mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
repeat pairing fix
This commit is contained in:
@@ -158,6 +158,11 @@ void resetAncsState() {
|
||||
g_pendingNotifications.clear();
|
||||
}
|
||||
|
||||
void clearDeliveredNotifications() {
|
||||
if (g_notificationCenter)
|
||||
g_notificationCenter->clear();
|
||||
}
|
||||
|
||||
PendingNotification* findPending(uint32_t uid) {
|
||||
for (auto& entry: g_pendingNotifications) {
|
||||
if (entry.uid == uid)
|
||||
@@ -1461,12 +1466,23 @@ int gapEventHandler(struct ble_gap_event* event, void* /*arg*/) {
|
||||
|
||||
case BLE_GAP_EVENT_REPEAT_PAIRING: {
|
||||
ble_gap_conn_desc desc{};
|
||||
if (ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc) == 0) {
|
||||
ESP_LOGI(kLogTag, "Repeat pairing requested by %02X:%02X:%02X:%02X:%02X:%02X; keeping existing bond",
|
||||
const int findRc = ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc);
|
||||
if (findRc != 0) {
|
||||
ESP_LOGW(kLogTag, "Repeat pairing but failed to fetch connection descriptor (rc=%d)", findRc);
|
||||
} else {
|
||||
ESP_LOGI(kLogTag,
|
||||
"Repeat pairing requested by %02X:%02X:%02X:%02X:%02X:%02X; deleting existing bond to re-pair",
|
||||
desc.peer_id_addr.val[0], desc.peer_id_addr.val[1], desc.peer_id_addr.val[2],
|
||||
desc.peer_id_addr.val[3], desc.peer_id_addr.val[4], desc.peer_id_addr.val[5]);
|
||||
const int deleteRc = ble_store_util_delete_peer(&desc.peer_id_addr);
|
||||
if (deleteRc != 0) {
|
||||
ESP_LOGW(kLogTag, "Failed to delete existing bond (rc=%d)", deleteRc);
|
||||
}
|
||||
return BLE_GAP_REPEAT_PAIRING_IGNORE;
|
||||
}
|
||||
resetAncsState();
|
||||
clearDeliveredNotifications();
|
||||
g_securityRequested = false;
|
||||
return BLE_GAP_REPEAT_PAIRING_RETRY;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user