Add OTA error handling
This commit is contained in:
parent
3456aceec2
commit
f92db527e1
2 changed files with 10 additions and 1 deletions
|
@ -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");
|
||||
|
|
|
@ -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();
|
Loading…
Reference in a new issue