fix: Bluetooth switched off stays off over a reboot or hibernate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-06 14:09:22 +02:00
co-authored by Claude Opus 5.5
parent 50d0d5577b
commit 5a92d36509
5 changed files with 15 additions and 3 deletions
+2 -2
View File
@@ -64,8 +64,8 @@ public:
bool isClientConnected() const { return _serial->isClientConnected(); }
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
bool isSerialEnabled() const { return _serial->isEnabled(); }
void enableSerial() { _serial->enable(); }
void disableSerial() { _serial->disable(); }
void enableSerial() { _serial->enable(); the_mesh.rememberBle(true); }
void disableSerial() { _serial->disable(); the_mesh.rememberBle(false); }
virtual void notify(UIEventType t = UIEventType::none) = 0;
// Single choke point for every controlled power-down (low-battery auto-off,
// long-press power-off, and every board.reboot() caller too): flush
+1
View File
@@ -332,6 +332,7 @@ static void sanitize(NodePrefs& p) {
if (p.quiet_to > 23) p.quiet_to = 7;
if (!battery::validCurve(p.batt_curve_mv)) memset(p.batt_curve_mv, 0, sizeof(p.batt_curve_mv));
flag(p.lock_compact, 0);
flag(p.ble_off, 0);
}
// The settings a firmware before 2.0 kept in /new_prefs that still matter
+1 -1
View File
@@ -2047,7 +2047,7 @@ bool MyMesh::isValidClientRepeatFreq(uint32_t f) const {
void MyMesh::startInterface(BaseSerialInterface &serial) {
_serial = &serial;
serial.enable();
if (!_prefs.ble_off) serial.enable();
}
static bool isAllZero(const uint8_t* buf, size_t n) {
+6
View File
@@ -414,6 +414,12 @@ public:
}
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
// Bluetooth on/off as the user left it (NodePrefs::ble_off), kept over reboots.
void rememberBle(bool on) {
if (_prefs.ble_off == (on ? 0 : 1)) return;
_prefs.ble_off = on ? 0 : 1;
savePrefs();
}
void saveRTCTime() { _store->saveRTCTime(); }
// Contact updates (new adverts, path/lastmod changes) are lazily debounced
// (see dirty_contacts_expiry) to avoid wearing flash on every packet --
+5
View File
@@ -520,6 +520,11 @@ struct NodePrefs { // persisted to file
// clock fields as rows below. The L2 has its own lock screen.
uint8_t lock_compact;
// ── Bluetooth ──────────────────────────────────────────────────────────
// 1 = the user switched Bluetooth off: it stays off after a reboot or
// hibernate (MyMesh::startInterface). USB keeps working either way.
uint8_t ble_off;
// Single source of truth for the live-share option tables (shared by the Map
// UI labels and the auto-send engine in UITask).
static const uint8_t LOC_SHARE_MOVE_COUNT = 4;