From 0ed558f1d077e68b69c2fe1cb0056c526ae3023e Mon Sep 17 00:00:00 2001 From: Olivier Date: Sun, 17 Sep 2017 20:54:20 +0200 Subject: [PATCH] Make debug prints portable (#929) --- core/MyGatewayTransportEthernet.cpp | 10 ++--- core/MyOTAFirmwareUpdate.cpp | 13 +++--- core/MyProtocolMySensors.cpp | 8 ++-- core/MySensorsCore.cpp | 16 ++++--- core/MySigning.cpp | 68 +++++++++++++++++------------ core/MySigningAtsha204.cpp | 11 ++--- core/MySigningAtsha204Soft.cpp | 11 ++--- core/MyTransport.cpp | 49 +++++++++++---------- drivers/NRF5/Radio_ESB.cpp | 10 +++-- drivers/RF24/RF24.cpp | 16 +++---- drivers/RFM69/new/RFM69_new.cpp | 29 +++++++----- drivers/RFM95/RFM95.cpp | 22 ++++++---- hal/architecture/MyHwAVR.cpp | 4 +- hal/architecture/MyHwESP8266.cpp | 6 ++- hal/architecture/MyHwNRF5.cpp | 6 ++- hal/architecture/MyHwSAMD.cpp | 6 ++- hal/architecture/MyHwSTM32F1.cpp | 8 ++-- hal/architecture/MyHwTeensy3.cpp | 4 +- 18 files changed, 173 insertions(+), 124 deletions(-) diff --git a/core/MyGatewayTransportEthernet.cpp b/core/MyGatewayTransportEthernet.cpp index 3ca7609..2278c94 100644 --- a/core/MyGatewayTransportEthernet.cpp +++ b/core/MyGatewayTransportEthernet.cpp @@ -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(); diff --git a/core/MyOTAFirmwareUpdate.cpp b/core/MyOTAFirmwareUpdate.cpp index bfd0826..4b4cf4a 100644 --- a/core/MyOTAFirmwareUpdate.cpp +++ b/core/MyOTAFirmwareUpdate.cpp @@ -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= 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)) { diff --git a/core/MySigningAtsha204.cpp b/core/MySigningAtsha204.cpp index 1734bde..b016eaf 100644 --- a/core/MySigningAtsha204.cpp +++ b/core/MySigningAtsha204.cpp @@ -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; diff --git a/core/MySigningAtsha204Soft.cpp b/core/MySigningAtsha204Soft.cpp index 7f67c93..cdd4894 100644 --- a/core/MySigningAtsha204Soft.cpp +++ b/core/MySigningAtsha204Soft.cpp @@ -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 diff --git a/core/MyTransport.cpp b/core/MyTransport.cpp index 5432ae8..79abe10 100644 --- a/core/MyTransport.cpp +++ b/core/MyTransport.cpp @@ -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) ? "" : _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; } diff --git a/drivers/NRF5/Radio_ESB.cpp b/drivers/NRF5/Radio_ESB.cpp index 06af368..202864a 100644 --- a/drivers/NRF5/Radio_ESB.cpp +++ b/drivers/NRF5/Radio_ESB.cpp @@ -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 diff --git a/drivers/RF24/RF24.cpp b/drivers/RF24/RF24.cpp index 73a85e3..cdaf869 100644 --- a/drivers/RF24/RF24.cpp +++ b/drivers/RF24/RF24.cpp @@ -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); diff --git a/drivers/RFM69/new/RFM69_new.cpp b/drivers/RFM69/new/RFM69_new.cpp index 0ba82a1..07b8f9f 100644 --- a/drivers/RFM69/new/RFM69_new.cpp +++ b/drivers/RFM69/new/RFM69_new.cpp @@ -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_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 \ No newline at end of file +#endif diff --git a/drivers/RFM95/RFM95.cpp b/drivers/RFM95/RFM95.cpp index 2c6d3d4..ec6c0ba 100644 --- a/drivers/RFM95/RFM95.cpp +++ b/drivers/RFM95/RFM95.cpp @@ -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_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); } diff --git a/hal/architecture/MyHwAVR.cpp b/hal/architecture/MyHwAVR.cpp index 9b7cbb8..b23cbf8 100644 --- a/hal/architecture/MyHwAVR.cpp +++ b/hal/architecture/MyHwAVR.cpp @@ -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 } diff --git a/hal/architecture/MyHwESP8266.cpp b/hal/architecture/MyHwESP8266.cpp index 8a18274..a11e1da 100644 --- a/hal/architecture/MyHwESP8266.cpp +++ b/hal/architecture/MyHwESP8266.cpp @@ -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 } diff --git a/hal/architecture/MyHwNRF5.cpp b/hal/architecture/MyHwNRF5.cpp index 31c405e..25ae921 100644 --- a/hal/architecture/MyHwNRF5.cpp +++ b/hal/architecture/MyHwNRF5.cpp @@ -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 } diff --git a/hal/architecture/MyHwSAMD.cpp b/hal/architecture/MyHwSAMD.cpp index 87d3576..c83eca7 100644 --- a/hal/architecture/MyHwSAMD.cpp +++ b/hal/architecture/MyHwSAMD.cpp @@ -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 } diff --git a/hal/architecture/MyHwSTM32F1.cpp b/hal/architecture/MyHwSTM32F1.cpp index f67fbe1..f213ba0 100644 --- a/hal/architecture/MyHwSTM32F1.cpp +++ b/hal/architecture/MyHwSTM32F1.cpp @@ -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 } diff --git a/hal/architecture/MyHwTeensy3.cpp b/hal/architecture/MyHwTeensy3.cpp index 4bc32a3..c9e7702 100644 --- a/hal/architecture/MyHwTeensy3.cpp +++ b/hal/architecture/MyHwTeensy3.cpp @@ -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 }