diff --git a/patches/RF24.patch b/patches/RF24.patch new file mode 100644 index 000000000..63db88236 --- /dev/null +++ b/patches/RF24.patch @@ -0,0 +1,35 @@ +diff --git a/RF24.cpp b/RF24.cpp +index 9e5b4a8..a4de63c 100644 +--- a/RF24.cpp ++++ b/RF24.cpp +@@ -1871,6 +1871,11 @@ uint8_t RF24::getARC(void) + return read_register(OBSERVE_TX) & 0x0F; + } + ++uint8_t RF24::getPLOS(void) ++{ ++ return read_register(OBSERVE_TX) & 0x0F; ++} ++ + /****************************************************************************/ + + bool RF24::setDataRate(rf24_datarate_e speed) +diff --git a/RF24.h b/RF24.h +index dbd32ae..a3d6b52 100644 +--- a/RF24.h ++++ b/RF24.h +@@ -1644,6 +1644,7 @@ public: + * @return Returns values from 0 to 15. + */ + uint8_t getARC(void); ++ uint8_t getPLOS(void); + + /** + * Set the transmission @ref Datarate +@@ -2415,4 +2416,4 @@ private: + * Use `ctrl+c` to quit at any time. + */ + +-#endif // __RF24_H__ +\ No newline at end of file ++#endif // __RF24_H__ diff --git a/patches/RF24_Hal.patch b/patches/RF24_Hal.patch index 1a4f159e4..88a53bf9c 100644 --- a/patches/RF24_Hal.patch +++ b/patches/RF24_Hal.patch @@ -1,5 +1,5 @@ diff --git a/RF24.cpp b/RF24.cpp -index c0cc732..b6708d9 100644 +index 9e5b4a8..af00758 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -12,228 +12,24 @@ @@ -727,7 +727,7 @@ index c0cc732..b6708d9 100644 } /****************************************************************************/ -@@ -1676,15 +1136,8 @@ void RF24::closeReadingPipe(uint8_t pipe) +@@ -1675,15 +1135,8 @@ void RF24::closeReadingPipe(uint8_t pipe) void RF24::toggle_features(void) { @@ -745,8 +745,20 @@ index c0cc732..b6708d9 100644 } /****************************************************************************/ +@@ -1871,6 +1324,11 @@ uint8_t RF24::getARC(void) + return read_register(OBSERVE_TX) & 0x0F; + } + ++uint8_t RF24::getPLOS(void) ++{ ++ return (read_register(OBSERVE_TX) >> 4) & 0x0F; ++} ++ + /****************************************************************************/ + + bool RF24::setDataRate(rf24_datarate_e speed) diff --git a/RF24.h b/RF24.h -index dbd32ae..f774bba 100644 +index dbd32ae..74ae35d 100644 --- a/RF24.h +++ b/RF24.h @@ -16,12 +16,7 @@ @@ -932,7 +944,15 @@ index dbd32ae..f774bba 100644 */ void encodeRadioDetails(uint8_t* encoded_status); -@@ -1896,18 +1800,6 @@ private: +@@ -1644,6 +1548,7 @@ public: + * @return Returns values from 0 to 15. + */ + uint8_t getARC(void); ++ uint8_t getPLOS(void); + + /** + * Set the transmission @ref Datarate +@@ -1896,18 +1801,6 @@ private: */ bool _init_pins(); diff --git a/scripts/applyPatches.py b/scripts/applyPatches.py index 3ba30a5f7..3289badbf 100644 --- a/scripts/applyPatches.py +++ b/scripts/applyPatches.py @@ -32,3 +32,5 @@ def applyPatch(libName, patchFile): if env['PIOENV'][:13] == "opendtufusion": applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") applyPatch("RF24", "../patches/RF24_Hal.patch") +else: + applyPatch("RF24", "../patches/RF24.patch") diff --git a/src/defines.h b/src/defines.h index 81319b299..b8ddace93 100644 --- a/src/defines.h +++ b/src/defines.h @@ -23,6 +23,7 @@ typedef struct { uint8_t packet[MAX_RF_PAYLOAD_SIZE]; uint16_t millis; uint8_t arc; + uint8_t plos; } packet_t; typedef enum { diff --git a/src/hm/Communication.h b/src/hm/Communication.h index ca76cc043..98dd06e15 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -137,7 +137,9 @@ class Communication : public CommQueue<> { DBGPRINT(F("ms")); if(INV_RADIO_TYPE_NRF == q->iv->ivRadioType) { DBGPRINT(F(", ARC ")); - DBGPRINTLN(String(q->iv->radio->getARC())); + DBGPRINT(String(q->iv->radio->getARC())); + DBGPRINT(F(", PLOS ")); + DBGPRINTLN(String(q->iv->radio->getPLOS())); } else DBGPRINTLN(""); } @@ -291,6 +293,8 @@ class Communication : public CommQueue<> { DBGPRINT(String(p->len)); DBGPRINT(F(", ARC ")); DBGPRINT(String(p->arc)); + DBGPRINT(F(", PLOS ")); + DBGPRINT(String(p->plos)); DBGPRINT(F(" |")); if(INV_RADIO_TYPE_NRF == q->iv->ivRadioType) { DBGPRINT(F(" CH")); diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 774a99a1c..ef37e266e 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -297,6 +297,10 @@ class HmRadio : public Radio { return mNrf24->getARC(); } + uint8_t getPLOS(void) { + return mNrf24->getPLOS(); + } + private: inline bool getReceived(void) { bool isLastPackage = false; @@ -312,6 +316,7 @@ class HmRadio : public Radio { p.rssi = mNrf24->testRPD() ? -64 : -75; p.millis = millis() - mMillis; p.arc = mNrf24->getARC(); + p.plos = mNrf24->getPLOS(); mNrf24->read(p.packet, p.len); if (p.packet[0] != 0x00) { diff --git a/src/hm/radio.h b/src/hm/radio.h index 9cb14000d..a71e24c7a 100644 --- a/src/hm/radio.h +++ b/src/hm/radio.h @@ -30,6 +30,7 @@ class Radio { virtual bool isChipConnected(void) { return false; } virtual bool loop(void) = 0; virtual uint8_t getARC(void) { return 0xff; } + virtual uint8_t getPLOS(void) { return 0xff; } void handleIntr(void) { mIrqRcvd = true; diff --git a/src/platformio.ini b/src/platformio.ini index e8a1a68af..9b97e0187 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -26,7 +26,7 @@ extra_scripts = lib_deps = https://github.com/yubox-node-org/ESPAsyncWebServer - nrf24/RF24 @ 1.4.8 + https://github.com/nRF24/RF24 @ 1.4.8 paulstoffregen/Time @ ^1.6.1 https://github.com/bertmelis/espMqttClient#v1.5.0 bblanchon/ArduinoJson @ ^6.21.3 @@ -195,7 +195,7 @@ board = esp32dev lib_deps = khoih-prog/AsyncWebServer_ESP32_W5500 khoih-prog/AsyncUDP_ESP32_W5500 - nrf24/RF24 @ ^1.4.8 + https://github.com/nRF24/RF24 @ ^1.4.8 paulstoffregen/Time @ ^1.6.1 https://github.com/bertmelis/espMqttClient#v1.5.0 bblanchon/ArduinoJson @ ^6.21.3 @@ -218,7 +218,7 @@ board = esp32dev lib_deps = khoih-prog/AsyncWebServer_ESP32_W5500 khoih-prog/AsyncUDP_ESP32_W5500 - nrf24/RF24 @ ^1.4.8 + https://github.com/nRF24/RF24 @ ^1.4.8 paulstoffregen/Time @ ^1.6.1 https://github.com/bertmelis/espMqttClient#v1.5.0 bblanchon/ArduinoJson @ ^6.21.3 @@ -334,6 +334,7 @@ build_flags = ${env.build_flags} -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY + -DSPI_HAL -DDEF_NRF_CS_PIN=37 -DDEF_NRF_CE_PIN=38 -DDEF_NRF_IRQ_PIN=47 @@ -362,6 +363,7 @@ build_flags = ${env.build_flags} -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY + -DSPI_HAL -DDEF_NRF_CS_PIN=37 -DDEF_NRF_CE_PIN=38 -DDEF_NRF_IRQ_PIN=47 @@ -385,6 +387,7 @@ platform = espressif32@6.5.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env.build_flags} + -DSPI_HAL -DDEF_NRF_CS_PIN=37 -DDEF_NRF_CE_PIN=38 -DDEF_NRF_IRQ_PIN=47