diff --git a/scripts/applyPatches.py b/scripts/applyPatches.py index 131572fd..3ba30a5f 100644 --- a/scripts/applyPatches.py +++ b/scripts/applyPatches.py @@ -31,5 +31,4 @@ if env['PIOENV'][:22] != "opendtufusion-ethernet": if env['PIOENV'][:13] == "opendtufusion": applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") -if env['PIOENV'][:22] == "opendtufusion-ethernet": applyPatch("RF24", "../patches/RF24_Hal.patch") diff --git a/src/CHANGES.md b/src/CHANGES.md index 85e477e3..6364a7e7 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.24 - 2023-12-16 +* fix NRF communication for opendtufusion ethernet variant + ## 0.8.23 - 2023-12-14 * heuristics fix #1269 #1270 * moved `sendInterval` in settings, **important:** *will be reseted to 15s after update to this version* diff --git a/src/defines.h b/src/defines.h index c4559891..71bfc1fa 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 23 +#define VERSION_PATCH 24 //------------------------------------- typedef struct { diff --git a/src/hm/CommQueue.h b/src/hm/CommQueue.h index 5d6f9bd0..d1beedfc 100644 --- a/src/hm/CommQueue.h +++ b/src/hm/CommQueue.h @@ -31,6 +31,7 @@ class CommQueue { } uint8_t getFillState(void) { + DPRINTLN(DBG_INFO, "wr: " + String(mWrPtr) + ", rd: " + String(mRdPtr)); return abs(mRdPtr - mWrPtr); } diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 14146830..d0387aa4 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -10,7 +10,7 @@ #include "SPI.h" #include "radio.h" #include "../config/config.h" -#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) +#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) #include "nrfHal.h" #endif @@ -35,8 +35,8 @@ class HmRadio : public Radio { HmRadio() { mDtuSn = DTU_SN; mIrqRcvd = false; - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) - mNrf24.reset(new RF24()); + #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + //mNrf24.reset(new RF24()); #else mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); #endif @@ -56,8 +56,8 @@ class HmRadio : public Radio { DTU_RADIO_ID = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01; #ifdef ESP32 - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) - mNrfHal.init(mosi, miso, sclk, cs, ce); + #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + mNrfHal.init(mosi, miso, sclk, cs, ce, SPI_SPEED); mNrf24.reset(new RF24(&mNrfHal)); #else #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 @@ -73,7 +73,7 @@ class HmRadio : public Radio { mSpi->begin(); #endif - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) + #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) mNrf24->begin(); #else mNrf24->begin(mSpi.get(), ce, cs); @@ -133,14 +133,12 @@ class HmRadio : public Radio { yield(); } // switch to next RX channel - if(++mRxChIdx >= RF_CHANNELS) - mRxChIdx = 0; + mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS; mNrf24->setChannel(mRfChLst[mRxChIdx]); startMicros = micros(); } // not finished but time is over - if(++mRxChIdx >= RF_CHANNELS) - mRxChIdx = 0; + mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS; return; } @@ -344,7 +342,7 @@ class HmRadio : public Radio { std::unique_ptr mSpi; std::unique_ptr mNrf24; - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) + #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) nrfHal mNrfHal; #endif Inverter<> *mLastIv = NULL; diff --git a/src/hm/nrfHal.h b/src/hm/nrfHal.h index d4db9f92..c9fbcdc7 100644 --- a/src/hm/nrfHal.h +++ b/src/hm/nrfHal.h @@ -118,7 +118,7 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle { uint8_t write(uint8_t cmd, const uint8_t* buf, uint8_t data_len, uint8_t blank_len) override { uint8_t data[NRF_MAX_TRANSFER_SZ]; data[0] = cmd; - memset(data, 0, NRF_MAX_TRANSFER_SZ); + memset(&data[1], 0, (NRF_MAX_TRANSFER_SZ-1)); std::copy(&buf[0], &buf[data_len], &data[1]); request_spi(); diff --git a/src/hms/cmt2300a.h b/src/hms/cmt2300a.h index bbbeefc7..1ff112e2 100644 --- a/src/hms/cmt2300a.h +++ b/src/hms/cmt2300a.h @@ -6,7 +6,7 @@ #ifndef __CMT2300A_H__ #define __CMT2300A_H__ -#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) +#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) #include "cmtHal.h" #else #include "esp32_3wSpi.h" @@ -480,7 +480,7 @@ class Cmt2300a { return mSpi.readReg(CMT2300A_CUS_MODE_STA) & CMT2300A_MASK_CHIP_MODE_STA; } - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) + #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) cmtHal mSpi; #else esp32_3wSpi mSpi; diff --git a/src/platformio.ini b/src/platformio.ini index e7fb137e..43fd7ddd 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -162,6 +162,7 @@ lib_deps = upload_protocol = esp-builtin build_flags = ${env.build_flags} -DETHERNET + -DSPI_HAL -DUSE_HSPI_FOR_EPD -DDEF_ETH_CS_PIN=42 -DDEF_ETH_SCK_PIN=39 @@ -184,13 +185,22 @@ build_flags = ${env.build_flags} -DDEF_LED1=17 -DLED_ACTIVE_HIGH -DARDUINO_USB_MODE=1 - #-DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_CDC_ON_BOOT=1 monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-dev] platform = espressif32@6.4.0 board = esp32-s3-devkitc-1 +lib_deps = + https://github.com/yubox-node-org/ESPAsyncWebServer + 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 + https://github.com/JChristensen/Timezone @ ^1.2.4 + olikraus/U8g2 @ ^2.35.7 + https://github.com/zinggjm/GxEPD2 @ ^1.5.2 upload_protocol = esp-builtin build_flags = ${env.build_flags} -DDEF_NRF_CS_PIN=37 @@ -209,5 +219,6 @@ build_flags = ${env.build_flags} -DLED_ACTIVE_HIGH -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 + -DSPI_HAL monitor_filters = esp32_exception_decoder, colorize