Harden USB logging and persist watchdog events in management reports

This commit is contained in:
mikecarper committed 2026-10-03 15:29:19 -07:00
1 parent bd55369aa9
commit 3add4695cc
98 files changed
+7207 -372

No files matched your search

+15
View File
@@ -1002,6 +1002,9 @@ bool DataStore::loadPrefsInt(const char *filename,
// Files written before this tail existed always started Bluetooth at boot.
// Do not inherit a runtime off value when loading one of those images.
loaded_prefs.bluetooth_enabled = 1;
// Older images have no independent debug preference. Never inherit a
// runtime-on value when loading one of those images.
loaded_prefs.usb_debug_enabled = 0;
double loaded_lat = node_lat;
double loaded_lon = node_lon;
// The original image ended after ble_pin at byte 84. Later releases only
@@ -1056,6 +1059,13 @@ bool DataStore::loadPrefsInt(const char *filename,
329,
#else
232,
#endif
#ifdef TBEAM_1W
240, // Independent USB debug preference, after the existing tail
#elif defined(RP2040_PLATFORM) && defined(ENABLE_WIFI_INTERFACE)
330,
#else
233,
#endif
};
const uint32_t prefs_size = file.size();
@@ -1200,6 +1210,8 @@ bool DataStore::loadPrefsInt(const char *filename,
sizeof(loaded_prefs.one_key_dm_enabled));
readOptionalField(&loaded_prefs.bluetooth_enabled,
sizeof(loaded_prefs.bluetooth_enabled));
readOptionalField(&loaded_prefs.usb_debug_enabled,
sizeof(loaded_prefs.usb_debug_enabled));
// Any bytes left over form only part of a historically appended field.
// Preserve the file and defaults rather than treating that tail as EOF.
@@ -1207,6 +1219,7 @@ bool DataStore::loadPrefsInt(const char *filename,
success = success && loaded_prefs.bluetooth_enabled <= 1;
file.close();
if (!success) return false;
loaded_prefs.usb_debug_enabled = loaded_prefs.usb_debug_enabled == 1 ? 1 : 0;
_prefs = loaded_prefs;
node_lat = loaded_lat;
node_lon = loaded_lon;
@@ -1363,6 +1376,8 @@ bool DataStore::savePrefs(const CompanionNodePrefs& _prefs, double node_lat, dou
sizeof(_prefs.one_key_dm_enabled)) == sizeof(_prefs.one_key_dm_enabled);
success = success && file.write((uint8_t *)&_prefs.bluetooth_enabled,
sizeof(_prefs.bluetooth_enabled)) == sizeof(_prefs.bluetooth_enabled);
success = success && file.write((uint8_t *)&_prefs.usb_debug_enabled,
sizeof(_prefs.usb_debug_enabled)) == sizeof(_prefs.usb_debug_enabled);
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) || defined(ESP32_PLATFORM) || defined(RP2040_PLATFORM)
success = file.commit(success);