Add a lock mechanism to improve the OTA chances of success with ESP32 and BLE (#634)
* Add a lock mechanism to improve the OTA chances of success change TimeBeforeMQTTconnect to InitialMQTTConnectionTimeout move delay(BLEinterval); after the scan so the first scan will always be done at start now remove non relevant delay add stopProcessing and startProcessing functions
This commit is contained in:
1 parent
eb5fff7fba
commit
9bba730e84
4 files changed
+90
-41
No files matched your search
+19
-6
@@ -699,15 +699,30 @@ void setOTA() {
|
||||
ArduinoOTA.setPassword(ota_password);
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
Log.trace(F("Start OTA" CR));
|
||||
Log.trace(F("Start OTA, lock other functions" CR));
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
stopProcessing();
|
||||
# endif
|
||||
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
|
||||
M5Display("OTA in progress", "", "");
|
||||
# endif
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
Log.trace(F("\nEnd OTA" CR));
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
startProcessing();
|
||||
# endif
|
||||
Log.trace(F("\nOTA done" CR));
|
||||
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
|
||||
M5Display("OTA done", "", "");
|
||||
# endif
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Log.trace(F("Progress: %u%%\r" CR), (progress / (total / 100)));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
# if defined(ZgatewayBT) && defined(ESP32)
|
||||
startProcessing();
|
||||
# endif
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
if (error == OTA_AUTH_ERROR)
|
||||
Log.error(F("Auth Failed" CR));
|
||||
@@ -1034,6 +1049,7 @@ void loop() {
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
ArduinoOTA.handle();
|
||||
#else
|
||||
if ((Ethernet.hardwareStatus() != EthernetW5100 && Ethernet.linkStatus() == LinkON) || (Ethernet.hardwareStatus() == EthernetW5100)) { //we are able to detect disconnection only on w5200 and w5500
|
||||
#endif
|
||||
@@ -1048,10 +1064,6 @@ void loop() {
|
||||
|
||||
client.loop();
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ArduinoOTA.handle();
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
||||
if (now > (timer_sys_measures + (TimeBetweenReadingSYS * 1000)) || !timer_sys_measures) {
|
||||
timer_sys_measures = millis();
|
||||
@@ -1228,6 +1240,7 @@ void stateMeasures() {
|
||||
# ifdef ESP32
|
||||
SYSdata["lowpowermode"] = (int)low_power_mode;
|
||||
# endif
|
||||
SYSdata["interval"] = BLEinterval;
|
||||
# endif
|
||||
# ifdef ZgatewayRFM69
|
||||
modules = modules + ZgatewayRFM69;
|
||||
|
||||
Reference in new issue
Block a user