mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-19 09:16:41 +00:00
Updater changes
This commit is contained in:
parent
a5564a4b41
commit
f13312b266
@ -21,7 +21,7 @@ Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include "StringStream.h"
|
||||
//#include "StringStream.h"
|
||||
typedef void (*printfunction)(uint8_t tag, int level, Print *);
|
||||
|
||||
//#include <stdint.h>
|
||||
|
19
src/hasp.cpp
19
src/hasp.cpp
@ -304,8 +304,9 @@ void haspReconnect()
|
||||
lv_obj_set_hidden(obj, true);*/
|
||||
}
|
||||
|
||||
String progress_str((char *)0);
|
||||
// String progress_str((char *)0);
|
||||
|
||||
// Shows/hides the the global progress bar and updates the value
|
||||
void haspProgressVal(uint8_t val)
|
||||
{
|
||||
lv_obj_t * layer = lv_disp_get_layer_sys(NULL);
|
||||
@ -316,8 +317,8 @@ void haspProgressVal(uint8_t val)
|
||||
lv_obj_set_hidden(bar, true);
|
||||
lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, "");
|
||||
#if defined(ARCH_ARDUINO_ESP32) || defined(ARCH_ARDUINO_ESP8266)
|
||||
progress_str.clear();
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
// progress_str.clear();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@ -331,17 +332,23 @@ void haspProgressVal(uint8_t val)
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the value string of the global progress bar
|
||||
void haspProgressMsg(const char * msg)
|
||||
{
|
||||
lv_obj_t * bar = hasp_find_obj_from_id(255, 10);
|
||||
if(bar) {
|
||||
hasp_process_obj_attribute(bar, "value_str", msg, true); // literal string
|
||||
lv_task_handler(); /* let the GUI do its work */
|
||||
|
||||
/* if(bar) {
|
||||
progress_str.reserve(64);
|
||||
progress_str = msg;
|
||||
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, progress_str.c_str());
|
||||
lv_task_handler(); /* let the GUI do its work */
|
||||
}
|
||||
|
||||
lv_task_handler(); // let the GUI do its work
|
||||
} */
|
||||
}
|
||||
|
||||
// Sets the value string of the global progress bar
|
||||
void haspProgressMsg(const __FlashStringHelper * msg)
|
||||
{
|
||||
haspProgressMsg(String(msg).c_str());
|
||||
|
@ -537,6 +537,7 @@ void guiSetup()
|
||||
|
||||
Log.verbose(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
||||
PSTR(LVGL_VERSION_INFO));
|
||||
|
||||
Log.verbose(TAG_LVGL, F("Rotation : %d"), guiRotation);
|
||||
#ifdef LV_MEM_SIZE
|
||||
Log.verbose(TAG_LVGL, F("MEM size : %d"), LV_MEM_SIZE);
|
||||
|
@ -696,7 +696,9 @@ void webHandleFirmwareUpdate()
|
||||
webUploadProgress();
|
||||
}
|
||||
} else if(upload->status == UPLOAD_FILE_END) {
|
||||
haspProgressVal(100);
|
||||
if(Update.end(true)) { // true to set the size to the current progress
|
||||
haspProgressMsg(F("Applying Firmware & Reboot"));
|
||||
webUpdateReboot();
|
||||
} else {
|
||||
webUpdatePrintError();
|
||||
|
@ -60,9 +60,7 @@ void otaSetup()
|
||||
Log.notice(TAG_OTA, F("Start update"));
|
||||
haspProgressVal(0);
|
||||
haspProgressMsg(F("Firmware Update"));
|
||||
// dispatchPage("0");
|
||||
otaPrecentageComplete = 0;
|
||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\"");
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
otaPrecentageComplete = 100;
|
||||
@ -70,33 +68,40 @@ void otaSetup()
|
||||
haspProgressVal(100);
|
||||
otaProgress();
|
||||
otaPrecentageComplete = -1;
|
||||
// dispatchPage("0");
|
||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\\rComplete!\"");
|
||||
setup();
|
||||
// dispatchReboot(true);
|
||||
// setup();
|
||||
dispatchReboot(true);
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
if(total != 0) {
|
||||
otaPrecentageComplete = progress * 100 / total;
|
||||
haspProgressVal(otaPrecentageComplete);
|
||||
}
|
||||
|
||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\\rProgress: " + String(progress / (total / 100)) + "%\"");
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
char buffer[16];
|
||||
switch(error) {
|
||||
case OTA_AUTH_ERROR:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("Auth"));
|
||||
break;
|
||||
case OTA_BEGIN_ERROR:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("Begin"));
|
||||
break;
|
||||
case OTA_CONNECT_ERROR:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("Connect"));
|
||||
break;
|
||||
case OTA_RECEIVE_ERROR:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("Receive"));
|
||||
break;
|
||||
case OTA_END_ERROR:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("End"));
|
||||
break;
|
||||
default:
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("Something"));
|
||||
}
|
||||
|
||||
otaPrecentageComplete = -1;
|
||||
Log.error(TAG_OTA, F("ERROR code %u"), error);
|
||||
if(error == OTA_AUTH_ERROR)
|
||||
Log.error(TAG_OTA, F("ERROR - Auth Failed"));
|
||||
else if(error == OTA_BEGIN_ERROR)
|
||||
Log.error(TAG_OTA, F("ERROR - Begin Failed"));
|
||||
else if(error == OTA_CONNECT_ERROR)
|
||||
Log.error(TAG_OTA, F("ERROR - Connect Failed"));
|
||||
else if(error == OTA_RECEIVE_ERROR)
|
||||
Log.error(TAG_OTA, F("ERROR - Receive Failed"));
|
||||
else if(error == OTA_END_ERROR)
|
||||
Log.error(TAG_OTA, F("ERROR - End Failed"));
|
||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA FAILED\"");
|
||||
Log.error(TAG_OTA, F("ERROR - %s failed (%s)"), buffer, error);
|
||||
haspProgressMsg(F("ESP OTA FAILED"));
|
||||
// delay(5000);
|
||||
// haspSendCmd("page " + String(nextionActivePage));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user