diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 99bd3ccb..3509821c 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -2383,6 +2383,7 @@ void MyMesh::handleCmdFrame(size_t len) { if (dirty_contacts_expiry) { // is there are pending dirty contacts write needed? saveContacts(); } + savePrefs(); // flush any on-device setting change not yet persisted -- see UITask::shutdown()'s comment board.reboot(); } else if (cmd_frame[0] == CMD_GET_BATT_AND_STORAGE) { uint8_t reply[11]; @@ -3191,6 +3192,7 @@ void MyMesh::checkCLIRescueCmd() { } } else if (strcmp(cli_command, "reboot") == 0) { + savePrefs(); // flush any on-device setting change not yet persisted -- see UITask::shutdown()'s comment board.reboot(); // doesn't return } else { Serial.println(" Error: unknown command"); diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index ccde57d0..3626dbc6 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2012,6 +2012,19 @@ bool UITask::savePrefsIfDirty(bool& dirty) { hardware-agnostic pre-shutdown activity should be done here */ void UITask::shutdown(bool restart){ + // Every screen that edits NodePrefs (Settings, Bot, Trail, Locator, GPS + // sharing, etc.) only persists on its OWN "Cancel"/exit path (see each + // screen's own savePrefsIfDirty(_dirty) call) -- there was previously no + // flush here at all. A user who edits a setting and then triggers a + // reboot/power-off WITHOUT first backing out of that screen (e.g. the + // display auto-offs while still inside Settings, then the device is + // later hard-reset or its battery pulled; or a low-battery auto-shutdown + // fires mid-edit) silently lost that change on the next boot -- this was + // the actual mechanism behind reports of "settings don't survive a + // reboot." Unconditional and cheap: an unchanged NodePrefs still writes + // identical bytes, same as this codebase's many other direct + // the_mesh.savePrefs() call sites already do without a dirty check. + the_mesh.savePrefs(); the_mesh.saveRTCTime(); // Auto-save the live GPS trail before power-off when the user enabled it