Skip to content

Commit

Permalink
0.8.64
Browse files Browse the repository at this point in the history
add `getPLOS` (NRF24 Debug)
  • Loading branch information
lumapu committed Jan 22, 2024
1 parent 92a9e16 commit 7f386f0
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 8 deletions.
35 changes: 35 additions & 0 deletions patches/RF24.patch
Original file line number Diff line number Diff line change
@@ -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__
28 changes: 24 additions & 4 deletions patches/RF24_Hal.patch
Original file line number Diff line number Diff line change
@@ -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 @@
Expand Down Expand Up @@ -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)
{
Expand All @@ -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 @@
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions scripts/applyPatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/hm/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
}
Expand Down Expand Up @@ -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"));
Expand Down
5 changes: 5 additions & 0 deletions src/hm/hmRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/hm/radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -385,6 +387,7 @@ platform = [email protected]
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
Expand Down

0 comments on commit 7f386f0

Please sign in to comment.