Skip to content

Commit 61e11e5

Browse files
committed
renamed upload_progress to ota_progress
added ota event pushed on ota start / end ( throw "started", "completed", "failed" )
1 parent e53aea7 commit 61e11e5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/http_update.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ bool http_update_start(String source, size_t total)
7979

8080
lcd.display(F("Updating WiFi"), 0, 0, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
8181
lcd.display(F(""), 0, 1, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
82-
82+
StaticJsonDocument<128> event;
83+
event["ota"] = "started";
84+
web_server_event(event);
8385
return true;
8486
}
8587

@@ -112,9 +114,9 @@ bool http_update_write(uint8_t *data, size_t len)
112114
DEBUG_PORT.printf("Update: %d%%\n", percent);
113115

114116
StaticJsonDocument<128> event;
115-
event["upload_progress"] = percent;
117+
event["ota_progress"] = percent;
116118
web_server_event(event);
117-
119+
yield();
118120
lastPercent = percent;
119121
}
120122
}
@@ -132,9 +134,17 @@ bool http_update_end()
132134
{
133135
DBUGF("Update Success: %u", update_position);
134136
lcd.display(F("Complete"), 0, 1, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
137+
StaticJsonDocument<128> event;
138+
event["ota"] = "completed";
139+
web_server_event(event);
140+
yield();
135141
return true;
136142
} else {
137143
DBUGF("Update failed: %d", Update.getError());
144+
StaticJsonDocument<128> event;
145+
event["ota"] = "failed";
146+
web_server_event(event);
147+
yield();
138148
lcd.display(F("Error"), 0, 1, 10 * 1000, LCD_CLEAR_LINE | LCD_DISPLAY_NOW);
139149
}
140150

0 commit comments

Comments
 (0)