From 8657eedc43181e7733d748230c423aa1ce981321 Mon Sep 17 00:00:00 2001 From: c3ma Date: Wed, 28 Oct 2020 20:31:18 +0100 Subject: [PATCH] Disable pumps while OTA running, mode2 is called only once --- esp32/include/ControllerConfiguration.h | 2 +- esp32/src/main.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index fd1a946..7cb273b 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -11,7 +11,7 @@ #ifndef CONTROLLER_CONFIG_H #define CONTROLLER_CONFIG_H -#define FIRMWARE_VERSION "1.0.5" +#define FIRMWARE_VERSION "1.0.6" #define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095) #define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095) diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 5c9c487..c51d289 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -371,18 +371,17 @@ void readSensors() { void onHomieEvent(const HomieEvent& event) { switch(event.type) { case HomieEventType::SENDING_STATISTICS: - mode2MQTT(); Homie.getLogger() << "My statistics" << endl; break; case HomieEventType::MQTT_READY: //wait for rtc sync? rtcDeepSleepTime = deepSleepTime.get(); - Serial << rtcDeepSleepTime << " ms ds" << endl; - mode2MQTT(); - Homie.getLogger() << "MQTT 1" << endl; + Serial << "MQTT ready " << rtcDeepSleepTime << " ms ds" << endl; for(int i=0; i < MAX_PLANTS; i++) { mPlants[i].postMQTTconnection(); } + + mode2MQTT(); break; case HomieEventType::READY_TO_SLEEP: Homie.getLogger() << "rtsleep" << endl; @@ -391,11 +390,17 @@ void onHomieEvent(const HomieEvent& event) { case HomieEventType::OTA_STARTED: digitalWrite(OUTPUT_SENSOR, HIGH); digitalWrite(OUTPUT_PUMP, LOW); + gpio_hold_dis(GPIO_NUM_13); //pump pwr + gpio_deep_sleep_hold_dis(); + for (int i=0; i < MAX_PLANTS; i++) { + mPlants[i].deactivatePump(); + } mode3Active=true; break; case HomieEventType::OTA_SUCCESSFUL: digitalWrite(OUTPUT_SENSOR, LOW); digitalWrite(OUTPUT_PUMP, LOW); + ESP.restart(); break; default: break;