Skip to content

Commit

Permalink
Provide conversion of expansion type to string for easier reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger committed Jul 23, 2024
1 parent 1290037 commit b7cc798
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/opcua_server/opcua_server.ino
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ void setup()
uint8_t const opta_expansion_num = OptaController.getExpansionNum();
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "OptaController %d expansion modules detected.", opta_expansion_num);
for(uint8_t i = 0; i < opta_expansion_num; i++)
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Expansion %d: type = %d, I2C address= 0x%02X", i, OptaController.getExpansionType(i), OptaController.getExpansionI2Caddress(i));
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Expansion %d: type = %d (\"%16s\"), I2C address= 0x%02X",
i, OptaController.getExpansionType(i), opcua::ArduinoOptaExpansionType::toStr(OptaController.getExpansionType(i)).c_str(), OptaController.getExpansionI2Caddress(i));

#if USE_MODBUS_SENSOR_MD02
{
Expand Down
1 change: 1 addition & 0 deletions src/ArduinoOpta.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "DigitalInputManager.h"
#include "UserButton.h"
#include "ArduinoOptaVariant.h"
#include "ArduinoOptaExpansionType.h"

/**************************************************************************************
* NAMESPACE
Expand Down
58 changes: 58 additions & 0 deletions src/ArduinoOptaExpansionType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2024 Arduino
*
* SPDX-License-Identifier: MPL-2.0
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

/**************************************************************************************
* INCLUDE
**************************************************************************************/

#include <string>

#include "OptaBlue.h"

/**************************************************************************************
* NAMESPACE
**************************************************************************************/

namespace opcua
{

/**************************************************************************************
* CLASS DECLARATION
**************************************************************************************/

class ArduinoOptaExpansionType
{
public:
ArduinoOptaExpansionType() = delete;
ArduinoOptaExpansionType(ArduinoOptaExpansionType const &) = delete;

static std::string toStr(ExpansionType_t const type)
{
if(type == EXPANSION_NOT_VALID)
return std::string("Invalid");
else if(type == EXPANSION_OPTA_DIGITAL_MEC)
return std::string("Digital [Mech.]");
else if(type == EXPANSION_OPTA_DIGITAL_STS)
return std::string("Digital [Solid]");
else if(type == EXPANSION_DIGITAL_INVALID)
return std::string("Digital [Inva.]");
else if(type == EXPANSION_OPTA_ANALOG)
return std::string("Analog");
else
return std::string("Unknown");
}
};

/**************************************************************************************
* NAMESPACE
**************************************************************************************/

}

0 comments on commit b7cc798

Please sign in to comment.