From d598b7b1c25dc8b9654d617ae64f20b093f8fe82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAILLARD?= Date: Mon, 3 May 2021 23:24:50 +0200 Subject: [PATCH 1/3] fixing some warnings --- RFM69.cpp | 2 +- RFM69.h | 6 +++--- RFM69_OTA.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RFM69.cpp b/RFM69.cpp index 4634dc9..09462a1 100644 --- a/RFM69.cpp +++ b/RFM69.cpp @@ -551,7 +551,7 @@ void RFM69::setCS(uint8_t newSPISlaveSelect) { // set the IRQ pin bool RFM69::setIrq(uint8_t newIRQPin) { - uint8_t _newInterruptNum = digitalPinToInterrupt(newIRQPin); + int _newInterruptNum = digitalPinToInterrupt(newIRQPin); if (_newInterruptNum == NOT_AN_INTERRUPT) return false; #ifdef RF69_ATTACHINTERRUPT_TAKES_PIN_NUMBER _newInterruptNum = newIRQPin; diff --git a/RFM69.h b/RFM69.h index fc7d935..21bea1b 100644 --- a/RFM69.h +++ b/RFM69.h @@ -195,7 +195,7 @@ class RFM69 { static int16_t RSSI; // most accurate RSSI during reception (closest to the reception). RSSI of last packet. static uint8_t _mode; // should be protected? - RFM69(uint8_t slaveSelectPin, uint8_t interruptPin, bool isRFM69HW, uint8_t interruptNum) //interruptNum is now deprecated + RFM69(uint8_t slaveSelectPin, uint8_t interruptPin, bool isRFM69HW, uint8_t interruptNum __attribute__((unused))) //interruptNum is now deprecated : RFM69(slaveSelectPin, interruptPin, isRFM69HW){}; RFM69(uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, SPIClass *spi=nullptr); @@ -238,7 +238,7 @@ class RFM69 { protected: static void isr0(); void interruptHandler(); - virtual void interruptHook(uint8_t CTLbyte) {}; + virtual void interruptHook(uint8_t CTLbyte __attribute__((unused))) {}; static volatile bool _haveData; virtual void sendFrame(uint16_t toAddress, const void* buffer, uint8_t size, bool requestACK=false, bool sendACK=false); @@ -247,7 +247,7 @@ class RFM69 { uint8_t _slaveSelectPin; uint8_t _interruptPin; - uint8_t _interruptNum; + int _interruptNum; uint16_t _address; bool _spyMode; uint8_t _powerLevel; diff --git a/RFM69_OTA.cpp b/RFM69_OTA.cpp index f75b051..ee39197 100644 --- a/RFM69_OTA.cpp +++ b/RFM69_OTA.cpp @@ -510,7 +510,7 @@ uint8_t sendHEXPacket(RFM69& radio, uint16_t targetID, uint8_t* sendBuf, uint8_t radio.DATA[ackLen-2]=='O' && radio.DATA[ackLen-1]=='K') { uint16_t tmp=0; - sscanf((const char*)radio.DATA, "FLX:%hu:OK", &tmp); + sscanf((const char*)radio.DATA, "FLX:%u:OK", &tmp); return tmp == seq; } } From b4f535d68d8778268451ce2faee565e7641e80d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAILLARD?= Date: Tue, 4 May 2021 00:11:00 +0200 Subject: [PATCH 2/3] update --- RFM69.cpp | 6 +++--- RFM69.h | 2 +- RFM69_OTA.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RFM69.cpp b/RFM69.cpp index 09462a1..418f7e1 100644 --- a/RFM69.cpp +++ b/RFM69.cpp @@ -59,7 +59,7 @@ RFM69::RFM69(uint8_t slaveSelectPin, uint8_t interruptPin, bool isRFM69HW, SPICl bool RFM69::initialize(uint8_t freqBand, uint16_t nodeID, uint8_t networkID) { _interruptNum = digitalPinToInterrupt(_interruptPin); - if (_interruptNum == NOT_AN_INTERRUPT) return false; + if (_interruptNum == (uint8_t)NOT_AN_INTERRUPT) return false; #ifdef RF69_ATTACHINTERRUPT_TAKES_PIN_NUMBER _interruptNum = _interruptPin; #endif @@ -551,8 +551,8 @@ void RFM69::setCS(uint8_t newSPISlaveSelect) { // set the IRQ pin bool RFM69::setIrq(uint8_t newIRQPin) { - int _newInterruptNum = digitalPinToInterrupt(newIRQPin); - if (_newInterruptNum == NOT_AN_INTERRUPT) return false; + uint8_t _newInterruptNum = digitalPinToInterrupt(newIRQPin); + if (_newInterruptNum == (uint8_t)NOT_AN_INTERRUPT) return false; #ifdef RF69_ATTACHINTERRUPT_TAKES_PIN_NUMBER _newInterruptNum = newIRQPin; #endif diff --git a/RFM69.h b/RFM69.h index 21bea1b..3e6d50d 100644 --- a/RFM69.h +++ b/RFM69.h @@ -247,7 +247,7 @@ class RFM69 { uint8_t _slaveSelectPin; uint8_t _interruptPin; - int _interruptNum; + uint8_t _interruptNum; uint16_t _address; bool _spyMode; uint8_t _powerLevel; diff --git a/RFM69_OTA.cpp b/RFM69_OTA.cpp index ee39197..1e91837 100644 --- a/RFM69_OTA.cpp +++ b/RFM69_OTA.cpp @@ -510,7 +510,7 @@ uint8_t sendHEXPacket(RFM69& radio, uint16_t targetID, uint8_t* sendBuf, uint8_t radio.DATA[ackLen-2]=='O' && radio.DATA[ackLen-1]=='K') { uint16_t tmp=0; - sscanf((const char*)radio.DATA, "FLX:%u:OK", &tmp); + sscanf((const char*)radio.DATA, "FLX:%" PRIu16 ":OK", &tmp); return tmp == seq; } } From bcdf0cfa489c6d0b3cd04fa41a35781307c0485d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAILLARD?= Date: Tue, 4 May 2021 00:26:12 +0200 Subject: [PATCH 3/3] uint16_t formatting --- RFM69_OTA.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/RFM69_OTA.cpp b/RFM69_OTA.cpp index 1e91837..729bf8a 100644 --- a/RFM69_OTA.cpp +++ b/RFM69_OTA.cpp @@ -510,7 +510,13 @@ uint8_t sendHEXPacket(RFM69& radio, uint16_t targetID, uint8_t* sendBuf, uint8_t radio.DATA[ackLen-2]=='O' && radio.DATA[ackLen-1]=='K') { uint16_t tmp=0; - sscanf((const char*)radio.DATA, "FLX:%" PRIu16 ":OK", &tmp); +#if defined(__arm__) + // On the ARM platform, uint16_t = short unsigned int, so %hu formatting is needed: + sscanf((const char*)radio.DATA, "FLX:%hu:OK", &tmp); +#else + // On the AVR platform, uint16_t = unsigned int, so %u formatting is needed: + sscanf((const char*)radio.DATA, "FLX:%u:OK", &tmp); +#endif return tmp == seq; } }