| 
						
						
							
								
							
						
						
					 | 
					@ -47,38 +47,38 @@ void app::setup() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    #endif | 
					 | 
					 | 
					    #endif | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    #ifdef ETHERNET | 
					 | 
					 | 
					    #ifdef ETHERNET | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    delay(1000); | 
					 | 
					 | 
					        delay(1000); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    DPRINT(DBG_INFO, F("mEth setup...")); | 
					 | 
					 | 
					        DPRINT(DBG_INFO, F("mEth setup...")); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    DSERIAL.flush(); | 
					 | 
					 | 
					        DSERIAL.flush(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mEth.setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); }); | 
					 | 
					 | 
					        mEth.setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); }); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    DBGPRINTLN(F("done...")); | 
					 | 
					 | 
					        DBGPRINTLN(F("done...")); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    DSERIAL.flush(); | 
					 | 
					 | 
					        DSERIAL.flush(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    #endif // ETHERNET
 | 
					 | 
					 | 
					    #endif // ETHERNET
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    #if !defined(ETHERNET) | 
					 | 
					 | 
					    #if !defined(ETHERNET) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    #if defined(AP_ONLY) | 
					 | 
					 | 
					        #if defined(AP_ONLY) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mInnerLoopCb = std::bind(&app::loopStandard, this); | 
					 | 
					 | 
					            mInnerLoopCb = std::bind(&app::loopStandard, this); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    #else | 
					 | 
					 | 
					        #else | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mInnerLoopCb = std::bind(&app::loopWifi, this); | 
					 | 
					 | 
					            mInnerLoopCb = std::bind(&app::loopWifi, this); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    #endif | 
					 | 
					 | 
					        #endif | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    #endif /* !defined(ETHERNET) */ | 
					 | 
					 | 
					    #endif /* !defined(ETHERNET) */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					#if !defined(ETHERNET) | 
					 | 
					 | 
					    #if !defined(ETHERNET) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onNetwork, this, std::placeholders::_1)); | 
					 | 
					 | 
					        mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onNetwork, this, std::placeholders::_1)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    #if !defined(AP_ONLY) | 
					 | 
					 | 
					        #if !defined(AP_ONLY) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); | 
					 | 
					 | 
					            everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    #endif | 
					 | 
					 | 
					        #endif | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					#endif /* defined(ETHERNET) */ | 
					 | 
					 | 
					    #endif /* defined(ETHERNET) */ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    mSys.setup(&mTimestamp); | 
					 | 
					 | 
					    mSys.setup(&mTimestamp); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    mSys.addInverters(&mConfig->inst); | 
					 | 
					 | 
					    mSys.addInverters(&mConfig->inst); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    if(mConfig->nrf.enabled) { | 
					 | 
					 | 
					    if (mConfig->nrf.enabled) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        mPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); | 
					 | 
					 | 
					        mPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mPayload.enableSerialDebug(mConfig->serial.debug); | 
					 | 
					 | 
					        mPayload.enableSerialDebug(mConfig->serial.debug); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        mPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); | 
					 | 
					 | 
					        mPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        mMiPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); | 
					 | 
					 | 
					        mMiPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    mMiPayload.enableSerialDebug(mConfig->serial.debug); | 
					 | 
					 | 
					        mMiPayload.enableSerialDebug(mConfig->serial.debug); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); | 
					 | 
					 | 
					        mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -90,7 +90,7 @@ void app::setup() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if(mConfig->nrf.enabled) { | 
					 | 
					 | 
					    if(mConfig->nrf.enabled) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (!mNrfRadio.isChipConnected()) | 
					 | 
					 | 
					        if (!mNrfRadio.isChipConnected()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring")); | 
					 | 
					 | 
					            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
 | 
					 | 
					 | 
					    // when WiFi is in client mode, then enable mqtt broker
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -228,12 +228,12 @@ void app::onNetwork(bool gotIp) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        #endif /* !defined(ETHERNET) */ | 
					 | 
					 | 
					        #endif /* !defined(ETHERNET) */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        mInnerLoopCb = [this]() { this->loopStandard(); }; | 
					 | 
					 | 
					        mInnerLoopCb = [this]() { this->loopStandard(); }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } else { | 
					 | 
					 | 
					    } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					#if defined(ETHERNET) | 
					 | 
					 | 
					        #if defined(ETHERNET) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        mInnerLoopCb = nullptr; | 
					 | 
					 | 
					                mInnerLoopCb = nullptr; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					#else /* defined(ETHERNET) */ | 
					 | 
					 | 
					        #else /* defined(ETHERNET) */ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        mInnerLoopCb = [this]() { this->loopWifi(); }; | 
					 | 
					 | 
					                mInnerLoopCb = [this]() { this->loopWifi(); }; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); | 
					 | 
					 | 
					                everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					#endif /* defined(ETHERNET) */ | 
					 | 
					 | 
					        #endif /* defined(ETHERNET) */ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -370,14 +370,14 @@ void app::tickComm(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void app::tickZeroValues(void) { | 
					 | 
					 | 
					void app::tickZeroValues(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    zeroIvValues(!CHECK_AVAIL, SKIP_YIELD_DAY); | 
					 | 
					 | 
					    zeroIvValues(!CHECK_AVAIL, SKIP_YIELD_DAY); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    } | 
					 | 
					 | 
					} | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void app::tickMinute(void) { | 
					 | 
					 | 
					void app::tickMinute(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    // only triggered if 'reset values on no avail is enabled'
 | 
					 | 
					 | 
					    // only triggered if 'reset values on no avail is enabled'
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    zeroIvValues(CHECK_AVAIL, SKIP_YIELD_DAY); | 
					 | 
					 | 
					    zeroIvValues(CHECK_AVAIL, SKIP_YIELD_DAY); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        } | 
					 | 
					 | 
					} | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
					 | 
					 | 
					//-----------------------------------------------------------------------------
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void app::tickMidnight(void) { | 
					 | 
					 | 
					void app::tickMidnight(void) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -396,9 +396,9 @@ void app::tickMidnight(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void app::tickSend(void) { | 
					 | 
					 | 
					void app::tickSend(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if(mConfig->nrf.enabled) { | 
					 | 
					 | 
					    if(mConfig->nrf.enabled) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if(!mNrfRadio.isChipConnected()) { | 
					 | 
					 | 
					        if(!mNrfRadio.isChipConnected()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        DPRINTLN(DBG_WARN, F("NRF24 not connected!")); | 
					 | 
					 | 
					            DPRINTLN(DBG_WARN, F("NRF24 not connected!")); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        return; | 
					 | 
					 | 
					            return; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    } | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if (mIVCommunicationOn) { | 
					 | 
					 | 
					    if (mIVCommunicationOn) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (!mNrfRadio.mBufCtrl.empty()) { | 
					 | 
					 | 
					        if (!mNrfRadio.mBufCtrl.empty()) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -428,15 +428,15 @@ void app::tickSend(void) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                if(mConfig->nrf.enabled) { | 
					 | 
					 | 
					                if(mConfig->nrf.enabled) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                if (iv->ivGen == IV_HM) | 
					 | 
					 | 
					                if (iv->ivGen == IV_HM) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    mPayload.ivSend(iv); | 
					 | 
					 | 
					                    mPayload.ivSend(iv); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    else if(iv->ivGen == IV_MI) | 
					 | 
					 | 
					                else if(iv->ivGen == IV_MI) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    mMiPayload.ivSend(iv); | 
					 | 
					 | 
					                    mMiPayload.ivSend(iv); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                #if defined(ESP32) | 
					 | 
					 | 
					            #if defined(ESP32) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                if(mConfig->cmt.enabled) { | 
					 | 
					 | 
					            if(mConfig->cmt.enabled) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    if((iv->ivGen == IV_HMS) || (iv->ivGen == IV_HMT)) | 
					 | 
					 | 
					                if((iv->ivGen == IV_HMS) || (iv->ivGen == IV_HMT)) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                        mHmsPayload.ivSend(iv); | 
					 | 
					 | 
					                    mHmsPayload.ivSend(iv); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        } | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                #endif | 
					 | 
					 | 
					            #endif | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } else { | 
					 | 
					 | 
					    } else { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |