Disable pumps while OTA running, mode2 is called only once

This commit is contained in:
c3ma 2020-10-28 20:31:18 +01:00
parent 58e3e3c652
commit 8657eedc43
2 changed files with 10 additions and 5 deletions

View File

@ -11,7 +11,7 @@
#ifndef CONTROLLER_CONFIG_H #ifndef CONTROLLER_CONFIG_H
#define 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(adc) ((adc) * 3.3 ) / 4095)
#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095) #define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc) * 3.3 * (multi)) / 4095)

View File

@ -371,18 +371,17 @@ void readSensors() {
void onHomieEvent(const HomieEvent& event) { void onHomieEvent(const HomieEvent& event) {
switch(event.type) { switch(event.type) {
case HomieEventType::SENDING_STATISTICS: case HomieEventType::SENDING_STATISTICS:
mode2MQTT();
Homie.getLogger() << "My statistics" << endl; Homie.getLogger() << "My statistics" << endl;
break; break;
case HomieEventType::MQTT_READY: case HomieEventType::MQTT_READY:
//wait for rtc sync? //wait for rtc sync?
rtcDeepSleepTime = deepSleepTime.get(); rtcDeepSleepTime = deepSleepTime.get();
Serial << rtcDeepSleepTime << " ms ds" << endl; Serial << "MQTT ready " << rtcDeepSleepTime << " ms ds" << endl;
mode2MQTT();
Homie.getLogger() << "MQTT 1" << endl;
for(int i=0; i < MAX_PLANTS; i++) { for(int i=0; i < MAX_PLANTS; i++) {
mPlants[i].postMQTTconnection(); mPlants[i].postMQTTconnection();
} }
mode2MQTT();
break; break;
case HomieEventType::READY_TO_SLEEP: case HomieEventType::READY_TO_SLEEP:
Homie.getLogger() << "rtsleep" << endl; Homie.getLogger() << "rtsleep" << endl;
@ -391,11 +390,17 @@ void onHomieEvent(const HomieEvent& event) {
case HomieEventType::OTA_STARTED: case HomieEventType::OTA_STARTED:
digitalWrite(OUTPUT_SENSOR, HIGH); digitalWrite(OUTPUT_SENSOR, HIGH);
digitalWrite(OUTPUT_PUMP, LOW); 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; mode3Active=true;
break; break;
case HomieEventType::OTA_SUCCESSFUL: case HomieEventType::OTA_SUCCESSFUL:
digitalWrite(OUTPUT_SENSOR, LOW); digitalWrite(OUTPUT_SENSOR, LOW);
digitalWrite(OUTPUT_PUMP, LOW); digitalWrite(OUTPUT_PUMP, LOW);
ESP.restart();
break; break;
default: default:
break; break;