BLE Pairing fix (#9701)

* BLE Pairing fix

* gating for consistency

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
HarukiToreda
2026-02-20 10:38:07 -06:00
committed by GitHub
co-authored by Ben Meadors
parent 6bc3e31537
commit 8f81b194d3
3 changed files with 35 additions and 8 deletions
+15 -1
View File
@@ -32,6 +32,7 @@ static uint8_t toRadioBytes[meshtastic_ToRadio_size];
static uint8_t lastToRadio[MAX_TO_FROM_RADIO_SIZE];
static uint16_t connectionHandle;
static bool passkeyShowing;
class BluetoothPhoneAPI : public PhoneAPI
{
@@ -86,6 +87,16 @@ void onDisconnect(uint16_t conn_handle, uint8_t reason)
// Notify UI (or any other interested firmware components)
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
bluetoothStatus->updateStatus(&newStatus);
#if HAS_SCREEN
// If a pairing prompt is active, make sure we dismiss it on disconnect/cancel/failure paths.
if (passkeyShowing) {
passkeyShowing = false;
if (screen) {
screen->endAlert();
}
}
#endif
}
void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
{
@@ -400,6 +411,8 @@ bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passke
});
}
#endif
passkeyShowing = true;
if (match_request) {
uint32_t start_time = millis();
while (millis() < start_time + 30000) {
@@ -451,6 +464,7 @@ void NRF52Bluetooth::onPairingCompleted(uint16_t conn_handle, uint8_t auth_statu
}
// Todo: migrate this display code back into Screen class, and observe bluetoothStatus
passkeyShowing = false;
if (screen) {
screen->endAlert();
}
@@ -464,4 +478,4 @@ void NRF52Bluetooth::sendLog(const uint8_t *logMessage, size_t length)
logRadio.indicate(logMessage, (uint16_t)length);
else
logRadio.notify(logMessage, (uint16_t)length);
}
}