Add OTA error handling

This commit is contained in:
Djuri Baars 2023-11-13 01:02:01 +01:00
parent 3456aceec2
commit f92db527e1
2 changed files with 10 additions and 1 deletions

View File

@ -9,7 +9,7 @@ void setupOTA()
ArduinoOTA.onStart(onOTAStart);
ArduinoOTA.onProgress(onOTAProgress);
ArduinoOTA.onError(onOTAError);
ArduinoOTA.onEnd(onOTAComplete);
ArduinoOTA.setHostname(getMyHostname().c_str());
@ -80,6 +80,14 @@ void downloadUpdate()
{
}
void onOTAError(ota_error_t error) {
Serial.println("\nOTA update error, restarting");
Wire.end();
SPI.end();
delay(1000);
ESP.restart();
}
void onOTAComplete()
{
Serial.println("\nOTA update finished");

View File

@ -8,4 +8,5 @@ void onOTAStart();
void handleOTATask(void *parameter);
void onOTAProgress(unsigned int progress, unsigned int total);
void downloadUpdate();
void onOTAError(ota_error_t error);
void onOTAComplete();