diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json index 6af36bae..3b7ffafd 100644 --- a/src/.vscode/settings.json +++ b/src/.vscode/settings.json @@ -24,6 +24,55 @@ "typeinfo": "cpp", "string": "cpp", "istream": "cpp", - "ostream": "cpp" + "ostream": "cpp", + "array": "cpp", + "atomic": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "map": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "limits": "cpp", + "new": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp" }, } \ No newline at end of file diff --git a/src/app.cpp b/src/app.cpp index fcfee586..06fb3088 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -23,6 +23,7 @@ void app::setup(uint32_t timeout) { addListener(EVERY_12H, std::bind(&app::ntpUpdateTick, this)); resetSystem(); + mSettings.setup(); mSettings.getPtr(mConfig); DPRINTLN(DBG_INFO, F("Settings valid: ") + String((mSettings.getValid()) ? F("true") : F("false"))); @@ -33,19 +34,28 @@ void app::setup(uint32_t timeout) { mSys = new HmSystemType(); mSys->enableDebug(); mSys->setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs); - mSys->addInverters(&mConfig->inst); - mPayload.setup(mSys); - mPayload.enableSerialDebug(mConfig->serial.debug); -#if !defined(AP_ONLY) - if (mConfig->mqtt.broker[0] > 0) { + if(mSys->Radio.isChipConnected()) + { + mSys->addInverters(&mConfig->inst); + + mPayload.setup(mSys); + mPayload.enableSerialDebug(mConfig->serial.debug); + } + else + { + DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring")); + } + + // when WiFi is in client mode, then enable mqtt broker + if (mConfig->mqtt.broker[0] > 0 && WiFi.getMode() == WIFI_STA) { mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, mSys, &mUtcTimestamp, &mSunrise, &mSunset); mPayload.addListener(std::bind(&PubMqttType::payloadEventListener, &mMqtt, std::placeholders::_1)); addListener(EVERY_SEC, std::bind(&PubMqttType::tickerSecond, &mMqtt)); addListener(EVERY_MIN, std::bind(&PubMqttType::tickerMinute, &mMqtt)); addListener(EVERY_HR, std::bind(&PubMqttType::tickerHour, &mMqtt)); } -#endif + setupLed(); mWeb = new web(this, mConfig, &mStat, mVersion); diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 4e1b749c..9061174a 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -99,7 +99,7 @@ class HmRadio { DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setup")); pinMode(irq, INPUT_PULLUP); mBufCtrl = ctrl; - + uint32_t dtuSn = 0x87654321; uint32_t chipID = 0; // will be filled with last 3 bytes of MAC @@ -191,7 +191,7 @@ class HmRadio { uint8_t setDefaultChannels(void) { //DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setDefaultChannels")); mTxChIdx = 2; // Start TX with 40 - mRxChIdx = 0; // Start RX with 03 + mRxChIdx = 0; // Start RX with 03 return mRfChLst[mTxChIdx]; } @@ -212,7 +212,7 @@ class HmRadio { uint16_t crc = ah::crc16(&mTxBuf[10], cnt); mTxBuf[10 + cnt++] = (crc >> 8) & 0xff; mTxBuf[10 + cnt++] = (crc ) & 0xff; - + // crc over all mTxBuf[10 + cnt] = ah::crc8(mTxBuf, 10 + cnt); @@ -295,6 +295,14 @@ class HmRadio { return mNrf24.isChipConnected(); } + rf24_datarate_e getDataRate(void) { + return mNrf24.getDataRate(); + } + + bool isPVariant(void) { + return mNrf24.isPVariant(); + } + uint32_t mSendCnt; @@ -360,7 +368,7 @@ class HmRadio { uint8_t mTxChIdx; uint8_t mRfChLst[RF_CHANNELS]; - + uint8_t mRxChIdx; uint16_t mRxLoopCnt; diff --git a/src/web/html/system.html b/src/web/html/system.html index d8a473a2..c95d581a 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -19,6 +19,7 @@