diff --git a/src/app.cpp b/src/app.cpp index 06a1c264..a7a12ae8 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -60,9 +60,13 @@ void app::setup() { #endif /* defined(ETHERNET) */ mSys.setup(&mTimestamp, &mConfig->inst); - Inverter<> *iv; for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - mSys.addInverter(i); + mSys.addInverter(i, [this](Inverter<> *iv) { + if((IV_MI == iv->ivGen) || (IV_HM == iv->ivGen)) + iv->radio = &mNrfRadio; + else if((IV_HMS == iv->ivGen) || (IV_HMT == iv->ivGen)) + iv->radio = &mCmtRadio; + }); } if (mConfig->nrf.enabled) { mPayload.setup(this, &mSys, &mNrfRadio, &mNrfStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); diff --git a/src/hm/hmSystem.h b/src/hm/hmSystem.h index 6a4666a3..6c6faef6 100644 --- a/src/hm/hmSystem.h +++ b/src/hm/hmSystem.h @@ -20,7 +20,7 @@ class HmSystem { mNumInv = 0; } - void addInverter(uint8_t id) { + void addInverter(uint8_t id, std::function<void(Inverter<> *iv)> cb) { DPRINTLN(DBG_VERBOSE, F("hmSystem.h:addInverter")); if(MAX_INVERTER <= mNumInv) { DPRINT(DBG_WARN, F("max number of inverters reached!")); @@ -89,6 +89,8 @@ class HmSystem { if((iv->config->serial.b[5] == 0x10) && ((iv->config->serial.b[4] & 0x03) == 0x01)) DPRINTLN(DBG_WARN, F("MI Inverter are not fully supported now!!!")); + + cb(iv); } INVERTERTYPE *findInverter(uint8_t buf[]) {