Browse Source

Improved ESP8266 support for HMS version (same code base: only ESP32 supports HMS!)

pull/935/head
lumapu 2 years ago
parent
commit
27f16c4e91
  1. 24
      src/app.cpp
  2. 12
      src/app.h
  3. 2
      src/defines.h
  4. 4
      src/main.cpp
  5. 16
      src/web/html/setup.html

24
src/app.cpp

@ -61,22 +61,20 @@ void app::setup() {
mMiPayload.enableSerialDebug(mConfig->serial.debug);
mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
if(!mNrfRadio.isChipConnected())
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
}
//if(mConfig->cmt.enabled) {
#if defined(ESP32)
mHmsPayload.setup(this, &mSys, &mCmtRadio, &mStat, 5, &mTimestamp);
mHmsPayload.enableSerialDebug(mConfig->serial.debug);
mHmsPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
//}
#endif
/*DBGPRINTLN("--- after payload");
DBGPRINTLN(String(ESP.getFreeHeap()));
DBGPRINTLN(String(ESP.getHeapFragmentation()));
DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));*/
//if (!mSys.Radio.isChipConnected())
// DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
if(mConfig->nrf.enabled) {
if (!mSys.Radio.isChipConnected())
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 !defined(AP_ONLY)
@ -371,10 +369,12 @@ void app::tickMidnight(void) {
//-----------------------------------------------------------------------------
void app::tickSend(void) {
/*if(!mNrfRadio.isChipConnected()) {
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
return;
}*/
if(mConfig->nrf.enabled) {
if(!mNrfRadio.isChipConnected()) {
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
return;
}
}
if (mIVCommunicationOn) {
if (!mNrfRadio.mBufCtrl.empty()) {
if (mConfig->serial.debug) {

12
src/app.h

@ -36,11 +36,13 @@
#define ASIN(x) (degrees(asin(x)))
#define ACOS(x) (degrees(acos(x)))
typedef CmtRadio<esp32_3wSpi<>> CmtRadioType;
typedef HmSystem<MAX_NUM_INVERTERS> HmSystemType;
typedef HmPayload<HmSystemType, HmRadio<>> PayloadType;
typedef MiPayload<HmSystemType, HmRadio<>> MiPayloadType;
#ifdef ESP32
typedef CmtRadio<esp32_3wSpi<>> CmtRadioType;
typedef HmsPayload<HmSystemType, CmtRadioType> HmsPayloadType;
#endif
typedef Web<HmSystemType> WebType;
typedef RestApi<HmSystemType, HmRadio<>> RestApiType;
typedef PubMqtt<HmSystemType> PubMqttType;
@ -66,9 +68,11 @@ class app : public IApp, public ah::Scheduler {
mNrfRadio.handleIntr();
}
#ifdef ESP32
void handleHmsIntr(void) {
mCmtRadio.handleIntr();
}
#endif
uint32_t getUptime() {
return Scheduler::getUptime();
@ -299,7 +303,6 @@ class app : public IApp, public ah::Scheduler {
HmSystemType mSys;
HmRadio<> mNrfRadio;
CmtRadioType mCmtRadio;
bool mShowRebootRequest;
bool mIVCommunicationOn;
@ -309,8 +312,11 @@ class app : public IApp, public ah::Scheduler {
RestApiType mApi;
PayloadType mPayload;
MiPayloadType mMiPayload;
HmsPayloadType mHmsPayload;
PubSerialType mPubSerial;
#ifdef ESP32
CmtRadioType mCmtRadio;
HmsPayloadType mHmsPayload;
#endif
char mVersion[12];
settings mSettings;

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 6
#define VERSION_PATCH 9
#define VERSION_PATCH 10
//-------------------------------------
typedef struct {

4
src/main.cpp

@ -14,9 +14,11 @@ IRAM_ATTR void handleIntr(void) {
}
//-----------------------------------------------------------------------------
#ifdef ESP32
IRAM_ATTR void handleHmsIntr(void) {
myApp.handleHmsIntr();
}
#endif
//-----------------------------------------------------------------------------
void setup() {
@ -26,10 +28,12 @@ void setup() {
if(DEF_PIN_OFF != myApp.getNrfIrqPin())
attachInterrupt(digitalPinToInterrupt(myApp.getNrfIrqPin()), handleIntr, FALLING);
}
#ifdef ESP32
if(myApp.getCmtEnabled()) {
if(DEF_PIN_OFF != myApp.getCmtIrqPin())
attachInterrupt(digitalPinToInterrupt(myApp.getCmtIrqPin()), handleHmsIntr, RISING);
}
#endif
}

16
src/web/html/setup.html

@ -21,7 +21,7 @@
<div class="row mb-3">
<div class="col-8 col-sm-3">Dark Mode</div>
<div class="col-4 col-sm-9"><input type="checkbox" name="darkMode"/></div>
<div class="col-8 col-sm-3">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
<div class="col-12">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
</div>
</fieldset>
<fieldset class="mb-4">
@ -33,7 +33,7 @@
<div id="rf24"></div>
<p class="des">Radio (CMT2300A)</p>
<div id="cmt"></div>
<div id="cmt"><div class="col-12">(ESP32 only)</div></div>
<p class="des">Serial Console</p>
<div class="row mb-3">
@ -695,6 +695,16 @@
function parseNrfRadio(obj, type, system) {
var e = document.getElementById("rf24");
var en = inp("nrfEnable", null, null, ["cb"], "nrfEnable", "checkbox");
en.checked = obj["en"];
e.replaceChildren (
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-8 col-sm-3 my-2"}, "NRF24 Enable"),
ml("div", {class: "col-4 col-sm-9"}, en)
])
);
if ("ESP8266" == type) {
pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq']];
} else {
@ -730,7 +740,7 @@
var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox");
en.checked = obj["en"];
e.append(
e.replaceChildren (
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-8 col-sm-3 my-2"}, "CMT2300A Enable"),
ml("div", {class: "col-4 col-sm-9"}, en)

Loading…
Cancel
Save