Browse Source

Merge branch 'development03' into ethW5500

pull/1512/head
lumapu 1 year ago
parent
commit
61a7030cdd
  1. 35
      patches/RF24.patch
  2. 28
      patches/RF24_Hal.patch
  3. 2
      scripts/applyPatches.py
  4. 4
      src/CHANGES.md
  5. 24
      src/app.cpp
  6. 1
      src/app.h
  7. 4
      src/defines.h
  8. 17
      src/hm/Communication.h
  9. 10
      src/hm/hmRadio.h
  10. 2
      src/hm/radio.h
  11. 5
      src/platformio.ini

35
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__

28
patches/RF24_Hal.patch

@ -1,5 +1,5 @@
diff --git a/RF24.cpp b/RF24.cpp diff --git a/RF24.cpp b/RF24.cpp
index c0cc732..b6708d9 100644 index 9e5b4a8..af00758 100644
--- a/RF24.cpp --- a/RF24.cpp
+++ b/RF24.cpp +++ b/RF24.cpp
@@ -12,228 +12,24 @@ @@ -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) 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 diff --git a/RF24.h b/RF24.h
index dbd32ae..f774bba 100644 index dbd32ae..74ae35d 100644
--- a/RF24.h --- a/RF24.h
+++ b/RF24.h +++ b/RF24.h
@@ -16,12 +16,7 @@ @@ -16,12 +16,7 @@
@ -932,7 +944,15 @@ index dbd32ae..f774bba 100644
*/ */
void encodeRadioDetails(uint8_t* encoded_status); 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(); bool _init_pins();

2
scripts/applyPatches.py

@ -32,3 +32,5 @@ if env['PIOENV'][:22] != "opendtufusion-ethernet":
if env['PIOENV'][:13] == "opendtufusion": if env['PIOENV'][:13] == "opendtufusion":
applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch")
applyPatch("RF24", "../patches/RF24_Hal.patch") applyPatch("RF24", "../patches/RF24_Hal.patch")
else:
applyPatch("RF24", "../patches/RF24.patch")

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes # Development Changes
## 0.8.64 - 2024-01-22
* add `ARC` to log (NRF24 Debug)
* merge PR: ETH NTP update bugfix #1385
## 0.8.63 - 2024-01-22 ## 0.8.63 - 2024-01-22
* made code review * made code review
* fixed endless loop #1387 * fixed endless loop #1387

24
src/app.cpp

@ -170,7 +170,6 @@ void app::onNetwork(bool gotIp) {
mMqttReconnect = true; mMqttReconnect = true;
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers! mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2"); once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
//tickNtpUpdate();
#if !defined(ETHERNET) #if !defined(ETHERNET)
if (WIFI_AP == WiFi.getMode()) { if (WIFI_AP == WiFi.getMode()) {
mMqttEnabled = false; mMqttEnabled = false;
@ -204,12 +203,7 @@ void app::regularTickers(void) {
#if defined(ETHERNET) #if defined(ETHERNET)
void app::onNtpUpdate(bool gotTime) { void app::onNtpUpdate(bool gotTime) {
uint32_t nxtTrig = 5; // default: check again in 5 sec mNtpReceived = true;
if (gotTime || mTimestamp != 0) {
this->updateNtp();
nxtTrig = gotTime ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min
}
once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp");
} }
#endif /* defined(ETHERNET) */ #endif /* defined(ETHERNET) */
@ -253,13 +247,19 @@ void app::updateNtp(void) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void app::tickNtpUpdate(void) { void app::tickNtpUpdate(void) {
uint32_t nxtTrig = 5; // default: check again in 5 sec uint32_t nxtTrig = 5; // default: check again in 5 sec
bool isOK = false;
#if defined(ETHERNET) #if defined(ETHERNET)
bool isOK = (mTimestamp != 0); if (!mNtpReceived)
mEth.updateNtpTime(); mEth.updateNtpTime();
else {
mNtpReceived = false;
isOK = true;
}
#else #else
bool isOK = mWifi.getNtpTime(); isOK = mWifi.getNtpTime();
#endif #endif
if (isOK || mTimestamp != 0) { if (isOK) {
this->updateNtp(); this->updateNtp();
nxtTrig = isOK ? (mConfig->ntp.interval * 60) : 60; // depending on NTP update success check again in 12h (depends on setting) or in 1 min nxtTrig = isOK ? (mConfig->ntp.interval * 60) : 60; // depending on NTP update success check again in 12h (depends on setting) or in 1 min
@ -563,6 +563,10 @@ void app::resetSystem(void) {
mSaveReboot = false; mSaveReboot = false;
mNetworkConnected = false; mNetworkConnected = false;
#if defined(ETHERNET)
mNtpReceived = false;
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

1
src/app.h

@ -351,6 +351,7 @@ class app : public IApp, public ah::Scheduler {
void tickNtpUpdate(void); void tickNtpUpdate(void);
#if defined(ETHERNET) #if defined(ETHERNET)
void onNtpUpdate(bool gotTime); void onNtpUpdate(bool gotTime);
bool mNtpReceived;
#endif /* defined(ETHERNET) */ #endif /* defined(ETHERNET) */
void updateNtp(void); void updateNtp(void);

4
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 63 #define VERSION_PATCH 64
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {
@ -22,6 +22,8 @@ typedef struct {
int8_t rssi; int8_t rssi;
uint8_t packet[MAX_RF_PAYLOAD_SIZE]; uint8_t packet[MAX_RF_PAYLOAD_SIZE];
uint16_t millis; uint16_t millis;
uint8_t arc;
uint8_t plos;
} packet_t; } packet_t;
typedef enum { typedef enum {

17
src/hm/Communication.h

@ -134,10 +134,17 @@ class Communication : public CommQueue<> {
DPRINT_IVID(DBG_INFO, q->iv->id); DPRINT_IVID(DBG_INFO, q->iv->id);
DBGPRINT(F("request timeout: ")); DBGPRINT(F("request timeout: "));
DBGPRINT(String(q->iv->radio->mRadioWaitTime.getRunTime())); DBGPRINT(String(q->iv->radio->mRadioWaitTime.getRunTime()));
DBGPRINTLN(F("ms")); DBGPRINT(F("ms"));
if(INV_RADIO_TYPE_NRF == q->iv->ivRadioType) {
DBGPRINT(F(", ARC "));
DBGPRINT(String(q->iv->radio->getARC()));
DBGPRINT(F(", PLOS "));
DBGPRINTLN(String(q->iv->radio->getPLOS()));
} else
DBGPRINTLN("");
} }
if(!q->iv->mGotFragment) { if(!q->iv->mGotFragment) {
if(q->iv->ivRadioType == INV_RADIO_TYPE_CMT) { if(INV_RADIO_TYPE_CMT == q->iv->ivRadioType) {
q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ)); q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ));
mWaitTime.startTimeMonitor(1000); mWaitTime.startTimeMonitor(1000);
} else { } else {
@ -284,6 +291,11 @@ class Communication : public CommQueue<> {
DBGPRINT(String(p->millis)); DBGPRINT(String(p->millis));
DBGPRINT(F("ms | ")); DBGPRINT(F("ms | "));
DBGPRINT(String(p->len)); 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) { if(INV_RADIO_TYPE_NRF == q->iv->ivRadioType) {
DBGPRINT(F(" CH")); DBGPRINT(F(" CH"));
if(3 == p->ch) if(3 == p->ch)
@ -500,6 +512,7 @@ class Communication : public CommQueue<> {
int8_t rssi = -127; int8_t rssi = -127;
uint8_t len = 0; uint8_t len = 0;
DPRINT_IVID(DBG_INFO, q->iv->id);
for(uint8_t i = 0; i < mMaxFrameId; i++) { for(uint8_t i = 0; i < mMaxFrameId; i++) {
if(mLocalBuf[i].len + len > MAX_BUFFER) { if(mLocalBuf[i].len + len > MAX_BUFFER) {
DPRINTLN(DBG_ERROR, F("payload buffer to small!")); DPRINTLN(DBG_ERROR, F("payload buffer to small!"));

10
src/hm/hmRadio.h

@ -293,6 +293,14 @@ class HmRadio : public Radio {
return mNrf24->isPVariant(); return mNrf24->isPVariant();
} }
uint8_t getARC(void) {
return mNrf24->getARC();
}
uint8_t getPLOS(void) {
return mNrf24->getPLOS();
}
private: private:
inline bool getReceived(void) { inline bool getReceived(void) {
bool isLastPackage = false; bool isLastPackage = false;
@ -307,6 +315,8 @@ class HmRadio : public Radio {
p.len = (len > MAX_RF_PAYLOAD_SIZE) ? MAX_RF_PAYLOAD_SIZE : len; p.len = (len > MAX_RF_PAYLOAD_SIZE) ? MAX_RF_PAYLOAD_SIZE : len;
p.rssi = mNrf24->testRPD() ? -64 : -75; p.rssi = mNrf24->testRPD() ? -64 : -75;
p.millis = millis() - mMillis; p.millis = millis() - mMillis;
p.arc = mNrf24->getARC();
p.plos = mNrf24->getPLOS();
mNrf24->read(p.packet, p.len); mNrf24->read(p.packet, p.len);
if (p.packet[0] != 0x00) { if (p.packet[0] != 0x00) {

2
src/hm/radio.h

@ -29,6 +29,8 @@ class Radio {
virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; } virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; }
virtual bool isChipConnected(void) { return false; } virtual bool isChipConnected(void) { return false; }
virtual bool loop(void) = 0; virtual bool loop(void) = 0;
virtual uint8_t getARC(void) { return 0xff; }
virtual uint8_t getPLOS(void) { return 0xff; }
void handleIntr(void) { void handleIntr(void) {
mIrqRcvd = true; mIrqRcvd = true;

5
src/platformio.ini

@ -26,7 +26,7 @@ extra_scripts =
lib_deps = lib_deps =
https://github.com/yubox-node-org/ESPAsyncWebServer 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 paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.5.0 https://github.com/bertmelis/espMqttClient#v1.5.0
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
@ -314,6 +314,7 @@ build_flags = ${env.build_flags}
-DENABLE_MQTT -DENABLE_MQTT
-DPLUGIN_DISPLAY -DPLUGIN_DISPLAY
-DENABLE_HISTORY -DENABLE_HISTORY
-DSPI_HAL
-DDEF_NRF_CS_PIN=37 -DDEF_NRF_CS_PIN=37
-DDEF_NRF_CE_PIN=38 -DDEF_NRF_CE_PIN=38
-DDEF_NRF_IRQ_PIN=47 -DDEF_NRF_IRQ_PIN=47
@ -342,6 +343,7 @@ build_flags = ${env.build_flags}
-DENABLE_MQTT -DENABLE_MQTT
-DPLUGIN_DISPLAY -DPLUGIN_DISPLAY
-DENABLE_HISTORY -DENABLE_HISTORY
-DSPI_HAL
-DDEF_NRF_CS_PIN=37 -DDEF_NRF_CS_PIN=37
-DDEF_NRF_CE_PIN=38 -DDEF_NRF_CE_PIN=38
-DDEF_NRF_IRQ_PIN=47 -DDEF_NRF_IRQ_PIN=47
@ -365,6 +367,7 @@ platform = espressif32@6.5.0
board = esp32-s3-devkitc-1 board = esp32-s3-devkitc-1
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DSPI_HAL
-DDEF_NRF_CS_PIN=37 -DDEF_NRF_CS_PIN=37
-DDEF_NRF_CE_PIN=38 -DDEF_NRF_CE_PIN=38
-DDEF_NRF_IRQ_PIN=47 -DDEF_NRF_IRQ_PIN=47

Loading…
Cancel
Save