mode cleanup
This commit is contained in:
parent
b0829cba6b
commit
01e2839f30
@ -47,7 +47,6 @@ RTC_DATA_ATTR long lastWaterValue = 0;
|
||||
|
||||
|
||||
bool warmBoot = true;
|
||||
bool mode2Active = false;
|
||||
bool mode3Active = false; /**< Controller must not sleep */
|
||||
|
||||
|
||||
@ -318,7 +317,7 @@ void onHomieEvent(const HomieEvent& event) {
|
||||
|
||||
//wait for rtc sync?
|
||||
rtcDeepSleepTime = deepSleepTime.get();
|
||||
if(mode2Active){
|
||||
if(!mode3Active){
|
||||
mode2MQTT();
|
||||
}
|
||||
Homie.getLogger() << "MQTT connected, preparing for deep sleep after 100ms..." << endl;
|
||||
@ -599,14 +598,12 @@ bool mode1(){
|
||||
|
||||
void mode2(){
|
||||
Serial.println("Init mode 2");
|
||||
mode2Active = true;
|
||||
|
||||
systemInit();
|
||||
|
||||
/* Jump into Mode 3, if not configured */
|
||||
if (!mConfigured) {
|
||||
Serial.println("upgrade to mode 3");
|
||||
mode2Active = false;
|
||||
mode3Active = true;
|
||||
}
|
||||
}
|
||||
@ -672,21 +669,7 @@ void setup() {
|
||||
esp_sleep_enable_timer_wakeup(sleepEmptyLipo * 1000U);
|
||||
mDeepSleep = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cyclic call
|
||||
* Executs the Homie base functionallity or triggers sleeping, if requested.
|
||||
*/
|
||||
|
||||
void loop() {
|
||||
/* Perform the active modes (non mode1) */
|
||||
if (mode3Active || mode2Active) {
|
||||
Homie.loop();
|
||||
} else {
|
||||
/* Check which mode shall be selected */
|
||||
if(warmBoot){
|
||||
warmBoot = false;
|
||||
if(mode1()){
|
||||
mode2();
|
||||
} else {
|
||||
@ -695,7 +678,14 @@ void loop() {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cyclic call
|
||||
* Executs the Homie base functionallity or triggers sleeping, if requested.
|
||||
*/
|
||||
|
||||
void loop() {
|
||||
Homie.loop();
|
||||
|
||||
if(millis() > 30000 && !mode3Active){
|
||||
Serial << (millis()/ 1000) << "s running; going to suicide ..." << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user