Small clean-up of OTA
Researching potential use of rollback of OTA.
This commit is contained in:
parent
db3bea3b5c
commit
3336ac7fbe
|
|
@ -44,6 +44,7 @@ using namespace Utils;
|
||||||
HAPClient **hap; // HAP Client structure containing HTTP client connections, parsing routines, and state variables (global-scoped variable)
|
HAPClient **hap; // HAP Client structure containing HTTP client connections, parsing routines, and state variables (global-scoped variable)
|
||||||
Span homeSpan; // HAP Attributes database and all related control functions for this Accessory (global-scoped variable)
|
Span homeSpan; // HAP Attributes database and all related control functions for this Accessory (global-scoped variable)
|
||||||
HapCharacteristics hapChars; // Instantiation of all HAP Characteristics (used to create SpanCharacteristics)
|
HapCharacteristics hapChars; // Instantiation of all HAP Characteristics (used to create SpanCharacteristics)
|
||||||
|
int otaPercent;
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Span //
|
// Span //
|
||||||
|
|
@ -134,7 +135,9 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa
|
||||||
Serial.print(__DATE__);
|
Serial.print(__DATE__);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.print(__TIME__);
|
Serial.print(__TIME__);
|
||||||
|
|
||||||
|
Serial.printf("\nOTA Partition: %s",otaEnabled?esp_ota_get_running_partition()->label:"N/A");
|
||||||
|
|
||||||
Serial.print("\n\nDevice Name: ");
|
Serial.print("\n\nDevice Name: ");
|
||||||
Serial.print(displayName);
|
Serial.print(displayName);
|
||||||
Serial.print("\n\n");
|
Serial.print("\n\n");
|
||||||
|
|
@ -526,20 +529,21 @@ void Span::checkConnect(){
|
||||||
|
|
||||||
ArduinoOTA
|
ArduinoOTA
|
||||||
.onStart([]() {
|
.onStart([]() {
|
||||||
String type;
|
Serial.printf("\n*** Current Partition: %s\n*** New Partition: %s\n*** OTA Starting..",
|
||||||
if (ArduinoOTA.getCommand() == U_FLASH)
|
esp_ota_get_running_partition()->label,esp_ota_get_next_update_partition(NULL)->label);
|
||||||
type = "sketch";
|
otaPercent=-10;
|
||||||
else // U_SPIFFS
|
|
||||||
type = "filesystem";
|
|
||||||
Serial.println("\n*** OTA Starting:" + type);
|
|
||||||
homeSpan.statusLED.start(LED_OTA_STARTED);
|
homeSpan.statusLED.start(LED_OTA_STARTED);
|
||||||
})
|
})
|
||||||
.onEnd([]() {
|
.onEnd([]() {
|
||||||
Serial.println("\n*** OTA Completed. Rebooting...");
|
Serial.printf(" DONE! Rebooting...\n");
|
||||||
homeSpan.statusLED.off();
|
homeSpan.statusLED.off();
|
||||||
})
|
})
|
||||||
.onProgress([](unsigned int progress, unsigned int total) {
|
.onProgress([](unsigned int progress, unsigned int total) {
|
||||||
Serial.printf("*** Progress: %u%%\r", (progress / (total / 100)));
|
int percent=progress*100/total;
|
||||||
|
if(percent/10 != otaPercent/10){
|
||||||
|
otaPercent=percent;
|
||||||
|
Serial.printf("%d%%..",progress*100/total);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.onError([](ota_error_t error) {
|
.onError([](ota_error_t error) {
|
||||||
Serial.printf("*** OTA Error[%u]: ", error);
|
Serial.printf("*** OTA Error[%u]: ", error);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ void setup() {
|
||||||
// homeSpan.setMaxConnections(6);
|
// homeSpan.setMaxConnections(6);
|
||||||
// homeSpan.setQRID("One1");
|
// homeSpan.setQRID("One1");
|
||||||
// homeSpan.enableOTA();
|
// homeSpan.enableOTA();
|
||||||
homeSpan.setSketchVersion("Test 1.3.1");
|
homeSpan.setSketchVersion("OTA Test 5");
|
||||||
homeSpan.setWifiCallback(wifiEstablished);
|
homeSpan.setWifiCallback(wifiEstablished);
|
||||||
|
|
||||||
new SpanUserCommand('d',"- My Description",userCom1);
|
new SpanUserCommand('d',"- My Description",userCom1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue