mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 18:26:11 +00:00
fix(ble): show pairing PIN on dual (BLE+USB) builds
The Bluetooth-page PIN prompt was gated on hasConnection(), which is fed by the serial interface's isConnected(). DualSerialInterface::isConnected() always returns true (USB always "connected"), so waiting_for_pair was always false and the PIN was never drawn — on every dual build, i.e. the published OLED + e-ink firmware. Pure-BLE builds were unaffected (there isConnected() reflects bond state). Gate the PIN on actual BLE-bonded state instead: add AbstractUITask::isBLEConnected() (forwards to BaseSerialInterface:: isBLEConnected(), which DualSerialInterface overrides with the real BLE state and pure-BLE inherits as its bond-aware isConnected()). The PIN now shows on the Bluetooth page while BLE is on and not yet bonded. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
void setHasConnection(bool connected) { _connected = connected; }
|
void setHasConnection(bool connected) { _connected = connected; }
|
||||||
bool hasConnection() const { return _connected; }
|
bool hasConnection() const { return _connected; }
|
||||||
|
// 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.
|
||||||
|
bool isBLEConnected() const { return _serial->isBLEConnected(); }
|
||||||
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
|
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
|
||||||
bool isSerialEnabled() const { return _serial->isEnabled(); }
|
bool isSerialEnabled() const { return _serial->isEnabled(); }
|
||||||
void enableSerial() { _serial->enable(); }
|
void enableSerial() { _serial->enable(); }
|
||||||
|
|||||||
@@ -740,7 +740,10 @@ public:
|
|||||||
display.drawXbm((display.width() - 32) / 2, content_y,
|
display.drawXbm((display.width() - 32) / 2, content_y,
|
||||||
_task->isSerialEnabled() ? bluetooth_on : bluetooth_off, 32, 32);
|
_task->isSerialEnabled() ? bluetooth_on : bluetooth_off, 32, 32);
|
||||||
const int text_y = content_y + 32 + 3;
|
const int text_y = content_y + 32 + 3;
|
||||||
const bool waiting_for_pair = _task->isSerialEnabled() && !_task->hasConnection() && the_mesh.getBLEPin() != 0;
|
// Gate on BLE-bonded state, not hasConnection(): on a dual BLE+USB
|
||||||
|
// interface hasConnection() is always true (USB), which would hide the
|
||||||
|
// PIN forever — the exact e-ink dual-build pairing bug.
|
||||||
|
const bool waiting_for_pair = _task->isSerialEnabled() && !_task->isBLEConnected() && the_mesh.getBLEPin() != 0;
|
||||||
if (waiting_for_pair && !display.isLandscape()) {
|
if (waiting_for_pair && !display.isLandscape()) {
|
||||||
char pin_buf[16];
|
char pin_buf[16];
|
||||||
snprintf(pin_buf, sizeof(pin_buf), "PIN: %d", the_mesh.getBLEPin());
|
snprintf(pin_buf, sizeof(pin_buf), "PIN: %d", the_mesh.getBLEPin());
|
||||||
|
|||||||
Reference in New Issue
Block a user