Remote update progress

This commit is contained in:
2023-11-28 19:09:05 +05:30
parent 21beb90a76
commit 427c202567
4 changed files with 29 additions and 23 deletions
Binary file not shown.
+3 -3
View File
@@ -1,9 +1,9 @@
#ifndef BUILD_NUMBER #ifndef BUILD_NUMBER
#define BUILD_NUMBER 47 #define BUILD_NUMBER 48
#endif #endif
#ifndef VERSION #ifndef VERSION
#define VERSION "v0.1.47 - 2023-11-28 18:50:16.207931" #define VERSION "v0.1.48 - 2023-11-28 19:08:40.189843"
#endif #endif
#ifndef VERSION_SHORT #ifndef VERSION_SHORT
#define VERSION_SHORT "v0.1.47" #define VERSION_SHORT "v0.1.48"
#endif #endif
+23 -17
View File
@@ -34,7 +34,7 @@ void setupOTALocal() {
showInsideInfo("LU:Restarting.."); showInsideInfo("LU:Restarting..");
}); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress:%u%%\r", (progress / (total / 100))); Serial.printf("LU: Progress:%u%%\r", (progress / (total / 100)));
{ {
char infoBuffer[LCD_COLUMNS]; char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "LU:P:%u%%", (progress / (total / 100))); sprintf(infoBuffer, "LU:P:%u%%", (progress / (total / 100)));
@@ -73,22 +73,28 @@ void handleOTALocal() {
void handleOTARemote() { void handleOTARemote() {
WiFiClient client; WiFiClient client;
Serial.println("Updating from remote..."); ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);
showInsideInfo("RU:Start"); ESPhttpUpdate.onStart([]() {
t_httpUpdate_return ret = ESPhttpUpdate.update(client, "http://patient.bendtherules.in/build/esp12e/firmware.bin", VERSION_SHORT); Serial.println("RU: Started");
switch(ret) { showInsideInfo("RU:Started");
case HTTP_UPDATE_FAILED: });
Serial.print("update:Update failed. Reason - "); ESPhttpUpdate.onEnd([]() {
Serial.println("RU: Finished. Restarting..");
showInsideInfo("RU:Restarting..");
});
ESPhttpUpdate.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("RU: Progress:%u%%\r", (progress / (total / 100)));
{
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "RU:P:%u%%", (progress / (total / 100)));
showInsideInfo(infoBuffer);
}
});
ESPhttpUpdate.onError([](int err) {
Serial.printf("RU: Failed with code %d\n", err);
Serial.println(ESPhttpUpdate.getLastErrorString()); Serial.println(ESPhttpUpdate.getLastErrorString());
showInsideInfo("RU:Failed"); showInsideInfo("RU:Failed");
break; });
case HTTP_UPDATE_NO_UPDATES:
Serial.println("update:Update no Update."); t_httpUpdate_return ret = ESPhttpUpdate.update(client, "http://patient.bendtherules.in/build/esp12e/firmware.bin");
showInsideInfo("RU:Skip");
break;
case HTTP_UPDATE_OK:
Serial.println("update:Update ok."); // may not be called since we reboot the ESP
showInsideInfo("RU:Done");
break;
}
} }
+1 -1
View File
@@ -1 +1 @@
47 48