diff --git a/include/SolarStation.h b/include/SolarStation.h index 018fd35..20dc288 100644 --- a/include/SolarStation.h +++ b/include/SolarStation.h @@ -85,7 +85,6 @@ NeoPixelBus *ledsEsp32 = NULL; /****************** GLOBAL VARS ******************/ // MQTT publish retry until ack received -const int MQTT_PUBLISH_MAX_RETRY = 240; // max retry for MQTT publish int number_of_attemps = 0; bool onStateAckReceived = false; unsigned long onStateNowMillis = 0; @@ -118,7 +117,7 @@ bool waterPumpCutOff = true; bool espCutOff = false; int batteryLevelOnboot = -1; -const int FORCE_DEEP_SLEEP_TIME = 900000; // force deepSleep after 15 minutes +const int FORCE_DEEP_SLEEP_TIME = 3600000; // force deepSleep after 1 hour // variable used for faster delay instead of arduino delay(), this custom delay prevent a lot of problem and memory leak const int TENSECONDSPERIOD = 10000; diff --git a/include/Version.h b/include/Version.h index bdcbaf9..023fca1 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,9 +1,9 @@ // AUTO GENERATED FILE, DO NOT EDIT #ifndef VERSION - #define VERSION "1.12.38" + #define VERSION "1.12.39" #endif #ifndef BUILD_TIMESTAMP - #define BUILD_TIMESTAMP "2024-04-17 10:32:26.764800" + #define BUILD_TIMESTAMP "2024-04-18 20:24:27.606487" #endif \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index b94c512..e3df7c1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -82,7 +82,7 @@ upload_speed = ${common_env_data.upload_speed} board_build.filesystem = littlefs monitor_filters = esp32_exception_decoder ;build_type = debug -monitor_port = COM27 +monitor_port = COM8 ;upload_port = COM27 upload_protocol = espota upload_port = 192.168.1.59 @@ -94,6 +94,7 @@ lib_ldf_mode = deep extra_scripts = post:platformio_version_increment/esp32_create_factory_bin_post.py ${common_env_data.extra_scripts} lib_extra_dirs = ${common_env_data.lib_extra_dirs} +; '-D MAX_RECONNECT=4000' equals to 30 minutes more or less build_flags = -D TARGET_SOLAR_WS '-D ARDUINO_USB_MODE=1' diff --git a/src/SolarStation.cpp b/src/SolarStation.cpp index 387e7dc..debb424 100644 --- a/src/SolarStation.cpp +++ b/src/SolarStation.cpp @@ -73,12 +73,12 @@ void setup() { } void turnOffBuiltInLed() { - ledsEsp32 = new NeoPixelBus(1, OLED_RESET); if (ledsEsp32 == NULL) { - Serial.println(F("OUT OF MEMORY")); - } else { - ledsEsp32->Begin(); - ledsEsp32->Show(); + ledsEsp32 = new NeoPixelBus(1, OLED_RESET); + if (ledsEsp32 == nullptr) { + Serial.println(F("OUT OF MEMORY")); + } + ledsEsp32->Begin(); } ledsEsp32->SetPixelColor(0, {0, 0, 0}); ledsEsp32->Show(); @@ -415,10 +415,10 @@ void espDeepSleep(bool hardCutOff) { // force deepSleep after 15 minutes void forceDeepSleep() { - if((millis() > nowMillisForceDeepSleepStatus + FORCE_DEEP_SLEEP_TIME) || (number_of_attemps >= MQTT_PUBLISH_MAX_RETRY)){ + if(millis() > nowMillisForceDeepSleepStatus + FORCE_DEEP_SLEEP_TIME){ nowMillisForceDeepSleepStatus = millis(); digitalWrite(WATER_PUMP_PIN, LOW); - espDeepSleep(false, false); + espDeepSleep(false, true); } } diff --git a/version b/version index e0330ee..e195257 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.12.38 \ No newline at end of file +1.12.39 \ No newline at end of file