reduce use of std::string

This commit is contained in:
Thomas Kunze 2024-08-19 20:45:41 +02:00
parent 8f3e2f683f
commit e0f0b49db4
22 changed files with 182 additions and 189 deletions

View File

@ -90,7 +90,7 @@ bool AddressTableObject::contains(uint16_t addr)
void AddressTableObject::beforeStateChange(LoadState& newState) void AddressTableObject::beforeStateChange(LoadState& newState)
{ {
LOGGER.info("beforeStateChange %S", enum_name(newState)); LOGGER.info("beforeStateChange %s", enum_name(newState));
TableObject::beforeStateChange(newState); TableObject::beforeStateChange(newState);
if (newState != LS_LOADED) if (newState != LS_LOADED)

View File

@ -43,7 +43,7 @@ uint8_t APDU::length() const
string APDU::toString() const string APDU::toString() const
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
string value = "APDU: " + enum_name(type()) + " "; string value = std::string("APDU: ") + enum_name(type()) + " ";
value += byte2hex(_data[0] & 0x3); value += byte2hex(_data[0] & 0x3);
for (uint8_t i = 1; i < length() + 1; ++i) for (uint8_t i = 1; i < length() + 1; ++i)

View File

@ -39,7 +39,7 @@ void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priori
void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl) void ApplicationLayer::dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl)
{ {
LOGGER.info("dataGroupIndication %S", apdu.toString()); LOGGER.info("dataGroupIndication %s", apdu.toString().c_str());
if (_assocTable == nullptr) if (_assocTable == nullptr)
return; return;
@ -92,7 +92,7 @@ void ApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType, Prior
void ApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl, bool status) void ApplicationLayer::dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl, bool status)
{ {
LOGGER.info("dataGroupConfirm %S", apdu.toString()); LOGGER.info("dataGroupConfirm %s", apdu.toString().c_str());
switch (apdu.type()) switch (apdu.type())
{ {
@ -130,7 +130,7 @@ void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority pr
void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, const SecurityControl& secCtrl) void ApplicationLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, const SecurityControl& secCtrl)
{ {
LOGGER.info("dataBroadcastIndication %S", apdu.toString()); LOGGER.info("dataBroadcastIndication %s", apdu.toString().c_str());
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
@ -190,7 +190,7 @@ void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, P
void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, const SecurityControl& secCtrl, bool status) void ApplicationLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU& apdu, const SecurityControl& secCtrl, bool status)
{ {
LOGGER.info("dataBroadcastConfirm %S", apdu.toString()); LOGGER.info("dataBroadcastConfirm %s", apdu.toString().c_str());
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
@ -245,7 +245,7 @@ void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Prior
void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, const SecurityControl& secCtrl) void ApplicationLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU& apdu, const SecurityControl& secCtrl)
{ {
LOGGER.info("dataSystemBroadcastIndication %S", apdu.toString()); LOGGER.info("dataSystemBroadcastIndication %s", apdu.toString().c_str());
const uint8_t* data = apdu.data(); const uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
@ -294,7 +294,7 @@ void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority
void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, const SecurityControl& secCtrl, bool status) void ApplicationLayer::dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU& apdu, const SecurityControl& secCtrl, bool status)
{ {
LOGGER.info("dataSystemBroadcastConfirm %S", apdu.toString()); LOGGER.info("dataSystemBroadcastConfirm %s", apdu.toString().c_str());
const uint8_t* data = apdu.data(); const uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
@ -1118,7 +1118,7 @@ void ApplicationLayer::userMemorySend(ApduType type, AckType ack, Priority prior
void ApplicationLayer::individualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl) void ApplicationLayer::individualIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl)
{ {
LOGGER.info("individualIndication %S", apdu.toString()); LOGGER.info("individualIndication %s", apdu.toString().c_str());
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())
@ -1374,13 +1374,13 @@ void ApplicationLayer::individualIndication(HopCountType hopType, Priority prior
} }
default: default:
LOGGER.warning("Individual-indication: unhandled APDU-Type: %S", apdu.toString()); LOGGER.warning("Individual-indication: unhandled APDU-Type: %s", apdu.toString().c_str());
} }
} }
void ApplicationLayer::individualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl, bool status) void ApplicationLayer::individualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu, const SecurityControl& secCtrl, bool status)
{ {
LOGGER.info("individualConfirm %S", apdu.toString()); LOGGER.info("individualConfirm %s", apdu.toString().c_str());
uint8_t* data = apdu.data(); uint8_t* data = apdu.data();
switch (apdu.type()) switch (apdu.type())

View File

@ -103,6 +103,6 @@ double ApplicationProgramObject::getFloat(uint32_t addr, ParameterFloatEncodings
void ApplicationProgramObject::beforeStateChange(LoadState& newState) void ApplicationProgramObject::beforeStateChange(LoadState& newState)
{ {
LOGGER.info("beforeStateChange %S", enum_name(newState)); LOGGER.info("beforeStateChange %s", enum_name(newState));
TableObject::beforeStateChange(newState); TableObject::beforeStateChange(newState);
} }

View File

@ -150,7 +150,7 @@ int32_t AssociationTableObject::translateAsap(uint16_t asap)
void AssociationTableObject::beforeStateChange(LoadState& newState) void AssociationTableObject::beforeStateChange(LoadState& newState)
{ {
LOGGER.info("beforeStateChange %S", enum_name(newState)); LOGGER.info("beforeStateChange %s", enum_name(newState));
TableObject::beforeStateChange(newState); TableObject::beforeStateChange(newState);
if (newState != LS_LOADED) if (newState != LS_LOADED)

View File

@ -403,13 +403,19 @@ bool CemiFrame::valid() const
std::string CemiFrame::toString() const std::string CemiFrame::toString() const
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
std::string value = "DPDU:" + enum_name(frameType()) + " "; std::string value = std::string("DPDU:") + enum_name(frameType()) + " ";
value += enum_name(systemBroadcast()) + " "; value += enum_name(systemBroadcast());
value += enum_name(ack()) + " "; value += " ";
value += enum_name(repetition()) + " "; value += enum_name(ack());
value += enum_name(priority()) + " from "; value += " ";
value += format_ia(sourceAddress()) + " to "; value += enum_name(repetition());
value += enum_name(addressType()) + " "; value += " ";
value += enum_name(priority());
value += " from ";
value += format_ia(sourceAddress());
value += " to ";
value += enum_name(addressType());
value += " ";
if (addressType() == AddressType::IndividualAddress) if (addressType() == AddressType::IndividualAddress)
value += format_ia(destinationAddress()); value += format_ia(destinationAddress());

View File

@ -59,7 +59,7 @@ bool DataLinkLayer::isTunnelAddress(uint16_t addr)
} }
#endif #endif
void DataLinkLayer::dataRequestFromTunnel(CemiFrame& frame) void DataLinkLayer::cddataRequestFromTunnel(CemiFrame& frame)
{ {
_cemiServer->dataConfirmationToTunnel(frame); _cemiServer->dataConfirmationToTunnel(frame);
@ -161,7 +161,7 @@ void DataLinkLayer::frameReceived(CemiFrame& frame)
SystemBroadcast systemBroadcast = frame.systemBroadcast(); SystemBroadcast systemBroadcast = frame.systemBroadcast();
LOGGER.info("frameReceived %S", frame.toString()); LOGGER.info("frameReceived %s", frame.toString().c_str());
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
@ -222,7 +222,7 @@ bool DataLinkLayer::sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAd
else else
frame.frameType(format); frame.frameType(format);
LOGGER.info("sendTelegram %S", frame.toString()); LOGGER.info("sendTelegram %s", frame.toString().c_str());
if (!frame.valid()) if (!frame.valid())
{ {

View File

@ -33,11 +33,11 @@ class DataLinkLayer
Platform& platform); Platform& platform);
#ifdef USE_CEMI_SERVER #ifdef USE_CEMI_SERVER
void cemiServer(CemiServer& cemiServer); void cemiServer(CemiServer& cemiServer);
#endif
#ifdef KNX_TUNNELING
// from tunnel // from tunnel
void dataRequestFromTunnel(CemiFrame& frame); void dataRequestFromTunnel(CemiFrame& frame);
#endif
#ifdef KNX_TUNNELING
virtual void dataRequestToTunnel(CemiFrame& frame); virtual void dataRequestToTunnel(CemiFrame& frame);
virtual void dataConfirmationToTunnel(CemiFrame& frame); virtual void dataConfirmationToTunnel(CemiFrame& frame);
virtual void dataIndicationToTunnel(CemiFrame& frame); virtual void dataIndicationToTunnel(CemiFrame& frame);

View File

@ -80,7 +80,7 @@ void GroupObjectTableObject::groupObjects(GroupObject* objs, uint16_t size)
void GroupObjectTableObject::beforeStateChange(LoadState& newState) void GroupObjectTableObject::beforeStateChange(LoadState& newState)
{ {
LOGGER.info("beforeStateChange %S", enum_name(newState)); LOGGER.info("beforeStateChange %s", enum_name(newState));
TableObject::beforeStateChange(newState); TableObject::beforeStateChange(newState);
if (newState != LS_LOADED) if (newState != LS_LOADED)

View File

@ -330,7 +330,7 @@ void IpDataLinkLayer::loop()
uint16_t code; uint16_t code;
popWord(code, buffer + 2); popWord(code, buffer + 2);
LOGGER.info("loop: %s", enum_name((KnxIpServiceType)code).c_str()); LOGGER.info("loop: %s", enum_name((KnxIpServiceType)code));
switch ((KnxIpServiceType)code) switch ((KnxIpServiceType)code)
{ {
@ -1138,7 +1138,7 @@ bool IpDataLinkLayer::sendMulicast(KnxIpFrame& ipFrame)
if (!_enabled) if (!_enabled)
return false; return false;
LOGGER.info("sendMulicast %S", ipFrame.toString()); LOGGER.info("sendMulicast %s %s", enum_name(ipFrame.protocolVersion()), enum_name(ipFrame.serviceTypeIdentifier()));
return _platform.sendBytesMultiCast(ipFrame.data(), ipFrame.totalLength()); return _platform.sendBytesMultiCast(ipFrame.data(), ipFrame.totalLength());
} }
@ -1148,7 +1148,7 @@ bool IpDataLinkLayer::sendUnicast(uint32_t addr, uint16_t port, KnxIpFrame& ipFr
if (!_enabled) if (!_enabled)
return false; return false;
LOGGER.info("sendUnicast to %S:%d %S", ipaddr2str(addr), port, ipFrame.toString()); LOGGER.info("sendUnicast to %s:%d %s %s", ipaddr2str(addr), port, enum_name(ipFrame.protocolVersion()), enum_name(ipFrame.serviceTypeIdentifier()));
return _platform.sendBytesMultiCast(ipFrame.data(), ipFrame.totalLength()); return _platform.sendBytesMultiCast(ipFrame.data(), ipFrame.totalLength());
} }

View File

@ -77,12 +77,7 @@ KnxIpFrame::KnxIpFrame(uint16_t length)
totalLength(length); totalLength(length);
} }
const std::string KnxIpFrame::toString() const const char* enum_name(const KnxIpVersion enum_val)
{
return enum_name(protocolVersion()) + " " + enum_name(serviceTypeIdentifier());
}
const string enum_name(const KnxIpVersion enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -90,10 +85,10 @@ const string enum_name(const KnxIpVersion enum_val)
return "KnxIp1_0"; return "KnxIp1_0";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const KnxIpServiceType enum_val) const char* enum_name(const KnxIpServiceType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -152,5 +147,5 @@ const string enum_name(const KnxIpServiceType enum_val)
return "RoutingLostMessage"; return "RoutingLostMessage";
} }
return to_string(enum_val); return "";
} }

View File

@ -8,7 +8,7 @@ enum KnxIpVersion
{ {
KnxIp1_0 = 0x10 KnxIp1_0 = 0x10
}; };
const string enum_name(const KnxIpVersion enum_val); const char* enum_name(const KnxIpVersion enum_val);
enum KnxIpServiceType enum KnxIpServiceType
{ {
@ -31,7 +31,7 @@ enum KnxIpServiceType
RoutingIndication = 0x530, RoutingIndication = 0x530,
RoutingLostMessage = 0x531, RoutingLostMessage = 0x531,
}; };
const string enum_name(const KnxIpServiceType enum_val); const char* enum_name(const KnxIpServiceType enum_val);
class KnxIpFrame class KnxIpFrame
{ {
@ -48,7 +48,6 @@ class KnxIpFrame
uint16_t totalLength() const; uint16_t totalLength() const;
void totalLength(uint16_t length); void totalLength(uint16_t length);
uint8_t* data(); uint8_t* data();
const std::string toString() const;
protected: protected:
bool _freeData = false; bool _freeData = false;
uint8_t* _data = 0; uint8_t* _data = 0;

View File

@ -1,6 +1,6 @@
#include "knx_types.h" #include "knx_types.h"
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
const string enum_name(const LCCONFIG enum_val) const char* enum_name(const LCCONFIG enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -35,11 +35,11 @@ const string enum_name(const LCCONFIG enum_val)
return "PHYS_IACK_ALL"; return "PHYS_IACK_ALL";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const LCGRPCONFIG enum_val) const char* enum_name(const LCGRPCONFIG enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -65,11 +65,11 @@ const string enum_name(const LCGRPCONFIG enum_val)
return "GROUP_7000LOCK"; return "GROUP_7000LOCK";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const DptMedium enum_val) const char* enum_name(const DptMedium enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -86,11 +86,11 @@ const string enum_name(const DptMedium enum_val)
return "KNX_IP"; return "KNX_IP";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const EraseCode enum_val) const char* enum_name(const EraseCode enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -119,11 +119,11 @@ const string enum_name(const EraseCode enum_val)
return "FactoryResetWithoutIA"; return "FactoryResetWithoutIA";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const RestartType enum_val) const char* enum_name(const RestartType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -134,11 +134,11 @@ const string enum_name(const RestartType enum_val)
return "MasterReset"; return "MasterReset";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const DataSecurity enum_val) const char* enum_name(const DataSecurity enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -152,11 +152,11 @@ const string enum_name(const DataSecurity enum_val)
return "AuthConf"; return "AuthConf";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const ApduType enum_val) const char* enum_name(const ApduType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -359,11 +359,11 @@ const string enum_name(const ApduType enum_val)
return "SecureService"; return "SecureService";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const TpduType enum_val) const char* enum_name(const TpduType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -392,11 +392,11 @@ const string enum_name(const TpduType enum_val)
return "Nack"; return "Nack";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const HopCountType enum_val) const char* enum_name(const HopCountType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -407,11 +407,11 @@ const string enum_name(const HopCountType enum_val)
return "NetworkLayerParameter"; return "NetworkLayerParameter";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const Confirm enum_val) const char* enum_name(const Confirm enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -422,11 +422,11 @@ const string enum_name(const Confirm enum_val)
return "ConfirmError"; return "ConfirmError";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const SystemBroadcast enum_val) const char* enum_name(const SystemBroadcast enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -437,11 +437,11 @@ const string enum_name(const SystemBroadcast enum_val)
return "Broadcast"; return "Broadcast";
} }
return to_string(enum_val); return "";
} }
const string enum_name(Repetition enum_val) const char* enum_name(Repetition enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -452,10 +452,10 @@ const string enum_name(Repetition enum_val)
return "WasNotRepeated/RepetitionAllowed"; return "WasNotRepeated/RepetitionAllowed";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const ReturnCodes enum_val) const char* enum_name(const ReturnCodes enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -511,11 +511,11 @@ const string enum_name(const ReturnCodes enum_val)
return "GenericError"; return "GenericError";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const cEmiErrorCode enum_val) const char* enum_name(const cEmiErrorCode enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -553,11 +553,11 @@ const string enum_name(const cEmiErrorCode enum_val)
return "Value_temp_not_writeable"; return "Value_temp_not_writeable";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const MessageCode enum_val) const char* enum_name(const MessageCode enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -601,11 +601,11 @@ const string enum_name(const MessageCode enum_val)
return "M_Reset_ind"; return "M_Reset_ind";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const AddressType enum_val) const char* enum_name(const AddressType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -616,11 +616,11 @@ const string enum_name(const AddressType enum_val)
return "GroupAddress"; return "GroupAddress";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const TPAckType enum_val) const char* enum_name(const TPAckType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -637,11 +637,11 @@ const string enum_name(const TPAckType enum_val)
return "AckReqNone"; return "AckReqNone";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const AckType enum_val) const char* enum_name(const AckType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -652,11 +652,11 @@ const string enum_name(const AckType enum_val)
return "AckRequested"; return "AckRequested";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const Priority enum_val) const char* enum_name(const Priority enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -673,11 +673,11 @@ const string enum_name(const Priority enum_val)
return "SystemPriority"; return "SystemPriority";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const FrameFormat enum_val) const char* enum_name(const FrameFormat enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -688,7 +688,7 @@ const string enum_name(const FrameFormat enum_val)
return "StandardFrame"; return "StandardFrame";
} }
return to_string(enum_val); return "";
} }
const string format_ia(uint16_t ia) const string format_ia(uint16_t ia)

View File

@ -8,7 +8,7 @@ enum FrameFormat
ExtendedFrame = 0, ExtendedFrame = 0,
StandardFrame = 0x80 StandardFrame = 0x80
}; };
const string enum_name(const FrameFormat enum_val); const char* enum_name(const FrameFormat enum_val);
enum Priority enum Priority
{ {
@ -17,14 +17,14 @@ enum Priority
UrgentPriority = 0x8, //!< Used for alarms. UrgentPriority = 0x8, //!< Used for alarms.
SystemPriority = 0x0 //!< Mainly used by ETS for device programming. SystemPriority = 0x0 //!< Mainly used by ETS for device programming.
}; };
const string enum_name(const Priority enum_val); const char* enum_name(const Priority enum_val);
enum AckType enum AckType
{ {
AckDontCare = 0, //!< We don't care about DataLinkLayer acknowledgement. AckDontCare = 0, //!< We don't care about DataLinkLayer acknowledgement.
AckRequested = 0x2, //!< We want a DataLinkLayer acknowledgement. AckRequested = 0x2, //!< We want a DataLinkLayer acknowledgement.
}; };
const string enum_name(const AckType enum_val); const char* enum_name(const AckType enum_val);
enum TPAckType enum TPAckType
{ {
@ -34,14 +34,14 @@ enum TPAckType
AckReqAck = 0x01, AckReqAck = 0x01,
AckReqNone = 0x0, AckReqNone = 0x0,
}; };
const string enum_name(const TPAckType enum_val); const char* enum_name(const TPAckType enum_val);
enum AddressType enum AddressType
{ {
IndividualAddress = 0, IndividualAddress = 0,
GroupAddress = 0x80, GroupAddress = 0x80,
}; };
const string enum_name(const AddressType enum_val); const char* enum_name(const AddressType enum_val);
enum MessageCode enum MessageCode
{ {
@ -67,7 +67,7 @@ enum MessageCode
M_Reset_req = 0xF1, M_Reset_req = 0xF1,
M_Reset_ind = 0xF0, M_Reset_ind = 0xF0,
}; };
const string enum_name(const MessageCode enum_val); const char* enum_name(const MessageCode enum_val);
enum cEmiErrorCode enum cEmiErrorCode
{ {
@ -83,7 +83,7 @@ enum cEmiErrorCode
Prop_Index_Range_Error = 0x09, // read or write access to a non existing Property array index (R/W) Prop_Index_Range_Error = 0x09, // read or write access to a non existing Property array index (R/W)
Value_temp_not_writeable = 0x0A, // The Property exists but can at this moment not be written with a new value (W) Value_temp_not_writeable = 0x0A, // The Property exists but can at this moment not be written with a new value (W)
}; };
const string enum_name(const cEmiErrorCode enum_val); const char* enum_name(const cEmiErrorCode enum_val);
// Unified return codes for KNX services and functions // Unified return codes for KNX services and functions
// Note, that several older KNX services and functions do not use these return codes. // Note, that several older KNX services and functions do not use these return codes.
@ -109,7 +109,7 @@ enum ReturnCodes
DataTypeConflict = 0xFE, // write access with wrong datatype (datapoint length) DataTypeConflict = 0xFE, // write access with wrong datatype (datapoint length)
GenericError = 0xFF // service, function or command failed GenericError = 0xFF // service, function or command failed
}; };
const string enum_name(const ReturnCodes enum_val); const char* enum_name(const ReturnCodes enum_val);
enum Repetition enum Repetition
{ {
@ -118,28 +118,28 @@ enum Repetition
RepetitionAllowed = 0x20, RepetitionAllowed = 0x20,
WasNotRepeated = 0x20, WasNotRepeated = 0x20,
}; };
const string enum_name(Repetition enum_val); const char* enum_name(Repetition enum_val);
enum SystemBroadcast enum SystemBroadcast
{ {
SysBroadcast = 0, SysBroadcast = 0,
Broadcast = 0x10, Broadcast = 0x10,
}; };
const string enum_name(const SystemBroadcast enum_val); const char* enum_name(const SystemBroadcast enum_val);
enum Confirm enum Confirm
{ {
ConfirmNoError = 0, ConfirmNoError = 0,
ConfirmError = 1, ConfirmError = 1,
}; };
const string enum_name(const Confirm enum_val); const char* enum_name(const Confirm enum_val);
enum HopCountType enum HopCountType
{ {
UnlimitedRouting, //!< NPDU::hopCount is set to 7. This means that the frame never expires. This could be a problem if your bus contains a circle. UnlimitedRouting, //!< NPDU::hopCount is set to 7. This means that the frame never expires. This could be a problem if your bus contains a circle.
NetworkLayerParameter //!< use NetworkLayer::hopCount as NPDU::hopCount NetworkLayerParameter //!< use NetworkLayer::hopCount as NPDU::hopCount
}; };
const string enum_name(const HopCountType enum_val); const char* enum_name(const HopCountType enum_val);
enum TpduType enum TpduType
{ {
@ -152,7 +152,7 @@ enum TpduType
Ack, Ack,
Nack, Nack,
}; };
const string enum_name(const TpduType enum_val); const char* enum_name(const TpduType enum_val);
enum ApduType enum ApduType
{ {
@ -234,7 +234,7 @@ enum ApduType
// Secure Service // Secure Service
SecureService = 0x3F1 SecureService = 0x3F1
}; };
const string enum_name(const ApduType enum_val); const char* enum_name(const ApduType enum_val);
enum DataSecurity enum DataSecurity
{ {
@ -242,7 +242,7 @@ enum DataSecurity
Auth, Auth,
AuthConf AuthConf
}; };
const string enum_name(const DataSecurity enum_val); const char* enum_name(const DataSecurity enum_val);
struct SecurityControl struct SecurityControl
{ {
@ -255,7 +255,7 @@ enum RestartType
BasicRestart = 0x0, BasicRestart = 0x0,
MasterReset = 0x1 MasterReset = 0x1
}; };
const string enum_name(const RestartType enum_val); const char* enum_name(const RestartType enum_val);
enum EraseCode enum EraseCode
{ {
@ -268,7 +268,7 @@ enum EraseCode
ResetLinks = 0x06, ResetLinks = 0x06,
FactoryResetWithoutIA = 0x07 FactoryResetWithoutIA = 0x07
}; };
const string enum_name(const EraseCode enum_val); const char* enum_name(const EraseCode enum_val);
enum DptMedium enum DptMedium
{ {
@ -279,7 +279,7 @@ enum DptMedium
KNX_RF = 0x02, KNX_RF = 0x02,
KNX_IP = 0x05 KNX_IP = 0x05
}; };
const string enum_name(const DptMedium enum_val); const char* enum_name(const DptMedium enum_val);
enum LCGRPCONFIG enum LCGRPCONFIG
{ {
@ -293,7 +293,7 @@ enum LCGRPCONFIG
GROUP_7000LOCK = 0b00001000, GROUP_7000LOCK = 0b00001000,
GROUP_7000ROUTE = 0b00001100 GROUP_7000ROUTE = 0b00001100
}; };
const string enum_name(const LCGRPCONFIG enum_val); const char* enum_name(const LCGRPCONFIG enum_val);
enum LCCONFIG enum LCCONFIG
{ {
@ -310,7 +310,7 @@ enum LCCONFIG
PHYS_IACK_ALL = 0b10000000, PHYS_IACK_ALL = 0b10000000,
PHYS_IACK_NACK = 0b11000000 PHYS_IACK_NACK = 0b11000000
}; };
const string enum_name(const LCCONFIG enum_val); const char* enum_name(const LCCONFIG enum_val);
const string format_ia(uint16_t ia); const string format_ia(uint16_t ia);
const string format_ga(uint16_t ga); const string format_ga(uint16_t ga);

View File

@ -27,7 +27,7 @@ void Memory::readMemory()
return; return;
} }
LOGGER.info("content %S", array2hex(flashStart, _metadataSize)); LOGGER.info("content %s", array2hex(flashStart, _metadataSize).c_str());
uint16_t metadataBlockSize = alignToPageSize(_metadataSize); uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
@ -70,9 +70,9 @@ void Memory::readMemory()
else else
{ {
LOGGER.warning("manufacturerId or hardwareType are different"); LOGGER.warning("manufacturerId or hardwareType are different");
LOGGER.warning("expexted manufacturerId: %S , stored manufacturerId: %S", LOGGER.warning("expexted manufacturerId: %s , stored manufacturerId: %s",
word2hex(_deviceObject.manufacturerId()), manufacturerId); word2hex(_deviceObject.manufacturerId()), manufacturerId);
LOGGER.warning("expexted hardwareType: %S, stored hardwareType: %S", LOGGER.warning("expexted hardwareType: %s, stored hardwareType: %s",
array2hex(_deviceObject.hardwareType(), LEN_HARDWARE_TYPE), array2hex(_deviceObject.hardwareType(), LEN_HARDWARE_TYPE),
array2hex(hardwareType, LEN_HARDWARE_TYPE)); array2hex(hardwareType, LEN_HARDWARE_TYPE));
} }
@ -80,7 +80,7 @@ void Memory::readMemory()
else else
{ {
LOGGER.warning("DataObject api changed, any data stored in flash is invalid."); LOGGER.warning("DataObject api changed, any data stored in flash is invalid.");
LOGGER.warning("expexted DataObject api version: %S, stored api version: %S", word2hex(_deviceObject.apiVersion), word2hex(apiVersion)); LOGGER.warning("expexted DataObject api version: %s, stored api version: %s", word2hex(_deviceObject.apiVersion), word2hex(apiVersion));
} }
if (versionCheck == FlashAllInvalid) if (versionCheck == FlashAllInvalid)

View File

@ -32,7 +32,7 @@ void NetworkLayerDevice::dataIndividualRequest(AckType ack, uint16_t destination
// print.print("-> NL "); // print.print("-> NL ");
// tpdu.apdu().printPDU(); // tpdu.apdu().printPDU();
//} //}
LOGGER.info("dataIndividualRequest %S", npdu.toString()); LOGGER.info("dataIndividualRequest %s", npdu.toString().c_str());
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, IndividualAddress, Broadcast); _netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, IndividualAddress, Broadcast);
} }
@ -45,7 +45,7 @@ void NetworkLayerDevice::dataGroupRequest(AckType ack, uint16_t destination, Hop
else else
npdu.hopCount(hopCount()); npdu.hopCount(hopCount());
LOGGER.info("dataGroupRequest %S", npdu.toString()); LOGGER.info("dataGroupRequest %s", npdu.toString().c_str());
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast); _netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, destination, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
} }
@ -58,7 +58,7 @@ void NetworkLayerDevice::dataBroadcastRequest(AckType ack, HopCountType hopType,
else else
npdu.hopCount(hopCount()); npdu.hopCount(hopCount());
LOGGER.info("dataBroadcastRequest %S", npdu.toString()); LOGGER.info("dataBroadcastRequest %s", npdu.toString().c_str());
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast); _netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, Broadcast);
} }
@ -75,13 +75,13 @@ void NetworkLayerDevice::dataSystemBroadcastRequest(AckType ack, HopCountType ho
else else
npdu.hopCount(hopCount()); npdu.hopCount(hopCount());
LOGGER.info("dataSystemBroadcastRequest %S", npdu.toString()); LOGGER.info("dataSystemBroadcastRequest %s", npdu.toString().c_str());
_netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, broadcastType); _netLayerEntities[kInterfaceIndex].sendDataRequest(npdu, ack, 0, _deviceObj.individualAddress(), priority, GroupAddress, broadcastType);
} }
void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx) void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint16_t destination, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
{ {
LOGGER.info("dataIndication %S", npdu.toString()); LOGGER.info("dataIndication %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
if (addrType == IndividualAddress) if (addrType == IndividualAddress)
@ -103,7 +103,7 @@ void NetworkLayerDevice::dataIndication(AckType ack, AddressType addrType, uint1
void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx) void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
{ {
LOGGER.info("dataConfirm %S", npdu.toString()); LOGGER.info("dataConfirm %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
if (addressType == IndividualAddress) if (addressType == IndividualAddress)
@ -122,7 +122,7 @@ void NetworkLayerDevice::dataConfirm(AckType ack, AddressType addressType, uint1
void NetworkLayerDevice::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx) void NetworkLayerDevice::broadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
{ {
LOGGER.info("broadcastIndication %S", npdu.toString()); LOGGER.info("broadcastIndication %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
DptMedium mediumType = _netLayerEntities[srcIfIdx].mediumType(); DptMedium mediumType = _netLayerEntities[srcIfIdx].mediumType();
@ -143,21 +143,21 @@ void NetworkLayerDevice::broadcastIndication(AckType ack, FrameFormat format, NP
void NetworkLayerDevice::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx) void NetworkLayerDevice::broadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
{ {
LOGGER.info("broadcastConfirm %S", npdu.toString()); LOGGER.info("broadcastConfirm %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status); _transportLayer.dataBroadcastConfirm(ack, hopType, priority, npdu.tpdu(), status);
} }
void NetworkLayerDevice::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx) void NetworkLayerDevice::systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu, Priority priority, uint16_t source, uint8_t srcIfIdx)
{ {
LOGGER.info("systemBroadcastIndication %S", npdu.toString()); LOGGER.info("systemBroadcastIndication %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataSystemBroadcastIndication(hopType, priority, source, npdu.tpdu()); _transportLayer.dataSystemBroadcastIndication(hopType, priority, source, npdu.tpdu());
} }
void NetworkLayerDevice::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx) void NetworkLayerDevice::systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status, uint8_t srcIfIdx)
{ {
LOGGER.info("systemBroadcastConfirm %S", npdu.toString()); LOGGER.info("systemBroadcastConfirm %s", npdu.toString().c_str());
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter; HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status); _transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status);
} }

View File

@ -245,7 +245,7 @@ void Property::state(uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t
resultLength = 0; resultLength = 0;
} }
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
const string enum_name(const PropertyDataType enum_val) const char* enum_name(const PropertyDataType enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -397,10 +397,10 @@ const string enum_name(const PropertyDataType enum_val)
return "PDT_ESCAPE"; return "PDT_ESCAPE";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const PropertyID enum_val) const char* enum_name(const PropertyID enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -718,10 +718,10 @@ const string enum_name(const PropertyID enum_val)
return "PID_IP_ENABLE_SBC"; return "PID_IP_ENABLE_SBC";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const LoadState enum_val) const char* enum_name(const LoadState enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -744,10 +744,10 @@ const string enum_name(const LoadState enum_val)
return "LS_LOADCOMPLETING"; return "LS_LOADCOMPLETING";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const LoadEvents enum_val) const char* enum_name(const LoadEvents enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -767,10 +767,10 @@ const string enum_name(const LoadEvents enum_val)
return "LE_UNLOAD"; return "LE_UNLOAD";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const ErrorCode enum_val) const char* enum_name(const ErrorCode enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -832,10 +832,10 @@ const string enum_name(const ErrorCode enum_val)
return "E_GO_TYPE_TOO_BIG"; return "E_GO_TYPE_TOO_BIG";
} }
return to_string(enum_val); return "";
} }
const string enum_name(const AccessLevel enum_val) const char* enum_name(const AccessLevel enum_val)
{ {
switch (enum_val) switch (enum_val)
{ {
@ -861,6 +861,6 @@ const string enum_name(const AccessLevel enum_val)
return "WriteLv3"; return "WriteLv3";
} }
return to_string(enum_val); return "";
} }
#endif #endif

View File

@ -66,7 +66,7 @@ enum PropertyDataType
PDT_FUNCTION = 0x3e, //!< length: 3 PDT_FUNCTION = 0x3e, //!< length: 3
PDT_ESCAPE = 0x3f, //!< length: 3 PDT_ESCAPE = 0x3f, //!< length: 3
}; };
const std::string enum_name(const PropertyDataType enum_val); const char* enum_name(const PropertyDataType enum_val);
enum PropertyID enum PropertyID
{ {
@ -195,7 +195,7 @@ enum PropertyID
PID_RF_ENABLE_SBC = 112, // Exists only if medium for this router object is RF (PDT_FUNCTION) PID_RF_ENABLE_SBC = 112, // Exists only if medium for this router object is RF (PDT_FUNCTION)
PID_IP_ENABLE_SBC = 120, // Exists only if medium for this router object is IP (PDT_FUNCTION) PID_IP_ENABLE_SBC = 120, // Exists only if medium for this router object is IP (PDT_FUNCTION)
}; };
const std::string enum_name(const PropertyID enum_val); const char* enum_name(const PropertyID enum_val);
enum LoadState enum LoadState
{ {
@ -206,7 +206,7 @@ enum LoadState
LS_UNLOADING = 4, LS_UNLOADING = 4,
LS_LOADCOMPLETING = 5 LS_LOADCOMPLETING = 5
}; };
const std::string enum_name(const LoadState enum_val); const char* enum_name(const LoadState enum_val);
enum LoadEvents enum LoadEvents
{ {
@ -216,7 +216,7 @@ enum LoadEvents
LE_ADDITIONAL_LOAD_CONTROLS = 3, LE_ADDITIONAL_LOAD_CONTROLS = 3,
LE_UNLOAD = 4 LE_UNLOAD = 4
}; };
const std::string enum_name(const LoadEvents enum_val); const char* enum_name(const LoadEvents enum_val);
// 20.011 DPT_ErrorClass_System // 20.011 DPT_ErrorClass_System
enum ErrorCode enum ErrorCode
@ -241,7 +241,7 @@ enum ErrorCode
E_INVALID_GO_NUMBER = 17, E_INVALID_GO_NUMBER = 17,
E_GO_TYPE_TOO_BIG = 18 E_GO_TYPE_TOO_BIG = 18
}; };
const std::string enum_name(const ErrorCode enum_val); const char* enum_name(const ErrorCode enum_val);
/** The access level necessary to read a property of an interface object. */ /** The access level necessary to read a property of an interface object. */
enum AccessLevel enum AccessLevel
@ -255,7 +255,7 @@ enum AccessLevel
WriteLv2 = 0x02, WriteLv2 = 0x02,
WriteLv3 = 0x03, WriteLv3 = 0x03,
}; };
const std::string enum_name(const AccessLevel enum_val); const char* enum_name(const AccessLevel enum_val);
struct PropertyDescription struct PropertyDescription
{ {

View File

@ -660,7 +660,7 @@ void SecureApplicationLayer::sendSyncRequest(uint16_t dstAddr, bool dstAddrIsGro
if (secure(request.data() + APDU_LPDU_DIFF, kSecureSyncRequest, _deviceObj.individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast)) if (secure(request.data() + APDU_LPDU_DIFF, kSecureSyncRequest, _deviceObj.individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu, sizeof(asdu), secCtrl, systemBcast))
{ {
LOGGER.info("SyncRequest: %S", request.apdu().toString()); LOGGER.info("SyncRequest: %s", request.apdu().toString().c_str());
if (_syncReqBroadcastOutgoing) if (_syncReqBroadcastOutgoing)
{ {
@ -723,7 +723,7 @@ void SecureApplicationLayer::sendSyncResponse(uint16_t dstAddr, bool dstAddrIsGr
{ {
_lastSyncRes = millis(); _lastSyncRes = millis();
LOGGER.info("SyncResponse: %S", response.apdu()); LOGGER.info("SyncResponse: %s", response.apdu().c_str());
if (_syncReqBroadcastIncoming) if (_syncReqBroadcastIncoming)
{ {
@ -1063,7 +1063,7 @@ bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLengt
bool SecureApplicationLayer::decodeSecureApdu(APDU& secureApdu, APDU& plainApdu, SecurityControl& secCtrl) bool SecureApplicationLayer::decodeSecureApdu(APDU& secureApdu, APDU& plainApdu, SecurityControl& secCtrl)
{ {
// Decode secure APDU // Decode secure APDU
LOGGER.info("decodeSecureApdu: Secure APDU: %S", secureApdu.toString()); LOGGER.info("decodeSecureApdu: Secure APDU: %s", secureApdu.toString().c_str());
uint16_t srcAddress = secureApdu.frame().sourceAddress(); uint16_t srcAddress = secureApdu.frame().sourceAddress();
uint16_t dstAddress = secureApdu.frame().destinationAddress(); uint16_t dstAddress = secureApdu.frame().destinationAddress();
@ -1085,7 +1085,7 @@ bool SecureApplicationLayer::decodeSecureApdu(APDU& secureApdu, APDU& plainApdu,
// We are starting from TPCI octet (including): plainApdu.frame().data()+APDU_LPDU_DIFF // We are starting from TPCI octet (including): plainApdu.frame().data()+APDU_LPDU_DIFF
if (decrypt(plainApdu.frame().data() + APDU_LPDU_DIFF, plainApdu.length() + 1, srcAddress, dstAddress, isDstAddrGroupAddr, tpci, secureApdu.data() + 1, secCtrl, isSystemBroadcast)) if (decrypt(plainApdu.frame().data() + APDU_LPDU_DIFF, plainApdu.length() + 1, srcAddress, dstAddress, isDstAddrGroupAddr, tpci, secureApdu.data() + 1, secCtrl, isSystemBroadcast))
{ {
LOGGER.info("decodeSecureApdu: Plain APDU: %S", plainApdu.frame().apdu().toString()); LOGGER.info("decodeSecureApdu: Plain APDU: %s", plainApdu.frame().apdu().toString().c_str());
return true; return true;
} }
@ -1260,7 +1260,7 @@ bool SecureApplicationLayer::createSecureApdu(APDU& plainApdu, APDU& secureApdu,
{ {
// Create secure APDU // Create secure APDU
LOGGER.info("createSecureApdu: Plain APDU: %S", plainApdu.frame().apdu().toString()); LOGGER.info("createSecureApdu: Plain APDU: %s", plainApdu.frame().apdu().toString().c_str());
uint16_t srcAddress = plainApdu.frame().sourceAddress(); uint16_t srcAddress = plainApdu.frame().sourceAddress();
uint16_t dstAddress = plainApdu.frame().destinationAddress(); uint16_t dstAddress = plainApdu.frame().destinationAddress();
@ -1296,7 +1296,7 @@ bool SecureApplicationLayer::createSecureApdu(APDU& plainApdu, APDU& secureApdu,
println(nextSequenceNumber(secCtrl.toolAccess), HEX); println(nextSequenceNumber(secCtrl.toolAccess), HEX);
updateSequenceNumber(secCtrl.toolAccess, nextSequenceNumber(secCtrl.toolAccess) + 1); updateSequenceNumber(secCtrl.toolAccess, nextSequenceNumber(secCtrl.toolAccess) + 1);
LOGGER.info("createSecureApdu: Secure APDU: %S", secureApdu.frame().apdu().toString()); LOGGER.info("createSecureApdu: Secure APDU: %s", secureApdu.frame().apdu().toString().c_str());
return true; return true;
} }

View File

@ -28,7 +28,7 @@ void TransportLayer::groupAddressTable(AddressTableObject& addrTable)
void TransportLayer::dataIndividualIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu) void TransportLayer::dataIndividualIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
{ {
LOGGER.info("dataIndividualIndication %S", tpdu.toString()); LOGGER.info("dataIndividualIndication %s", tpdu.toString().c_str());
uint8_t sequenceNo = tpdu.sequenceNumber(); uint8_t sequenceNo = tpdu.sequenceNumber();
@ -331,7 +331,7 @@ void TransportLayer::dataIndividualIndication(uint16_t destination, HopCountType
void TransportLayer::dataIndividualConfirm(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status) void TransportLayer::dataIndividualConfirm(AckType ack, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status)
{ {
LOGGER.info("dataIndividualConfirm %S", tpdu.toString()); LOGGER.info("dataIndividualConfirm %s", tpdu.toString().c_str());
TpduType type = tpdu.type(); TpduType type = tpdu.type();
switch (type) switch (type)
@ -405,7 +405,7 @@ void TransportLayer::dataIndividualConfirm(AckType ack, uint16_t destination, Ho
void TransportLayer::dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu) void TransportLayer::dataGroupIndication(uint16_t destination, HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
{ {
LOGGER.info("dataGroupIndication %S", tpdu.toString()); LOGGER.info("dataGroupIndication %s", tpdu.toString().c_str());
if (_groupAddressTable == nullptr) if (_groupAddressTable == nullptr)
return; return;
@ -423,31 +423,31 @@ void TransportLayer::dataGroupIndication(uint16_t destination, HopCountType hopT
void TransportLayer::dataGroupConfirm(AckType ack, uint16_t source, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status) void TransportLayer::dataGroupConfirm(AckType ack, uint16_t source, uint16_t destination, HopCountType hopType, Priority priority, TPDU& tpdu, bool status)
{ {
LOGGER.info("dataGroupConfirm %S", tpdu.toString()); LOGGER.info("dataGroupConfirm %s", tpdu.toString().c_str());
_applicationLayer.dataGroupConfirm(ack, hopType, priority, destination, tpdu.apdu(), status); _applicationLayer.dataGroupConfirm(ack, hopType, priority, destination, tpdu.apdu(), status);
} }
void TransportLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu) void TransportLayer::dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
{ {
LOGGER.info("dataBroadcastIndication %S", tpdu.toString()); LOGGER.info("dataBroadcastIndication %s", tpdu.toString().c_str());
_applicationLayer.dataBroadcastIndication(hopType, priority, source, tpdu.apdu()); _applicationLayer.dataBroadcastIndication(hopType, priority, source, tpdu.apdu());
} }
void TransportLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status) void TransportLayer::dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu, bool status)
{ {
LOGGER.info("dataBroadcastConfirm %S", tpdu.toString()); LOGGER.info("dataBroadcastConfirm %s", tpdu.toString().c_str());
_applicationLayer.dataBroadcastConfirm(ack, hopType, priority, tpdu.apdu(), status); _applicationLayer.dataBroadcastConfirm(ack, hopType, priority, tpdu.apdu(), status);
} }
void TransportLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu) void TransportLayer::dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, TPDU& tpdu)
{ {
LOGGER.info("dataSystemBroadcastIndication %S", tpdu.toString()); LOGGER.info("dataSystemBroadcastIndication %s", tpdu.toString().c_str());
_applicationLayer.dataSystemBroadcastIndication(hopType, priority, source, tpdu.apdu()); _applicationLayer.dataSystemBroadcastIndication(hopType, priority, source, tpdu.apdu());
} }
void TransportLayer::dataSystemBroadcastConfirm(AckType ack, HopCountType hopType, TPDU& tpdu, Priority priority, bool status) void TransportLayer::dataSystemBroadcastConfirm(AckType ack, HopCountType hopType, TPDU& tpdu, Priority priority, bool status)
{ {
LOGGER.info("dataSystemBroadcastConfirm %S", tpdu.toString()); LOGGER.info("dataSystemBroadcastConfirm %s", tpdu.toString().c_str());
_applicationLayer.dataSystemBroadcastConfirm(hopType, priority, tpdu.apdu(), status); _applicationLayer.dataSystemBroadcastConfirm(hopType, priority, tpdu.apdu(), status);
} }
@ -458,28 +458,28 @@ void TransportLayer::dataGroupRequest(AckType ack, HopCountType hopType, Priorit
uint16_t groupAdress = _groupAddressTable->getGroupAddress(tsap); uint16_t groupAdress = _groupAddressTable->getGroupAddress(tsap);
TPDU& tpdu = apdu.frame().tpdu(); TPDU& tpdu = apdu.frame().tpdu();
LOGGER.info("dataGroupRequest %S", tpdu.toString()); LOGGER.info("dataGroupRequest %s", tpdu.toString().c_str());
_networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu); _networkLayer->dataGroupRequest(ack, groupAdress, hopType, priority, tpdu);
} }
void TransportLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void TransportLayer::dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{ {
TPDU& tpdu = apdu.frame().tpdu(); TPDU& tpdu = apdu.frame().tpdu();
LOGGER.info("dataBroadcastRequest %S", tpdu.toString()); LOGGER.info("dataBroadcastRequest %s", tpdu.toString().c_str());
_networkLayer->dataBroadcastRequest(ack, hopType, priority, tpdu); _networkLayer->dataBroadcastRequest(ack, hopType, priority, tpdu);
} }
void TransportLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu) void TransportLayer::dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU& apdu)
{ {
TPDU& tpdu = apdu.frame().tpdu(); TPDU& tpdu = apdu.frame().tpdu();
LOGGER.info("dataSystemBroadcastRequest %S", tpdu.toString()); LOGGER.info("dataSystemBroadcastRequest %s", tpdu.toString().c_str());
return _networkLayer->dataSystemBroadcastRequest(ack, hopType, priority, tpdu); return _networkLayer->dataSystemBroadcastRequest(ack, hopType, priority, tpdu);
} }
void TransportLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu) void TransportLayer::dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU& apdu)
{ {
TPDU& tpdu = apdu.frame().tpdu(); TPDU& tpdu = apdu.frame().tpdu();
LOGGER.info("dataIndividualRequest %S", tpdu.toString()); LOGGER.info("dataIndividualRequest %s", tpdu.toString().c_str());
_networkLayer->dataIndividualRequest(ack, destination, hopType, priority, tpdu); _networkLayer->dataIndividualRequest(ack, destination, hopType, priority, tpdu);
} }
@ -641,7 +641,7 @@ void TransportLayer::sendControlTelegram(TpduType pduType, uint8_t seqNo)
TPDU& tpdu = frame.tpdu(); TPDU& tpdu = frame.tpdu();
tpdu.type(pduType); tpdu.type(pduType);
tpdu.sequenceNumber(seqNo); tpdu.sequenceNumber(seqNo);
LOGGER.info("sendControlTelegram %S", tpdu.toString()); LOGGER.info("sendControlTelegram %s", tpdu.toString().c_str());
_networkLayer->dataIndividualRequest(AckRequested, _connectionAddress, NetworkLayerParameter, _networkLayer->dataIndividualRequest(AckRequested, _connectionAddress, NetworkLayerParameter,
SystemPriority, tpdu); SystemPriority, tpdu);
} }

View File

@ -2,66 +2,66 @@
#include "../bits.h" #include "../bits.h"
Map<std::string, Logger::LogType, 64> Logger::_loggers; Map<const char*, Logger::LogType, 64> Logger::_loggers;
Logger Logger::_logger; Logger Logger::_logger;
Logger& Logger::logger(const std::string name) Logger& Logger::logger(const char* name)
{ {
_logger.name(name); _logger.name(name);
return _logger; return _logger;
} }
void Logger::logLevel(const std::string name, LogType level) void Logger::logLevel(const char* name, LogType level)
{ {
_loggers.insertOrAssign(name, level); _loggers.insertOrAssign(name, level);
} }
void Logger::info(const std::string message, ...) void Logger::info(const char* message, ...)
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
va_list objects; va_list objects;
va_start( objects, message); va_start( objects, message);
log(LogType::Info, message.c_str(), objects); log(LogType::Info, message, objects);
va_end(objects); va_end(objects);
#endif #endif
} }
void Logger::warning(const std::string message, ...) void Logger::warning(const char* message, ...)
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
va_list objects; va_list objects;
va_start( objects, message); va_start( objects, message);
log(LogType::Warning, message.c_str(), objects); log(LogType::Warning, message, objects);
va_end(objects); va_end(objects);
#endif #endif
} }
void Logger::error(const std::string message, ...) void Logger::error(const char* message, ...)
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
va_list objects; va_list objects;
va_start( objects, message); va_start( objects, message);
log(LogType::Error, message.c_str(), objects); log(LogType::Error, message, objects);
va_end(objects); va_end(objects);
#endif #endif
} }
void Logger::critical(const std::string message, ...) void Logger::critical(const char* message, ...)
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
va_list objects; va_list objects;
va_start( objects, message); va_start( objects, message);
log(LogType::Critical, message.c_str(), objects); log(LogType::Critical, message, objects);
va_end(objects); va_end(objects);
#endif #endif
} }
void Logger::exception(const std::string message, ...) void Logger::exception(const char* message, ...)
{ {
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
va_list objects; va_list objects;
va_start( objects, message); va_start( objects, message);
log(LogType::Exception, message.c_str(), objects); log(LogType::Exception, message, objects);
va_end(objects); va_end(objects);
#endif #endif
} }
@ -72,9 +72,9 @@ void Logger::log(LogType type, const char* format, va_list args)
LogType* level = _loggers.get(_name); LogType* level = _loggers.get(_name);
if(level == nullptr) { if(level == nullptr) {
print("Logger "); print("Logger ");
print(_name.c_str()); print(_name);
print(" is disabled. Use Logger::logLevel(\""); print(" is disabled. Use Logger::logLevel(\"");
print(_name.c_str()); print(_name);
println("\", Logger::Info) to enable."); println("\", Logger::Info) to enable.");
_loggers.insertOrAssign(_name, Disabled); _loggers.insertOrAssign(_name, Disabled);
return; return;
@ -85,9 +85,9 @@ void Logger::log(LogType type, const char* format, va_list args)
print(millis()); print(millis());
print(" "); print(" ");
print(_name.c_str()); print(_name);
print("\t"); print("\t");
print(enum_name(type).c_str()); print(enum_name(type));
print(" "); print(" ");
while (*format) while (*format)
@ -104,10 +104,6 @@ void Logger::log(LogType type, const char* format, va_list args)
{ {
print(va_arg(args, char*)); print(va_arg(args, char*));
} }
else if (*format == 'S')
{
print(va_arg(args, std::string).c_str());
}
else if (*format == 'f') else if (*format == 'f')
{ {
print(va_arg(args, double)); print(va_arg(args, double));
@ -126,7 +122,7 @@ void Logger::log(LogType type, const char* format, va_list args)
#endif #endif
} }
#ifndef KNX_NO_PRINT #ifndef KNX_NO_PRINT
const std::string Logger::enum_name(LogType type) const char* Logger::enum_name(LogType type)
{ {
switch (type) switch (type)
{ {
@ -149,6 +145,6 @@ const std::string Logger::enum_name(LogType type)
return "DISA"; return "DISA";
} }
return std::to_string(type); return "";
} }
#endif #endif

View File

@ -1,26 +1,23 @@
#include <stdarg.h> #include <stdarg.h>
#include <string>
#include "simple_map.h" #include "simple_map.h"
class NoOpLogger;
class Logger class Logger
{ {
public: public:
enum LogType { Info, Warning, Error, Critical, Exception, Disabled}; enum LogType { Info, Warning, Error, Critical, Exception, Disabled};
static Logger& logger(const std::string name); static Logger& logger(const char* name);
static void logLevel(const std::string name, LogType level); static void logLevel(const char* name, LogType level);
void info(const std::string message, ...); void info(const char* message, ...);
void warning(const std::string message, ...); void warning(const char* message, ...);
void error(const std::string message, ...); void error(const char* message, ...);
void critical(const std::string message, ...); void critical(const char* message, ...);
void exception(const std::string message, ...); void exception(const char* message, ...);
protected: protected:
Logger() {} Logger() {}
void log(LogType type, const char* format, va_list args); void log(LogType type, const char* format, va_list args);
void name(std::string value) { _name = value; } void name(const char* value) { _name = value; }
private: private:
const std::string enum_name(LogType type); const char* enum_name(LogType type);
std::string _name = ""; const char* _name = "";
static Map<std::string, LogType, 64> _loggers; static Map<const char*, LogType, 64> _loggers;
static Logger _logger; static Logger _logger;
}; };