Make debug prints portable (#929)
This commit is contained in:
@@ -256,7 +256,7 @@ bool _readFromClient(uint8_t i)
|
||||
if (inChar == '\n' || inChar == '\r') {
|
||||
// Add string terminator and prepare for the next message
|
||||
inputString[i].string[inputString[i].idx] = 0;
|
||||
debug(PSTR("Client %d: %s\n"), i, inputString[i].string);
|
||||
debug(PSTR("Client %" PRIu8 ": %s\n"), i, inputString[i].string);
|
||||
inputString[i].idx = 0;
|
||||
if (protocolParse(_ethernetMsg, inputString[i].string)) {
|
||||
return true;
|
||||
@@ -268,7 +268,7 @@ bool _readFromClient(uint8_t i)
|
||||
}
|
||||
} else {
|
||||
// Incoming message too long. Throw away
|
||||
debug(PSTR("Client %d: Message too long\n"), i);
|
||||
debug(PSTR("Client %" PRIu8 ": Message too long\n"), i);
|
||||
inputString[i].idx = 0;
|
||||
// Finished with this client's message. Next loop() we'll see if there's more to read.
|
||||
break;
|
||||
@@ -322,7 +322,7 @@ bool gatewayTransportAvailable(void)
|
||||
int packet_size = _ethernetServer.parsePacket();
|
||||
|
||||
if (packet_size) {
|
||||
//debug(PSTR("UDP packet available. Size:%d\n"), packet_size);
|
||||
//debug(PSTR("UDP packet available. Size:%" PRIu8 "\n"), packet_size);
|
||||
_ethernetServer.read(inputString.string, MY_GATEWAY_MAX_RECEIVE_LENGTH);
|
||||
inputString.string[packet_size] = 0;
|
||||
debug(PSTR("UDP packet received: %s\n"), inputString.string);
|
||||
@@ -366,14 +366,14 @@ bool gatewayTransportAvailable(void)
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
|
||||
if (!clients[i].connected()) {
|
||||
if (clientsConnected[i]) {
|
||||
debug(PSTR("Client %d disconnected\n"), i);
|
||||
debug(PSTR("Client %" PRIu8 " disconnected\n"), i);
|
||||
clients[i].stop();
|
||||
}
|
||||
//check if there are any new clients
|
||||
if (_ethernetServer.hasClient()) {
|
||||
clients[i] = _ethernetServer.available();
|
||||
inputString[i].idx = 0;
|
||||
debug(PSTR("Client %d connected\n"), i);
|
||||
debug(PSTR("Client %" PRIu8 " connected\n"), i);
|
||||
gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set(MSG_GW_STARTUP_COMPLETE));
|
||||
// Send presentation of locally attached sensors (and node if applicable)
|
||||
presentNode();
|
||||
|
||||
@@ -59,7 +59,8 @@ void firmwareOTAUpdateRequest(void)
|
||||
firmwareRequest.type = _nodeFirmwareConfig.type;
|
||||
firmwareRequest.version = _nodeFirmwareConfig.version;
|
||||
firmwareRequest.block = (_firmwareBlock - 1);
|
||||
OTA_DEBUG(PSTR("OTA:FRQ:FW REQ,T=%04X,V=%04X,B=%04X\n"), _nodeFirmwareConfig.type,
|
||||
OTA_DEBUG(PSTR("OTA:FRQ:FW REQ,T=%04" PRIX16 ",V=%04" PRIX16 ",B=%04" PRIX16 "\n"),
|
||||
_nodeFirmwareConfig.type,
|
||||
_nodeFirmwareConfig.version, _firmwareBlock - 1); // request FW update block
|
||||
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_STREAM, ST_FIRMWARE_REQUEST,
|
||||
false).set(&firmwareRequest, sizeof(requestFirmwareBlock_t)));
|
||||
@@ -100,7 +101,7 @@ bool firmwareOTAUpdateProcess(void)
|
||||
// extract FW block
|
||||
replyFirmwareBlock_t *firmwareResponse = (replyFirmwareBlock_t *)_msg.data;
|
||||
|
||||
OTA_DEBUG(PSTR("OTA:FWP:RECV B=%04X\n"), firmwareResponse->block); // received FW block
|
||||
OTA_DEBUG(PSTR("OTA:FWP:RECV B=%04" PRIX16 "\n"), firmwareResponse->block); // received FW block
|
||||
if (firmwareResponse->block != _firmwareBlock - 1) {
|
||||
OTA_DEBUG(PSTR("!OTA:FWP:WRONG FWB\n")); // received FW block
|
||||
// wrong firmware block received
|
||||
@@ -119,14 +120,15 @@ bool firmwareOTAUpdateProcess(void)
|
||||
char prbuf[8];
|
||||
uint32_t addr = ((_firmwareBlock - 1) * FIRMWARE_BLOCK_SIZE) + FIRMWARE_START_OFFSET;
|
||||
OTA_DEBUG(PSTR("OTA:FWP:FL DUMP "));
|
||||
sprintf_P(prbuf,PSTR("%04X:"), (uint16_t)addr);
|
||||
sprintf_P(prbuf,PSTR("%04" PRIX16 ":"), (uint16_t)addr);
|
||||
MY_SERIALDEVICE.print(prbuf);
|
||||
for(uint8_t i=0; i<FIRMWARE_BLOCK_SIZE; i++) {
|
||||
uint8_t data = _flash.readByte(addr + i);
|
||||
sprintf_P(prbuf,PSTR("%02X"), (unsigned int)data);
|
||||
sprintf_P(prbuf,PSTR("%02" PRIX8 ""), (uint8_t)data);
|
||||
MY_SERIALDEVICE.print(prbuf);
|
||||
}
|
||||
OTA_DEBUG(PSTR("\n"));
|
||||
8
|
||||
}
|
||||
#endif
|
||||
_firmwareBlock--;
|
||||
@@ -195,7 +197,8 @@ bool transportIsValidFirmware(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
OTA_DEBUG(PSTR("OTA:CRC:B=%04X,C=%04X,F=%04X\n"), _nodeFirmwareConfig.blocks,crc,
|
||||
OTA_DEBUG(PSTR("OTA:CRC:B=%04" PRIX16 ",C=%04" PRIX16 ",F=%04" PRIX16 "\n"),
|
||||
_nodeFirmwareConfig.blocks,crc,
|
||||
_nodeFirmwareConfig.crc);
|
||||
return crc == _nodeFirmwareConfig.crc;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -99,7 +99,8 @@ bool protocolParse(MyMessage &message, char *inputString)
|
||||
|
||||
char * protocolFormat(MyMessage &message)
|
||||
{
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%d;%d;%d;%d;%d;%s\n"), message.sender,
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH,
|
||||
PSTR("%" PRIu8 ";%" PRIu8 ";%" PRIu8 ";%" PRIu8 ";%" PRIu8 ";%s\n"), message.sender,
|
||||
message.sensor, (uint8_t)mGetCommand(message), (uint8_t)mGetAck(message), message.type,
|
||||
message.getString(_convBuffer));
|
||||
return _fmtBuffer;
|
||||
@@ -107,7 +108,8 @@ char * protocolFormat(MyMessage &message)
|
||||
|
||||
char * protocolFormatMQTTTopic(const char* prefix, MyMessage &message)
|
||||
{
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%s/%d/%d/%d/%d/%d"), prefix,
|
||||
snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH,
|
||||
PSTR("%s/%" PRIu8 "/%" PRIu8 "/%" PRIu8 "/%" PRIu8 "/%" PRIu8 ""), prefix,
|
||||
message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type);
|
||||
return _fmtBuffer;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -169,7 +169,7 @@ void _begin(void)
|
||||
setup();
|
||||
}
|
||||
#if defined(MY_SENSOR_NETWORK)
|
||||
CORE_DEBUG(PSTR("MCO:BGN:INIT OK,TSP=%d\n"), isTransportReady());
|
||||
CORE_DEBUG(PSTR("MCO:BGN:INIT OK,TSP=%" PRIu8 "\n"), isTransportReady());
|
||||
#else
|
||||
// no sensor network defined, call presentation & registration
|
||||
_callbackTransportReady();
|
||||
@@ -407,7 +407,7 @@ bool _processInternalMessages(void)
|
||||
#if defined (MY_REGISTRATION_FEATURE) && !defined(MY_GATEWAY_FEATURE)
|
||||
_coreConfig.nodeRegistered = _msg.getBool();
|
||||
setIndication(INDICATION_GOT_REGISTRATION);
|
||||
CORE_DEBUG(PSTR("MCO:PIM:NODE REG=%d\n"), _coreConfig.nodeRegistered); // node registration
|
||||
CORE_DEBUG(PSTR("MCO:PIM:NODE REG=%" PRIu8 "\n"), _coreConfig.nodeRegistered); // node registration
|
||||
#endif
|
||||
} else if (type == I_CONFIG) {
|
||||
// Pick up configuration from controller (currently only metric/imperial) and store it in eeprom if changed
|
||||
@@ -540,7 +540,8 @@ void doYield(void)
|
||||
int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t interrupt1,
|
||||
const uint8_t mode1, const uint8_t interrupt2, const uint8_t mode2)
|
||||
{
|
||||
CORE_DEBUG(PSTR("MCO:SLP:MS=%lu,SMS=%d,I1=%d,M1=%d,I2=%d,M2=%d\n"), sleepingMS, smartSleep,
|
||||
CORE_DEBUG(PSTR("MCO:SLP:MS=%" PRIu32 ",SMS=%" PRIu8 ",I1=%" PRIu8 ",M1=%" PRIu8 ",I2=%" PRIu8
|
||||
",M2=%" PRIu8 "\n"), sleepingMS, smartSleep,
|
||||
interrupt1, mode1, interrupt2, mode2);
|
||||
// OTA FW feature: do not sleep if FW update ongoing
|
||||
#if defined(MY_OTA_FIRMWARE_FEATURE)
|
||||
@@ -577,7 +578,7 @@ int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t in
|
||||
// sleep remainder
|
||||
if (sleepDeltaMS < sleepingTimeMS) {
|
||||
sleepingTimeMS -= sleepDeltaMS; // calculate remaining sleeping time
|
||||
CORE_DEBUG(PSTR("MCO:SLP:MS=%lu\n"), sleepingTimeMS);
|
||||
CORE_DEBUG(PSTR("MCO:SLP:MS=%" PRIu32 "\n"), sleepingTimeMS);
|
||||
} else {
|
||||
// no sleeping time left
|
||||
return MY_SLEEP_NOT_POSSIBLE;
|
||||
@@ -617,7 +618,7 @@ int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t in
|
||||
result = hwSleep(sleepingTimeMS);
|
||||
}
|
||||
setIndication(INDICATION_WAKEUP);
|
||||
CORE_DEBUG(PSTR("MCO:SLP:WUP=%d\n"), result); // sleep wake-up
|
||||
CORE_DEBUG(PSTR("MCO:SLP:WUP=%" PRIi8 "\n"), result); // sleep wake-up
|
||||
#if defined(MY_SENSOR_NETWORK)
|
||||
transportReInitialise();
|
||||
#endif
|
||||
@@ -677,7 +678,8 @@ void _nodeLock(const char* str)
|
||||
hwWriteConfig(EEPROM_NODE_LOCK_COUNTER, 0);
|
||||
while (1) {
|
||||
setIndication(INDICATION_ERR_LOCKED);
|
||||
CORE_DEBUG(PSTR("MCO:NLK:NODE LOCKED. TO UNLOCK, GND PIN %d AND RESET\n"), MY_NODE_UNLOCK_PIN);
|
||||
CORE_DEBUG(PSTR("MCO:NLK:NODE LOCKED. TO UNLOCK, GND PIN %" PRIu8 " AND RESET\n"),
|
||||
MY_NODE_UNLOCK_PIN);
|
||||
doYield();
|
||||
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID,C_INTERNAL, I_LOCKED).set(str));
|
||||
#if defined(MY_SENSOR_NETWORK)
|
||||
|
||||
+39
-29
@@ -155,9 +155,10 @@ void signerPresentation(MyMessage &msg, uint8_t destination)
|
||||
#endif
|
||||
|
||||
if (!_sendRoute(msg)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%d FAIL\n"), destination); // Failed to transmit presentation!
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%" PRIu8 " FAIL\n"),
|
||||
destination); // Failed to transmit presentation!
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%d\n"), destination); // Transmitted signing presentation!
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%" PRIu8 "\n"), destination); // Transmitted signing presentation!
|
||||
}
|
||||
|
||||
if (destination == GATEWAY_ADDRESS) {
|
||||
@@ -210,11 +211,11 @@ bool signerSignMsg(MyMessage &msg)
|
||||
_signingNonceStatus=SIGN_WAITING_FOR_NONCE;
|
||||
if (!_sendRoute(build(_msgSign, msg.destination, msg.sensor, C_INTERNAL,
|
||||
I_NONCE_REQUEST).set(""))) {
|
||||
SIGN_DEBUG(PSTR("!SGN:SGN:NCE REQ,TO=%d FAIL\n"),
|
||||
SIGN_DEBUG(PSTR("!SGN:SGN:NCE REQ,TO=%" PRIu8 " FAIL\n"),
|
||||
msg.destination); // Failed to transmit nonce request!
|
||||
ret = false;
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:NCE REQ,TO=%d\n"), msg.destination); // Nonce requested
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:NCE REQ,TO=%" PRIu8 "\n"), msg.destination); // Nonce requested
|
||||
// We have to wait for the nonce to arrive before we can sign our original message
|
||||
// Other messages could come in-between. We trust _process() takes care of them
|
||||
unsigned long enter = hwMillis();
|
||||
@@ -245,10 +246,11 @@ bool signerSignMsg(MyMessage &msg)
|
||||
}
|
||||
} else if (getNodeId() == msg.sender) {
|
||||
mSetSigned(msg, 0); // Message is not supposed to be signed, make sure it is marked unsigned
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:NREQ=%d\n"), msg.destination); // Do not sign message as it is not req
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:NREQ=%" PRIu8 "\n"),
|
||||
msg.destination); // Do not sign message as it is not req
|
||||
ret = true;
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:%d!=%d NUS\n"), msg.sender,
|
||||
SIGN_DEBUG(PSTR("SGN:SGN:%" PRIu8 "!=%" PRIu8 " NUS\n"), msg.sender,
|
||||
getNodeId()); // Will not sign message since it was from someone else
|
||||
ret = true;
|
||||
}
|
||||
@@ -300,7 +302,7 @@ bool signerVerifyMsg(MyMessage &msg)
|
||||
nof_failed_verifications = 0;
|
||||
} else {
|
||||
nof_failed_verifications++;
|
||||
SIGN_DEBUG(PSTR("SGN:VER:LEFT=%d\n"), MY_NODE_LOCK_COUNTER_MAX-nof_failed_verifications);
|
||||
SIGN_DEBUG(PSTR("SGN:VER:LEFT=%" PRIu8 "\n"), MY_NODE_LOCK_COUNTER_MAX-nof_failed_verifications);
|
||||
if (nof_failed_verifications >= MY_NODE_LOCK_COUNTER_MAX) {
|
||||
_nodeLock("TMFV"); // Too many failed verifications
|
||||
}
|
||||
@@ -388,7 +390,8 @@ static bool skipSign(MyMessage &msg)
|
||||
ret = true;
|
||||
}
|
||||
if (ret) {
|
||||
SIGN_DEBUG(PSTR("SGN:SKP:%s CMD=%d,TYPE=%d\n"), mGetAck(msg) ? "ACK" : "MSG", mGetCommand(msg),
|
||||
SIGN_DEBUG(PSTR("SGN:SKP:%s CMD=%" PRIu8 ",TYPE=%" PRIu8 "\n"), mGetAck(msg) ? "ACK" : "MSG",
|
||||
mGetCommand(msg),
|
||||
msg.type); //Skip signing/verification of this message
|
||||
}
|
||||
return ret;
|
||||
@@ -412,38 +415,40 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
|
||||
const uint8_t sender = msg.sender;
|
||||
#if defined(MY_SIGNING_FEATURE)
|
||||
if (msg.data[0] != SIGNING_PRESENTATION_VERSION_1) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:VER=%d\n"), msg.data[0]); // Unsupported signing presentation version
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:VER=%" PRIu8 "\n"),
|
||||
msg.data[0]); // Unsupported signing presentation version
|
||||
return true; // Just drop this presentation message
|
||||
}
|
||||
// We only handle version 1 here...
|
||||
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_SIGNATURES) {
|
||||
// We received an indicator that the sender require us to sign all messages we send to it
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN REQ,FROM=%d\n"), sender); // Node require signatures
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN REQ,FROM=%" PRIu8 "\n"), sender); // Node require signatures
|
||||
SET_SIGN(sender);
|
||||
} else {
|
||||
#if defined(MY_SIGNING_WEAK_SECURITY)
|
||||
// We received an indicator that the sender does not require us to sign messages we send to it
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN NREQ,FROM=%d\n"), sender); // Node does not require signatures
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN NREQ,FROM=%" PRIu8 "\n"), sender); // Node does not require signatures
|
||||
CLEAR_SIGN(sender);
|
||||
#else
|
||||
if (DO_SIGN(sender)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:SGN NREQ,FROM=%d REJ\n"),
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:SGN NREQ,FROM=%" PRIu8 " REJ\n"),
|
||||
sender); // Node does not require signatures but used to do so
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_WHITELISTING) {
|
||||
// We received an indicator that the sender require us to salt signatures with serial
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI REQ,FROM=%d\n"), sender); // Node require whitelisting
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI REQ,FROM=%" PRIu8 "\n"), sender); // Node require whitelisting
|
||||
SET_WHITELIST(sender);
|
||||
} else {
|
||||
#if defined(MY_SIGNING_WEAK_SECURITY)
|
||||
// We received an indicator that the sender does not require us to sign messages we send to it
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI NREQ,FROM=%d\n"), sender); // Node does not require whitelisting
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI NREQ,FROM=%" PRIu8 "\n"),
|
||||
sender); // Node does not require whitelisting
|
||||
CLEAR_WHITELIST(sender);
|
||||
#else
|
||||
if (DO_WHITELIST(sender)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:WHI NREQ,FROM=%d REJ\n"),
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:WHI NREQ,FROM=%" PRIu8 " REJ\n"),
|
||||
sender); // Node does not require whitelisting but used to do so
|
||||
}
|
||||
#endif
|
||||
@@ -472,21 +477,24 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
|
||||
msg.data[1] |= SIGNING_PRESENTATION_REQUIRE_WHITELISTING;
|
||||
#endif // MY_SIGNING_NODE_WHITELISTING
|
||||
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_SIGNATURES) {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN REQ,TO=%d\n"), sender); // Inform node that we require signatures
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN REQ,TO=%" PRIu8 "\n"),
|
||||
sender); // Inform node that we require signatures
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN NREQ,TO=%d\n"),
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:SGN NREQ,TO=%" PRIu8 "\n"),
|
||||
sender); // Inform node that we do not require signatures
|
||||
}
|
||||
if (msg.data[1] & SIGNING_PRESENTATION_REQUIRE_WHITELISTING) {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI REQ,TO=%d\n"), sender); // Inform node that we require whitelisting
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI REQ,TO=%" PRIu8 "\n"),
|
||||
sender); // Inform node that we require whitelisting
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI NREQ,TO=%d\n"),
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:WHI NREQ,TO=%" PRIu8 "\n"),
|
||||
sender); // Inform node that we do not require whitelisting
|
||||
}
|
||||
if (!_sendRoute(msg)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%d FAIL\n"), sender); // Failed to transmit signing presentation!
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%" PRIu8 " FAIL\n"),
|
||||
sender); // Failed to transmit signing presentation!
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%d\n"), sender);
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%" PRIu8 "\n"), sender);
|
||||
}
|
||||
#endif // MY_GATEWAY_FEATURE
|
||||
#else // not MY_SIGNING_FEATURE
|
||||
@@ -494,11 +502,13 @@ static bool signerInternalProcessPresentation(MyMessage &msg)
|
||||
// If we act as gateway and do not have the signing feature and receive a signing request we still
|
||||
// need to do make sure the requester does not believe the gateway still require signatures
|
||||
prepareSigningPresentation(msg, sender);
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:NSUP,TO=%d\n"), sender); // Informing node that we do not support signing
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:NSUP,TO=%" PRIu8 "\n"),
|
||||
sender); // Informing node that we do not support signing
|
||||
if (!_sendRoute(msg)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%d FAIL\n"), sender); // Failed to transmit signing presentation!
|
||||
SIGN_DEBUG(PSTR("!SGN:PRE:XMT,TO=%" PRIu8 " FAIL\n"),
|
||||
sender); // Failed to transmit signing presentation!
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%d\n"), sender);
|
||||
SIGN_DEBUG(PSTR("SGN:PRE:XMT,TO=%" PRIu8 "\n"), sender);
|
||||
}
|
||||
#else // not MY_GATEWAY_FEATURE
|
||||
// If we act as a node and do not have the signing feature then we just silently drop any signing
|
||||
@@ -519,7 +529,7 @@ static bool signerInternalProcessNonceRequest(MyMessage &msg)
|
||||
#if defined(MY_SIGNING_FEATURE)
|
||||
#if defined(MY_NODE_LOCK_FEATURE)
|
||||
nof_nonce_requests++;
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:LEFT=%d\n"),
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:LEFT=%" PRIu8 "\n"),
|
||||
MY_NODE_LOCK_COUNTER_MAX-nof_nonce_requests); // Nonce requests left until lockdown
|
||||
if (nof_nonce_requests >= MY_NODE_LOCK_COUNTER_MAX) {
|
||||
_nodeLock("TMNR"); // Too many nonces requested
|
||||
@@ -527,9 +537,9 @@ static bool signerInternalProcessNonceRequest(MyMessage &msg)
|
||||
#endif // MY_NODE_LOCK_FEATURE
|
||||
if (signerBackendGetNonce(msg)) {
|
||||
if (!_sendRoute(build(msg, msg.sender, NODE_SENSOR_ID, C_INTERNAL, I_NONCE_RESPONSE))) {
|
||||
SIGN_DEBUG(PSTR("!SGN:NCE:XMT,TO=%d FAIL\n"), msg.sender); // Failed to transmit nonce!
|
||||
SIGN_DEBUG(PSTR("!SGN:NCE:XMT,TO=%" PRIu8 " FAIL\n"), msg.sender); // Failed to transmit nonce!
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:XMT,TO=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:XMT,TO=%" PRIu8 "\n"), msg.sender);
|
||||
}
|
||||
} else {
|
||||
SIGN_DEBUG(PSTR("!SGN:NCE:GEN\n")); // Failed to generate nonce!
|
||||
@@ -547,9 +557,9 @@ static bool signerInternalProcessNonceResponse(MyMessage &msg)
|
||||
{
|
||||
#if defined(MY_SIGNING_FEATURE)
|
||||
// Proceed with signing if nonce has been received
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:FROM=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:FROM=%" PRIu8 "\n"), msg.sender);
|
||||
if (msg.sender != _msgSign.destination) {
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:%d!=%d (DROPPED)\n"), _msgSign.destination, msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:NCE:%" PRIu8 "!=%" PRIu8 " (DROPPED)\n"), _msgSign.destination, msg.sender);
|
||||
} else {
|
||||
signerBackendPutNonce(msg);
|
||||
if (signerBackendSignMsg(_msgSign)) {
|
||||
|
||||
@@ -182,7 +182,8 @@ bool signerAtsha204SignMsg(MyMessage &msg)
|
||||
{
|
||||
// If we cannot fit any signature in the message, refuse to sign it
|
||||
if (mGetLength(msg) > MAX_PAYLOAD-2) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:SIG,SIZE,%d>%d\n"), mGetLength(msg), MAX_PAYLOAD-2); //Message too large
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:SIG,SIZE,%" PRIu8 ">%" PRIu8 "\n"), mGetLength(msg),
|
||||
MAX_PAYLOAD-2); //Message too large
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,7 +199,7 @@ bool signerAtsha204SignMsg(MyMessage &msg)
|
||||
memcpy(&_signing_signing_nonce[33], _signing_node_serial_info, 9);
|
||||
// We can 'void' sha256 because the hash is already put in the correct place
|
||||
(void)signerSha256(_signing_signing_nonce, 32+1+9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,ID=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,ID=%" PRIu8 "\n"), msg.sender);
|
||||
#ifdef MY_DEBUG_VERBOSE_SIGNING
|
||||
buf2str(_signing_node_serial_info, 9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,SERIAL=%s\n"), printStr);
|
||||
@@ -231,7 +232,7 @@ bool signerAtsha204VerifyMsg(MyMessage &msg)
|
||||
_signing_verification_ongoing = false;
|
||||
|
||||
if (msg.data[mGetLength(msg)] != SIGNING_IDENTIFIER) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER,IDENT=%d\n"), msg.data[mGetLength(msg)]);
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER,IDENT=%" PRIu8 "\n"), msg.data[mGetLength(msg)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -248,7 +249,7 @@ bool signerAtsha204VerifyMsg(MyMessage &msg)
|
||||
memcpy(&_signing_verifying_nonce[33], _signing_whitelist[j].serial, 9);
|
||||
// We can 'void' sha256 because the hash is already put in the correct place
|
||||
(void)signerSha256(_signing_verifying_nonce, 32+1+9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,ID=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,ID=%" PRIu8 "\n"), msg.sender);
|
||||
#ifdef MY_DEBUG_VERBOSE_SIGNING
|
||||
buf2str(_signing_whitelist[j].serial, 9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,SERIAL=%s\n"), printStr);
|
||||
@@ -257,7 +258,7 @@ bool signerAtsha204VerifyMsg(MyMessage &msg)
|
||||
}
|
||||
}
|
||||
if (j == NUM_OF(_signing_whitelist)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER WHI,ID=%d MISSING\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER WHI,ID=%" PRIu8 " MISSING\n"), msg.sender);
|
||||
// Put device back to sleep
|
||||
atsha204_sleep();
|
||||
return false;
|
||||
|
||||
@@ -199,7 +199,8 @@ bool signerAtsha204SoftSignMsg(MyMessage &msg)
|
||||
{
|
||||
// If we cannot fit any signature in the message, refuse to sign it
|
||||
if (mGetLength(msg) > MAX_PAYLOAD-2) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:SIG,SIZE,%d>%d\n"), mGetLength(msg), MAX_PAYLOAD-2); //Message too large
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:SIG,SIZE,%" PRIu8 ">%" PRIu8 "\n"), mGetLength(msg),
|
||||
MAX_PAYLOAD-2); //Message too large
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ bool signerAtsha204SoftSignMsg(MyMessage &msg)
|
||||
_signing_signing_nonce[32] = msg.sender;
|
||||
memcpy(&_signing_signing_nonce[33], _signing_node_serial_info, 9);
|
||||
memcpy(_signing_hmac, signerSha256(_signing_signing_nonce, 32+1+9), 32);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,ID=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,ID=%" PRIu8 "\n"), msg.sender);
|
||||
#ifdef MY_DEBUG_VERBOSE_SIGNING
|
||||
buf2str(_signing_node_serial_info, 9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:SIG WHI,SERIAL=%s\n"), printStr);
|
||||
@@ -244,7 +245,7 @@ bool signerAtsha204SoftVerifyMsg(MyMessage &msg)
|
||||
_signing_verification_ongoing = false;
|
||||
|
||||
if (msg.data[mGetLength(msg)] != SIGNING_IDENTIFIER) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER,IDENT=%d\n"), msg.data[mGetLength(msg)]);
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER,IDENT=%" PRIu8 "\n"), msg.data[mGetLength(msg)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -260,7 +261,7 @@ bool signerAtsha204SoftVerifyMsg(MyMessage &msg)
|
||||
_signing_verifying_nonce[32] = msg.sender;
|
||||
memcpy(&_signing_verifying_nonce[33], _signing_whitelist[j].serial, 9);
|
||||
memcpy(_signing_hmac, signerSha256(_signing_verifying_nonce, 32+1+9), 32);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,ID=%d\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,ID=%" PRIu8 "\n"), msg.sender);
|
||||
#ifdef MY_DEBUG_VERBOSE_SIGNING
|
||||
buf2str(_signing_whitelist[j].serial, 9);
|
||||
SIGN_DEBUG(PSTR("SGN:BND:VER WHI,SERIAL=%s\n"), printStr);
|
||||
@@ -269,7 +270,7 @@ bool signerAtsha204SoftVerifyMsg(MyMessage &msg)
|
||||
}
|
||||
}
|
||||
if (j == NUM_OF(_signing_whitelist)) {
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER WHI,ID=%d MISSING\n"), msg.sender);
|
||||
SIGN_DEBUG(PSTR("!SGN:BND:VER WHI,ID=%" PRIu8 " MISSING\n"), msg.sender);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
+27
-22
@@ -121,7 +121,7 @@ void stInitUpdate(void)
|
||||
transportSwitchSM(stReady);
|
||||
#else
|
||||
if (MY_NODE_ID != AUTO) {
|
||||
TRANSPORT_DEBUG(PSTR("TSM:INIT:STATID=%d\n"),(uint8_t)MY_NODE_ID);
|
||||
TRANSPORT_DEBUG(PSTR("TSM:INIT:STATID=%" PRIu8 "\n"),(uint8_t)MY_NODE_ID);
|
||||
// Set static ID
|
||||
_transportConfig.nodeId = (uint8_t)MY_NODE_ID;
|
||||
// Save static ID to eeprom (for bootloader)
|
||||
@@ -147,7 +147,7 @@ void stParentTransition(void)
|
||||
_transportSM.uplinkOk = false;
|
||||
_transportSM.preferredParentFound = false;
|
||||
#if defined(MY_PARENT_NODE_IS_STATIC) || defined(MY_PASSIVE_NODE)
|
||||
TRANSPORT_DEBUG(PSTR("TSM:FPAR:STATP=%d\n"), (uint8_t)MY_PARENT_NODE_ID); // static parent
|
||||
TRANSPORT_DEBUG(PSTR("TSM:FPAR:STATP=%" PRIu8 "\n"), (uint8_t)MY_PARENT_NODE_ID); // static parent
|
||||
_transportSM.findingParentNode = false;
|
||||
_transportConfig.distanceGW = 1u; // assumption, CHKUPL:GWDC will update this variable
|
||||
_transportConfig.parentNodeId = (uint8_t)MY_PARENT_NODE_ID;
|
||||
@@ -262,7 +262,7 @@ void stUplinkUpdate(void)
|
||||
// uplink ok, i.e. GW replied
|
||||
TRANSPORT_DEBUG(PSTR("TSM:UPL:OK\n")); // uplink ok
|
||||
if (_transportSM.pingResponse != _transportConfig.distanceGW) {
|
||||
TRANSPORT_DEBUG(PSTR("TSM:UPL:DGWC,O=%d,N=%d\n"), _transportConfig.distanceGW,
|
||||
TRANSPORT_DEBUG(PSTR("TSM:UPL:DGWC,O=%" PRIu8 ",N=%" PRIu8 "\n"), _transportConfig.distanceGW,
|
||||
_transportSM.pingResponse); // distance to GW changed
|
||||
_transportConfig.distanceGW = _transportSM.pingResponse;
|
||||
}
|
||||
@@ -289,7 +289,8 @@ void stUplinkUpdate(void)
|
||||
void stReadyTransition(void)
|
||||
{
|
||||
// transport is ready and fully operational
|
||||
TRANSPORT_DEBUG(PSTR("TSM:READY:ID=%d,PAR=%d,DIS=%d\n"), _transportConfig.nodeId,
|
||||
TRANSPORT_DEBUG(PSTR("TSM:READY:ID=%" PRIu8 ",PAR=%" PRIu8 ",DIS=%" PRIu8 "\n"),
|
||||
_transportConfig.nodeId,
|
||||
_transportConfig.parentNodeId, _transportConfig.distanceGW);
|
||||
_transportSM.uplinkOk = true;
|
||||
_transportSM.failureCounter = 0u; // reset failure counter
|
||||
@@ -338,7 +339,7 @@ void stFailureTransition(void)
|
||||
if (_transportSM.failureCounter < MY_TRANSPORT_MAX_TSM_FAILURES) {
|
||||
_transportSM.failureCounter++; // increment consecutive TSM failure counter
|
||||
}
|
||||
TRANSPORT_DEBUG(PSTR("TSM:FAIL:CNT=%d\n"),_transportSM.failureCounter);
|
||||
TRANSPORT_DEBUG(PSTR("TSM:FAIL:CNT=%" PRIu8 "\n"),_transportSM.failureCounter);
|
||||
_transportSM.uplinkOk = false; // uplink nok
|
||||
_transportSM.transportActive = false; // transport inactive
|
||||
setIndication(INDICATION_ERR_INIT_TRANSPORT);
|
||||
@@ -445,7 +446,7 @@ void transportReInitialise(void)
|
||||
bool transportWaitUntilReady(const uint32_t waitingMS)
|
||||
{
|
||||
// check if transport ready
|
||||
TRANSPORT_DEBUG(PSTR("TSF:WUR:MS=%lu\n"), waitingMS); // timeout
|
||||
TRANSPORT_DEBUG(PSTR("TSF:WUR:MS=%" PRIu32 "\n"), waitingMS); // timeout
|
||||
uint32_t enterMS = hwMillis();
|
||||
bool result = false;
|
||||
while (!result && ( hwMillis() - enterMS < waitingMS || !waitingMS)) {
|
||||
@@ -481,7 +482,7 @@ bool transportCheckUplink(const bool force)
|
||||
TRANSPORT_DEBUG(PSTR("TSF:CKU:OK\n"));
|
||||
// did distance to GW change upstream, eg. re-routing of uplink nodes
|
||||
if (hopsCount != _transportConfig.distanceGW) {
|
||||
TRANSPORT_DEBUG(PSTR("TSF:CKU:DGWC,O=%d,N=%d\n"), _transportConfig.distanceGW,
|
||||
TRANSPORT_DEBUG(PSTR("TSF:CKU:DGWC,O=%" PRIu8 ",N=%" PRIu8 "\n"), _transportConfig.distanceGW,
|
||||
hopsCount); // distance to GW changed
|
||||
_transportConfig.distanceGW = hopsCount;
|
||||
}
|
||||
@@ -500,10 +501,10 @@ bool transportAssignNodeID(const uint8_t newNodeId)
|
||||
transportSetAddress(newNodeId);
|
||||
// Write ID to EEPROM
|
||||
hwWriteConfig(EEPROM_NODE_ID_ADDRESS, newNodeId);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:SID:OK,ID=%d\n"),newNodeId); // Node ID assigned
|
||||
TRANSPORT_DEBUG(PSTR("TSF:SID:OK,ID=%" PRIu8 "\n"),newNodeId); // Node ID assigned
|
||||
return true;
|
||||
} else {
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:SID:FAIL,ID=%d\n"),newNodeId); // ID is invalid, cannot assign ID
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:SID:FAIL,ID=%" PRIu8 "\n"),newNodeId); // ID is invalid, cannot assign ID
|
||||
setIndication(INDICATION_ERR_NET_FULL);
|
||||
_transportConfig.nodeId = AUTO;
|
||||
return false;
|
||||
@@ -530,7 +531,7 @@ bool transportRouteMessage(MyMessage &message)
|
||||
// destination not GW & not BC, get route
|
||||
route = transportGetRoute(destination);
|
||||
if (route == AUTO) {
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:RTE:%d UNKNOWN\n"), destination); // route unknown
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:RTE:%" PRIu8 " UNKNOWN\n"), destination); // route unknown
|
||||
#if !defined(MY_GATEWAY_FEATURE)
|
||||
if (message.last != _transportConfig.parentNodeId) {
|
||||
// message not from parent, i.e. child node - route it to parent
|
||||
@@ -608,7 +609,7 @@ bool transportWait(const uint32_t waitingMS, const uint8_t cmd, const uint8_t ms
|
||||
uint8_t transportPingNode(const uint8_t targetId)
|
||||
{
|
||||
if(!_transportSM.pingActive) {
|
||||
TRANSPORT_DEBUG(PSTR("TSF:PNG:SEND,TO=%d\n"), targetId);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:PNG:SEND,TO=%" PRIu8 "\n"), targetId);
|
||||
if(targetId == _transportConfig.nodeId) {
|
||||
// pinging self
|
||||
_transportSM.pingResponse = 0u;
|
||||
@@ -656,7 +657,8 @@ void transportProcessMessage(void)
|
||||
const uint8_t last = _msg.last;
|
||||
const uint8_t destination = _msg.destination;
|
||||
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:READ,%d-%d-%d,s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d:%s\n"),
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:READ,%" PRIu8 "-%" PRIu8 "-%" PRIu8 ",s=%" PRIu8 ",c=%" PRIu8 ",t=%"
|
||||
PRIu8 ",pt=%" PRIu8 ",l=%" PRIu8 ",sg=%" PRIu8 ":%s\n"),
|
||||
sender, last, destination, _msg.sensor, command, type, mGetPayloadType(_msg), msgLength,
|
||||
mGetSigned(_msg), ((command == C_INTERNAL &&
|
||||
type == I_NONCE_RESPONSE) ? "<NONCE>" : _msg.getString(_convBuf)));
|
||||
@@ -664,7 +666,7 @@ void transportProcessMessage(void)
|
||||
// Reject payloads with incorrect length
|
||||
if (payloadLength != expectedMessageLength) {
|
||||
setIndication(INDICATION_ERR_LENGTH);
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:MSG:LEN,%d!=%d\n"), payloadLength,
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:MSG:LEN,%" PRIu8 "!=%" PRIu8 "\n"), payloadLength,
|
||||
expectedMessageLength); // invalid payload length
|
||||
return;
|
||||
}
|
||||
@@ -672,7 +674,7 @@ void transportProcessMessage(void)
|
||||
// Reject messages with incorrect protocol version
|
||||
if (mGetVersion(_msg) != PROTOCOL_VERSION) {
|
||||
setIndication(INDICATION_ERR_VERSION);
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:MSG:PVER,%d=%d\n"), mGetVersion(_msg),
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:MSG:PVER,%" PRIu8 "!=%" PRIu8 "\n"), mGetVersion(_msg),
|
||||
PROTOCOL_VERSION); // protocol version mismatch
|
||||
return;
|
||||
}
|
||||
@@ -757,7 +759,7 @@ void transportProcessMessage(void)
|
||||
}
|
||||
_transportConfig.distanceGW = distance;
|
||||
_transportConfig.parentNodeId = sender;
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:FPAR OK,ID=%d,D=%d\n"), _transportConfig.parentNodeId,
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:FPAR OK,ID=%" PRIu8 ",D=%" PRIu8 "\n"), _transportConfig.parentNodeId,
|
||||
_transportConfig.distanceGW);
|
||||
}
|
||||
}
|
||||
@@ -770,7 +772,8 @@ void transportProcessMessage(void)
|
||||
#endif // !defined(MY_GATEWAY_FEATURE)
|
||||
// general
|
||||
if (type == I_PING) {
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:PINGED,ID=%d,HP=%d\n"), sender, _msg.getByte()); // node pinged
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:PINGED,ID=%" PRIu8 ",HP=%" PRIu8 "\n"), sender,
|
||||
_msg.getByte()); // node pinged
|
||||
#if defined(MY_GATEWAY_FEATURE) && (F_CPU>16000000)
|
||||
// delay for fast GW and slow nodes
|
||||
delay(5);
|
||||
@@ -783,7 +786,8 @@ void transportProcessMessage(void)
|
||||
if (_transportSM.pingActive) {
|
||||
_transportSM.pingActive = false;
|
||||
_transportSM.pingResponse = _msg.getByte();
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:PONG RECV,HP=%d\n"), _transportSM.pingResponse); // pong received
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:PONG RECV,HP=%" PRIu8 "\n"),
|
||||
_transportSM.pingResponse); // pong received
|
||||
} else {
|
||||
TRANSPORT_DEBUG(PSTR("!TSF:MSG:PONG RECV,INACTIVE\n")); // pong received, but !pingActive
|
||||
}
|
||||
@@ -843,7 +847,7 @@ void transportProcessMessage(void)
|
||||
if (type == I_FIND_PARENT_REQUEST) {
|
||||
#if defined(MY_REPEATER_FEATURE)
|
||||
if (sender != _transportConfig.parentNodeId) { // no circular reference
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:FPAR REQ,ID=%d\n"), sender); // FPAR: find parent request
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:FPAR REQ,ID=%" PRIu8 "\n"), sender); // FPAR: find parent request
|
||||
// check if uplink functional - node can only be parent node if link to GW functional
|
||||
// this also prevents circular references in case GW ooo
|
||||
if (transportCheckUplink()) {
|
||||
@@ -912,7 +916,7 @@ void transportProcessMessage(void)
|
||||
if (type == I_PING || type == I_PONG) {
|
||||
uint8_t hopsCnt = _msg.getByte();
|
||||
if (hopsCnt != MAX_HOPS) {
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%d\n"), hopsCnt);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:MSG:REL PxNG,HP=%" PRIu8 "\n"), hopsCnt);
|
||||
hopsCnt++;
|
||||
_msg.set(hopsCnt);
|
||||
}
|
||||
@@ -986,7 +990,8 @@ bool transportSendWrite(const uint8_t to, MyMessage &message)
|
||||
// broadcasting (workaround counterfeits)
|
||||
result |= (to == BROADCAST_ADDRESS);
|
||||
|
||||
TRANSPORT_DEBUG(PSTR("%sTSF:MSG:SEND,%d-%d-%d-%d,s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d,ft=%d,st=%s:%s\n"),
|
||||
TRANSPORT_DEBUG(PSTR("%sTSF:MSG:SEND,%" PRIu8 "-%" PRIu8 "-%" PRIu8 "-%" PRIu8 ",s=%" PRIu8 ",c=%"
|
||||
PRIu8 ",t=%" PRIu8 ",pt=%" PRIu8 ",l=%" PRIu8 ",sg=%" PRIu8 ",ft=%" PRIu8 ",st=%s:%s\n"),
|
||||
(_transportConfig.passiveMode ? "?" : result ? "" : "!"), message.sender, message.last, to,
|
||||
message.destination,
|
||||
message.sensor,
|
||||
@@ -1070,7 +1075,7 @@ void transportReportRoutingTable(void)
|
||||
for (uint16_t cnt = 0; cnt < SIZE_ROUTES; cnt++) {
|
||||
const uint8_t route = transportGetRoute(cnt);
|
||||
if (route != BROADCAST_ADDRESS) {
|
||||
TRANSPORT_DEBUG(PSTR("TSF:RRT:ROUTE N=%d,R=%d\n"), cnt, route);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:RRT:ROUTE N=%" PRIu8 ",R=%" PRIu8 "\n"), cnt, route);
|
||||
uint8_t outBuf[2] = { (uint8_t)cnt,route };
|
||||
(void)_sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_DEBUG).set(outBuf,
|
||||
2));
|
||||
@@ -1158,6 +1163,6 @@ int16_t transportSignalReport(const char command)
|
||||
break;
|
||||
}
|
||||
const uint16_t result = transportGetSignalReport(reportCommand);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:SIR:CMD=%d,VAL=%d\n"), reportCommand, result);
|
||||
TRANSPORT_DEBUG(PSTR("TSF:SIR:CMD=%" PRIu8 ",VAL=%" PRIu16 "\n"), reportCommand, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,8 @@ static uint8_t NRF5_ESB_readMessage(void *data)
|
||||
|
||||
// Debug message
|
||||
#ifdef MY_DEBUG_VERBOSE_NRF5_ESB
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:RX:LEN=%d,NOACK=%d,PID=%d,RSSI=%d,RX=%d\n"),
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:RX:LEN=%" PRIu8 ",NOACK=%" PRIu8 ",PID=%" PRIu8 ",RSSI=%" PRIi16 ",RX=%"
|
||||
PRIu32 "\n"),
|
||||
buffer->len, buffer->noack, buffer->pid, rssi_rx, buffer->rxmatch);
|
||||
#endif
|
||||
|
||||
@@ -380,7 +381,8 @@ void NRF5_ESB_endtx()
|
||||
|
||||
static bool NRF5_ESB_sendMessage(uint8_t recipient, const void *buf, uint8_t len, const bool noACK)
|
||||
{
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:TO=%d,LEN=%d,PID=%d,NOACK=%d\n"), recipient, len, tx_buffer.pid,
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:TO=%" PRIu8 ",LEN=%" PRIu8 ",PID=%" PRIu8 ",NOACK=%" PRIu8 "\n"),
|
||||
recipient, len, tx_buffer.pid,
|
||||
tx_buffer.noack); // send message
|
||||
// Check if radio is initialized
|
||||
if (NRF_RADIO->POWER == 0) {
|
||||
@@ -450,9 +452,9 @@ static bool NRF5_ESB_sendMessage(uint8_t recipient, const void *buf, uint8_t len
|
||||
// Arbitrary definition: ARC 0 == -29, ARC 15 = -104
|
||||
rssi_tx = (-29 - (8 * (tx_retries_start - tx_retries)));
|
||||
}
|
||||
|
||||
#ifdef MY_DEBUG_VERBOSE_NRF5_ESB
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:END=%d,ACK=%d,RTRY=%d,RSSI=%d,WAKE=%d\n"),
|
||||
NRF5_RADIO_DEBUG(PSTR("NRF5:SND:END=%" PRIu8 ",ACK=%" PRIu8 ",RTRY=%" PRIi8 ",RSSI=%" PRIi16
|
||||
",WAKE=%" PRIu32 "\n"),
|
||||
events_end_tx, ack_received, tx_retries_start - tx_retries, rssi_tx, wakeups);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,14 +120,14 @@ LOCAL uint8_t RF24_spiByteTransfer(const uint8_t cmd)
|
||||
LOCAL uint8_t RF24_RAW_readByteRegister(const uint8_t cmd)
|
||||
{
|
||||
const uint8_t value = RF24_spiMultiByteTransfer(cmd, NULL, 1, true);
|
||||
RF24_DEBUG(PSTR("RF24:RBR:REG=%d,VAL=%d\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
RF24_DEBUG(PSTR("RF24:RBR:REG=%" PRIu8 ",VAL=%" PRIu8 "\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
LOCAL uint8_t RF24_RAW_writeByteRegister(const uint8_t cmd, uint8_t value)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:WBR:REG=%d,VAL=%d\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return RF24_spiMultiByteTransfer( cmd , &value, 1, false);
|
||||
RF24_DEBUG(PSTR("RF24:WBR:REG=%" PRIu8 ",VAL=%" PRIu8 "\n"), cmd & RF24_REGISTER_MASK, value);
|
||||
return RF24_spiMultiByteTransfer( cmd, &value, 1, false);
|
||||
}
|
||||
|
||||
LOCAL void RF24_flushRX(void)
|
||||
@@ -224,7 +224,7 @@ LOCAL void RF24_enableFeatures(void)
|
||||
|
||||
LOCAL void RF24_openWritingPipe(const uint8_t recipient)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:OWP:RCPT=%d\n"), recipient); // open writing pipe
|
||||
RF24_DEBUG(PSTR("RF24:OWP:RCPT=%" PRIu8 "\n"), recipient); // open writing pipe
|
||||
// only write LSB of RX0 and TX pipe
|
||||
RF24_setPipeLSB(RF24_REG_RX_ADDR_P0, recipient);
|
||||
RF24_setPipeLSB(RF24_REG_TX_ADDR, recipient);
|
||||
@@ -289,7 +289,7 @@ LOCAL bool RF24_sendMessage(const uint8_t recipient, const void* buf, const uint
|
||||
uint8_t RF24_status;
|
||||
RF24_stopListening();
|
||||
RF24_openWritingPipe( recipient );
|
||||
RF24_DEBUG(PSTR("RF24:TXM:TO=%d,LEN=%d\n"),recipient,len); // send message
|
||||
RF24_DEBUG(PSTR("RF24:TXM:TO=%" PRIu8 ",LEN=%" PRIu8 "\n"),recipient,len); // send message
|
||||
// flush TX FIFO
|
||||
RF24_flushTX();
|
||||
// this command is affected in clones (e.g. Si24R1): flipped NoACK bit when using W_TX_PAYLOAD_NO_ACK / W_TX_PAYLOAD
|
||||
@@ -340,7 +340,7 @@ LOCAL bool RF24_isDataAvailable(void)
|
||||
LOCAL uint8_t RF24_readMessage(void* buf)
|
||||
{
|
||||
const uint8_t len = RF24_getDynamicPayloadSize();
|
||||
RF24_DEBUG(PSTR("RF24:RXM:LEN=%d\n"), len); // read message
|
||||
RF24_DEBUG(PSTR("RF24:RXM:LEN=%" PRIu8 "\n"), len); // read message
|
||||
RF24_spiMultiByteTransfer(RF24_CMD_READ_RX_PAYLOAD,(uint8_t*)buf,len,true);
|
||||
// clear RX interrupt
|
||||
RF24_setStatus(_BV(RF24_RX_DR));
|
||||
@@ -385,7 +385,7 @@ LOCAL bool RF24_setTxPowerLevel(const uint8_t newPowerLevel)
|
||||
{
|
||||
const uint8_t registerContent = RF24_readByteRegister(RF24_REG_RF_SETUP);
|
||||
RF24_writeByteRegister(RF24_REG_RF_SETUP, (registerContent & 0xF9) | ((newPowerLevel & 3) << 1));
|
||||
RF24_DEBUG(PSTR("RF24:STX:LEVEL=%d\n"), newPowerLevel);
|
||||
RF24_DEBUG(PSTR("RF24:STX:LEVEL=%" PRIu8 "\n"), newPowerLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ LOCAL void RF24_registerReceiveCallback(RF24_receiveCallbackType cb)
|
||||
LOCAL bool RF24_initialize(void)
|
||||
{
|
||||
RF24_DEBUG(PSTR("RF24:INIT\n"));
|
||||
RF24_DEBUG(PSTR("RF24:INIT:PIN,CE=%d,CS=%d\n"), MY_RF24_CE_PIN, MY_RF24_CS_PIN);
|
||||
RF24_DEBUG(PSTR("RF24:INIT:PIN,CE=%" PRIu8 ",CS=%" PRIu8 "\n"), MY_RF24_CE_PIN, MY_RF24_CS_PIN);
|
||||
// Initialize pins & HW
|
||||
#if defined(MY_RF24_POWER_PIN)
|
||||
hwPinMode(MY_RF24_POWER_PIN, OUTPUT);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -166,14 +166,14 @@ LOCAL uint8_t RFM69_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, uint8_
|
||||
LOCAL uint8_t RFM69_RAW_readByteRegister(const uint8_t address)
|
||||
{
|
||||
const uint8_t value = RFM69_spiMultiByteTransfer(address, NULL, 1, true);
|
||||
//RFM69_DEBUG(PSTR("RFM69:read register, reg=0x%02x, value=%d\n"), address, value);
|
||||
//RFM69_DEBUG(PSTR("RFM69:read register, reg=0x%02" PRIx8 ", value=%" PRIu8 "\n"), address, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
// low level register access
|
||||
LOCAL uint8_t RFM69_RAW_writeByteRegister(const uint8_t address, uint8_t value)
|
||||
{
|
||||
//RFM69_DEBUG(PSTR("RFM69:write register, reg=0x%02x, value=%d\n"), address & 0x7F, value);
|
||||
//RFM69_DEBUG(PSTR("RFM69:write register, reg=0x%02" PRIx8 ", value=%" PRIu8 "\n"), address & 0x7F, value);
|
||||
return RFM69_spiMultiByteTransfer(address, &value, 1, false);
|
||||
}
|
||||
|
||||
@@ -200,10 +200,12 @@ LOCAL bool RFM69_initialise(const uint32_t frequencyHz)
|
||||
hwDigitalWrite(MY_RFM69_RST_PIN, LOW);
|
||||
// wait until chip ready
|
||||
delay(5);
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%d,IQP=%d,IQN=%d,RST=%d\n"), MY_RFM69_CS_PIN,MY_RFM69_IRQ_PIN,
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 ",RST=%" PRIu8 "\n"),
|
||||
MY_RFM69_CS_PIN,MY_RFM69_IRQ_PIN,
|
||||
MY_RFM69_IRQ_NUM,MY_RFM69_RST_PIN);
|
||||
#else
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%d,IQP=%d,IQN=%d\n"),MY_RFM69_CS_PIN, MY_RFM69_IRQ_PIN,
|
||||
RFM69_DEBUG(PSTR("RFM69:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 "\n"),MY_RFM69_CS_PIN,
|
||||
MY_RFM69_IRQ_PIN,
|
||||
MY_RFM69_IRQ_NUM);
|
||||
#endif
|
||||
|
||||
@@ -479,7 +481,7 @@ LOCAL bool RFM69_setTxPowerLevel(rfm69_powerlevel_t newPowerLevel)
|
||||
}
|
||||
#endif
|
||||
RFM69_writeReg(RFM69_REG_PALEVEL, palevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:PTX:LEVEL=%d dBm\n"),newPowerLevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:PTX:LEVEL=%" PRIi8 " dBm\n"),newPowerLevel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -622,7 +624,8 @@ LOCAL bool RFM69_standBy(void)
|
||||
LOCAL void RFM69_sendACK(const uint8_t recipient, const rfm69_sequenceNumber_t sequenceNumber,
|
||||
const rfm69_RSSI_t RSSI)
|
||||
{
|
||||
RFM69_DEBUG(PSTR("RFM69:SAC:SEND ACK,TO=%d,RSSI=%d\n"),recipient, RFM69_internalToRSSI(RSSI));
|
||||
RFM69_DEBUG(PSTR("RFM69:SAC:SEND ACK,TO=%" PRIu8 ",RSSI=%" PRIi16 "\n"),recipient,
|
||||
RFM69_internalToRSSI(RSSI));
|
||||
rfm69_ack_t ACK;
|
||||
ACK.sequenceNumber = sequenceNumber;
|
||||
ACK.RSSI = RSSI;
|
||||
@@ -649,7 +652,8 @@ LOCAL bool RFM69_executeATC(const rfm69_RSSI_t currentRSSI, const rfm69_RSSI_t t
|
||||
// nothing to adjust
|
||||
return false;
|
||||
}
|
||||
RFM69_DEBUG(PSTR("RFM69:ATC:ADJ TXL,cR=%d,tR=%d,TXL=%d\n"), RFM69_internalToRSSI(currentRSSI),
|
||||
RFM69_DEBUG(PSTR("RFM69:ATC:ADJ TXL,cR=%" PRIi16 ",tR=%" PRIi16 ",TXL=%" PRIi16 "\n"),
|
||||
RFM69_internalToRSSI(currentRSSI),
|
||||
RFM69_internalToRSSI(targetRSSI), newPowerLevel);
|
||||
|
||||
return RFM69_setTxPowerLevel(newPowerLevel);
|
||||
@@ -666,7 +670,7 @@ LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTimeMS)
|
||||
{
|
||||
for (uint8_t retry = 0; retry <= retries; retry++) {
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:SEND,TO=%d,RETRY=%d\n"), recipient, retry);
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:SEND,TO=%" PRIu8 ",RETRY=%" PRIu8 "\n"), recipient, retry);
|
||||
rfm69_controlFlags_t flags = 0x00; // reset all flags
|
||||
RFM69_setACKRequested(flags, (recipient != RFM69_BROADCAST_ADDRESS));
|
||||
RFM69_setACKRSSIReport(flags, RFM69.ATCenabled);
|
||||
@@ -688,7 +692,8 @@ LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
// packet read, back to RX
|
||||
RFM69_setRadioMode(RFM69_RADIO_MODE_RX);
|
||||
if (sender == recipient && ACKsequenceNumber == RFM69.txSequenceNumber) {
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:ACK,FROM=%d,SEQ=%d,RSSI=%d\n"),sender,ACKsequenceNumber,
|
||||
RFM69_DEBUG(PSTR("RFM69:SWR:ACK,FROM=%" PRIu8 ",SEQ=%" PRIu8 ",RSSI=%" PRIi16 "\n"),sender,
|
||||
ACKsequenceNumber,
|
||||
RFM69_internalToRSSI(RSSI));
|
||||
|
||||
// ATC
|
||||
@@ -739,7 +744,7 @@ LOCAL bool RFM69_setTxPowerPercent(uint8_t newPowerPercent)
|
||||
const rfm69_powerlevel_t newPowerLevel = static_cast<rfm69_powerlevel_t>
|
||||
(RFM69_MIN_POWER_LEVEL_DBM + (RFM69_MAX_POWER_LEVEL_DBM
|
||||
- RFM69_MIN_POWER_LEVEL_DBM) * (newPowerPercent / 100.0f));
|
||||
RFM69_DEBUG(PSTR("RFM69:SPP:PCT=%d,TX LEVEL=%d\n"), newPowerPercent,newPowerLevel);
|
||||
RFM69_DEBUG(PSTR("RFM69:SPP:PCT=%" PRIu8 ",TX LEVEL=%" PRIi8 "\n"), newPowerPercent,newPowerLevel);
|
||||
return RFM69_setTxPowerLevel(newPowerLevel);
|
||||
}
|
||||
|
||||
@@ -1465,4 +1470,4 @@ LOCAL void RFM69_readAllRegs(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+14
-8
@@ -144,10 +144,12 @@ LOCAL bool RFM95_initialise(const uint32_t frequencyHz)
|
||||
hwDigitalWrite(MY_RFM95_RST_PIN, LOW);
|
||||
// wait until chip ready
|
||||
delay(5);
|
||||
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%d,IQP=%d,IQN=%d,RST=%d\n"), MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
|
||||
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 ",RST=%" PRIu8 "\n"),
|
||||
MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
|
||||
MY_RFM95_IRQ_NUM,MY_RFM95_RST_PIN);
|
||||
#else
|
||||
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%d,IQP=%d,IQN=%d\n"), MY_RFM95_CS_PIN, MY_RFM95_IRQ_PIN,
|
||||
RFM95_DEBUG(PSTR("RFM95:INIT:PIN,CS=%" PRIu8 ",IQP=%" PRIu8 ",IQN=%" PRIu8 "\n"), MY_RFM95_CS_PIN,
|
||||
MY_RFM95_IRQ_PIN,
|
||||
MY_RFM95_IRQ_NUM);
|
||||
#endif
|
||||
|
||||
@@ -357,7 +359,7 @@ LOCAL bool RFM95_setTxPowerLevel(rfm95_powerLevel_t newPowerLevel)
|
||||
val = newPowerLevel - 5;
|
||||
}
|
||||
RFM95_writeReg(RFM95_REG_09_PA_CONFIG, RFM95_PA_SELECT | val);
|
||||
RFM95_DEBUG(PSTR("RFM95:PTX:LEVEL=%d\n"), newPowerLevel);
|
||||
RFM95_DEBUG(PSTR("RFM95:PTX:LEVEL=%" PRIi8 "\n"), newPowerLevel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -460,7 +462,8 @@ LOCAL bool RFM95_standBy(void)
|
||||
LOCAL void RFM95_sendACK(const uint8_t recipient, const rfm95_sequenceNumber_t sequenceNumber,
|
||||
const rfm95_RSSI_t RSSI, const rfm95_SNR_t SNR)
|
||||
{
|
||||
RFM95_DEBUG(PSTR("RFM95:SAC:SEND ACK,TO=%d,SEQ=%d,RSSI=%d,SNR=%d\n"),recipient,sequenceNumber,
|
||||
RFM95_DEBUG(PSTR("RFM95:SAC:SEND ACK,TO=%" PRIu8 ",SEQ=%" PRIu16 ",RSSI=%" PRIi16 ",SNR=%" PRIi8
|
||||
"\n"),recipient,sequenceNumber,
|
||||
RFM95_internalToRSSI(RSSI),RFM95_internalToSNR(SNR));
|
||||
rfm95_ack_t ACK;
|
||||
ACK.sequenceNumber = sequenceNumber;
|
||||
@@ -489,7 +492,8 @@ LOCAL bool RFM95_executeATC(const rfm95_RSSI_t currentRSSI, const rfm95_RSSI_t t
|
||||
// nothing to adjust
|
||||
return false;
|
||||
}
|
||||
RFM95_DEBUG(PSTR("RFM95:ATC:ADJ TXL,cR=%d,tR=%d,TXL=%d\n"), RFM95_internalToRSSI(currentRSSI),
|
||||
RFM95_DEBUG(PSTR("RFM95:ATC:ADJ TXL,cR=%" PRIi16 ",tR=%" PRIi16 ",TXL=%" PRIi8 "\n"),
|
||||
RFM95_internalToRSSI(currentRSSI),
|
||||
RFM95_internalToRSSI(targetRSSI), RFM95.powerLevel);
|
||||
return RFM95_setTxPowerLevel(newPowerLevel);
|
||||
}
|
||||
@@ -498,7 +502,8 @@ LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
const uint8_t bufferSize, const uint8_t retries, const uint32_t retryWaitTime)
|
||||
{
|
||||
for (uint8_t retry = 0; retry <= retries; retry++) {
|
||||
RFM95_DEBUG(PSTR("RFM95:SWR:SEND,TO=%d,SEQ=%d,RETRY=%d\n"), recipient, RFM95.txSequenceNumber,
|
||||
RFM95_DEBUG(PSTR("RFM95:SWR:SEND,TO=%" PRIu8 ",SEQ=%" PRIu16 ",RETRY=%" PRIu8 "\n"), recipient,
|
||||
RFM95.txSequenceNumber,
|
||||
retry);
|
||||
rfm95_controlFlags_t flags = 0x00;
|
||||
RFM95_setACKRequested(flags, (recipient != RFM95_BROADCAST_ADDRESS));
|
||||
@@ -521,7 +526,8 @@ LOCAL bool RFM95_sendWithRetry(const uint8_t recipient, const void* buffer,
|
||||
RFM95_setRadioMode(RFM95_RADIO_MODE_RX);
|
||||
if (sender == recipient &&
|
||||
(ACKsequenceNumber == RFM95.txSequenceNumber)) {
|
||||
RFM95_DEBUG(PSTR("RFM95:SWR:ACK FROM=%d,SEQ=%d,RSSI=%d\n"),sender,ACKsequenceNumber,
|
||||
RFM95_DEBUG(PSTR("RFM95:SWR:ACK FROM=%" PRIu8 ",SEQ=%" PRIu16 ",RSSI=%" PRIi16 "\n"),sender,
|
||||
ACKsequenceNumber,
|
||||
RFM95_internalToRSSI(RSSI));
|
||||
//RFM95_clearRxBuffer();
|
||||
// ATC
|
||||
@@ -636,7 +642,7 @@ LOCAL bool RFM95_setTxPowerPercent(const uint8_t newPowerPercent)
|
||||
const rfm95_powerLevel_t newPowerLevel = static_cast<rfm95_powerLevel_t>
|
||||
(RFM95_MIN_POWER_LEVEL_DBM + (RFM95_MAX_POWER_LEVEL_DBM
|
||||
- RFM95_MIN_POWER_LEVEL_DBM) * (newPowerPercent / 100.0f));
|
||||
RFM95_DEBUG(PSTR("RFM95:SPP:PCT=%d,TX LEVEL=%d\n"), newPowerPercent,newPowerLevel);
|
||||
RFM95_DEBUG(PSTR("RFM95:SPP:PCT=%" PRIu8 ",TX LEVEL=%" PRIi8 "\n"), newPowerPercent,newPowerLevel);
|
||||
return RFM95_setTxPowerLevel(newPowerLevel);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "),
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
@@ -336,5 +336,7 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
va_end (args);
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
MY_SERIALDEVICE.flush();
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE,
|
||||
hwMillis());
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
// prepend timestamp
|
||||
@@ -172,5 +172,7 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
va_end (args);
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
MY_SERIALDEVICE.flush();
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -486,7 +486,7 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "),
|
||||
snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
@@ -505,5 +505,7 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
va_end (args);
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
MY_SERIALDEVICE.flush();
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -186,8 +186,8 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE,
|
||||
hwMillis());
|
||||
snprintf(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
// prepend timestamp
|
||||
@@ -206,5 +206,7 @@ void hwDebugPrint(const char *fmt, ... )
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
// MY_SERIALDEVICE.flush();
|
||||
}
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
@@ -173,8 +173,8 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE,
|
||||
hwMillis());
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
// prepend timestamp
|
||||
@@ -194,5 +194,7 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
// Disable flush since current STM32duino implementation performs a reset
|
||||
// instead of an actual flush
|
||||
//MY_SERIALDEVICE.flush();
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
|
||||
#ifdef MY_GATEWAY_SERIAL
|
||||
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "),
|
||||
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
|
||||
C_INTERNAL, I_LOG_MESSAGE, hwMillis());
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
@@ -189,5 +189,7 @@ void hwDebugPrint(const char *fmt, ...)
|
||||
#endif
|
||||
va_end(args);
|
||||
MY_SERIALDEVICE.print(fmtBuffer);
|
||||
#else
|
||||
(void)fmt;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user