fix(ui): force immediate refresh when BLE disconnects

UITask.onBLEDisconnected() sets _next_refresh=0 so the BLE icon
updates instantly instead of waiting for the next polling cycle.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-12 12:59:41 +02:00
parent a1fc67ed96
commit ec4b7d625f
2 changed files with 7 additions and 1 deletions

View File

@@ -34,8 +34,13 @@ protected:
}
public:
void setHasConnection(bool connected) { _connected = connected; }
void setHasConnection(bool connected) {
bool prev = _connected;
_connected = connected;
if (prev && !connected) onBLEDisconnected();
}
bool hasConnection() const { return _connected; }
virtual void onBLEDisconnected() {}
// True only when a BLE central is actually bonded/connected. On a dual
// (BLE+USB) interface hasConnection() is always true (USB counts), so use
// this for BLE-specific UI like the pairing-PIN prompt.

View File

@@ -132,6 +132,7 @@ public:
curr = NULL;
}
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
void onBLEDisconnected() override { _next_refresh = 0; }
NodePrefs* getNodePrefs() const { return _node_prefs; }
uint16_t getBattMilliVolts() const { return _batt_mv > 0 ? _batt_mv : AbstractUITask::getBattMilliVolts(); }