Skip to content

Commit

Permalink
FW Update appends message about missing Wifi Expander to persistent log
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Sep 26, 2024
1 parent 8c9f9c3 commit 975d3c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions firmware/src/fw_update/updater_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ bool FirmwareUpdaterProxy::start(std::string_view manifest_filename,
}

FirmwareUpdaterProxy::Status FirmwareUpdaterProxy::process() {
error_message = "";

switch (state) {
case Idle:
case Success:
Expand Down Expand Up @@ -194,8 +196,8 @@ FirmwareUpdaterProxy::Status FirmwareUpdaterProxy::process() {
break;

case FileStorageProxy::WifiExpanderNotConnected:
error_message = "No Wifi Expander: skipping " + manifest.files[current_file_idx].filename;
proceedWithNextFile();
// abortWithMessage("No Wifi expander found.");
break;

default:
Expand Down Expand Up @@ -252,9 +254,7 @@ FirmwareUpdaterProxy::Status FirmwareUpdaterProxy::process() {
abortWithMessage("Internal Error");
}

return state == State::Error ?
Status{state, current_file_name, current_file_size, sharedMem->bytes_processed, error_message} :
Status{state, current_file_name, current_file_size, sharedMem->bytes_processed};
return Status{state, current_file_name, current_file_size, sharedMem->bytes_processed, error_message};
}

void FirmwareUpdaterProxy::abortWithMessage(const char *message) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/fw_update/updater_proxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public:
std::string name;
std::size_t file_size{0};
std::size_t bytes_completed{0};
std::string error_message{};
std::string message{};
};

FirmwareUpdaterProxy(FileStorageProxy &file_storage);
Expand Down
14 changes: 13 additions & 1 deletion firmware/src/gui/pages/firmware_update_tab.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct FirmwareUpdateTab : SystemMenuTab {
display_file_not_found();

confirm_popup.init(ui_SystemMenu, group);
lv_label_set_text(ui_SystemMenuUpdateLog, "");
lv_hide(ui_SystemMenUpdateProgressBar);
}

// Returns true if this pages uses the back event
Expand Down Expand Up @@ -84,8 +86,11 @@ struct FirmwareUpdateTab : SystemMenuTab {
case State::Updating: {
auto status = updater.process();

if (status.state != FirmwareUpdaterProxy::Error && status.message.length())
append_log_message(status.message);

if (status.state == FirmwareUpdaterProxy::Error) {
display_update_failed(status.error_message);
display_update_failed(status.message);
state = State::Failed;

} else if (status.state == FirmwareUpdaterProxy::LoadingUpdateFiles) {
Expand Down Expand Up @@ -204,6 +209,13 @@ private:
lv_hide(ui_SystemMenUpdateProgressBar);
}

void append_log_message(std::string_view message) {
std::string log = lv_label_get_text(ui_SystemMenuUpdateLog);
lv_label_set_text_fmt(ui_SystemMenuUpdateLog, "%s\n%.*s", log.c_str(), (int)message.length(), message.data());
lv_hide(ui_FWUpdateSpinner);
lv_hide(ui_SystemMenUpdateProgressBar);
}

void display_success() {
lv_obj_set_style_text_color(ui_SystemMenuUpdateMessage, lv_palette_lighten(LV_PALETTE_GREEN, 1), LV_PART_MAIN);
lv_label_set_text(ui_SystemMenuUpdateMessage, "Success! Firmware has been updated. Power off and back on now");
Expand Down

0 comments on commit 975d3c5

Please sign in to comment.