mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-25 20:27:18 +02:00
0.7.51
* fix CMT configureable pins #1150 * fix default CMT pins for opendtufusion * beautified `system` * changed main loops, fix resets #1125, #1135
This commit is contained in:
parent
b06f8e98a4
commit
9521cf756a
9 changed files with 46 additions and 84 deletions
73
src/app.cpp
73
src/app.cpp
|
@ -11,10 +11,7 @@
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
app::app()
|
||||
: ah::Scheduler {},
|
||||
mInnerLoopCb {nullptr} {
|
||||
}
|
||||
app::app() : ah::Scheduler {} {}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -55,14 +52,6 @@ void app::setup() {
|
|||
DSERIAL.flush();
|
||||
#endif // ETHERNET
|
||||
|
||||
#if !defined(ETHERNET)
|
||||
#if defined(AP_ONLY)
|
||||
mInnerLoopCb = std::bind(&app::loopStandard, this);
|
||||
#else
|
||||
mInnerLoopCb = std::bind(&app::loopWifi, this);
|
||||
#endif
|
||||
#endif /* !defined(ETHERNET) */
|
||||
|
||||
#if !defined(ETHERNET)
|
||||
mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onNetwork, this, std::placeholders::_1));
|
||||
#if !defined(AP_ONLY)
|
||||
|
@ -128,14 +117,6 @@ void app::setup() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::loop(void) {
|
||||
if (mInnerLoopCb)
|
||||
mInnerLoopCb();
|
||||
#if !defined(ETHERNET)
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::loopStandard(void) {
|
||||
ah::Scheduler::loop();
|
||||
|
||||
if (mNrfRadio.loop() && mConfig->nrf.enabled) {
|
||||
|
@ -198,47 +179,29 @@ void app::loopStandard(void) {
|
|||
mHmsPayload.loop();
|
||||
#endif
|
||||
|
||||
if (mMqttEnabled)
|
||||
if (mMqttEnabled && mNetworkConnected)
|
||||
mMqtt.loop();
|
||||
}
|
||||
|
||||
#if !defined(ETHERNET)
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::loopWifi(void) {
|
||||
ah::Scheduler::loop();
|
||||
yield();
|
||||
}
|
||||
#endif /* !defined(ETHERNET) */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::onNetwork(bool gotIp) {
|
||||
DPRINTLN(DBG_DEBUG, F("onNetwork"));
|
||||
ah::Scheduler::resetTicker();
|
||||
regularTickers(); // reinstall regular tickers
|
||||
if (gotIp) {
|
||||
every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval, "tSend");
|
||||
#if defined(ESP32)
|
||||
if(mConfig->cmt.enabled)
|
||||
everySec(std::bind(&CmtRadioType::tickSecond, &mCmtRadio), "tsCmt");
|
||||
#endif
|
||||
mMqttReconnect = true;
|
||||
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
||||
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
||||
#if !defined(ETHERNET)
|
||||
if (WIFI_AP == WiFi.getMode()) {
|
||||
mMqttEnabled = false;
|
||||
}
|
||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||
#endif /* !defined(ETHERNET) */
|
||||
mInnerLoopCb = [this]() { this->loopStandard(); };
|
||||
} else {
|
||||
#if defined(ETHERNET)
|
||||
mInnerLoopCb = nullptr;
|
||||
#else /* defined(ETHERNET) */
|
||||
mInnerLoopCb = [this]() { this->loopWifi(); };
|
||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||
#endif /* defined(ETHERNET) */
|
||||
mNetworkConnected = gotIp;
|
||||
every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval, "tSend");
|
||||
#if defined(ESP32)
|
||||
if(mConfig->cmt.enabled)
|
||||
everySec(std::bind(&CmtRadioType::tickSecond, &mCmtRadio), "tsCmt");
|
||||
#endif
|
||||
mMqttReconnect = true;
|
||||
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
|
||||
//once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
|
||||
tickNtpUpdate();
|
||||
#if !defined(ETHERNET)
|
||||
if (WIFI_AP == WiFi.getMode()) {
|
||||
mMqttEnabled = false;
|
||||
}
|
||||
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
|
||||
#endif /* !defined(ETHERNET) */
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -560,6 +523,8 @@ void app::resetSystem(void) {
|
|||
mSavePending = false;
|
||||
mSaveReboot = false;
|
||||
|
||||
mNetworkConnected = false;
|
||||
|
||||
memset(&mStat, 0, sizeof(statistics_t));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue