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();
|
g_pendingNotifications.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearDeliveredNotifications() {
|
||||||
|
if (g_notificationCenter)
|
||||||
|
g_notificationCenter->clear();
|
||||||
|
}
|
||||||
|
|
||||||
PendingNotification* findPending(uint32_t uid) {
|
PendingNotification* findPending(uint32_t uid) {
|
||||||
for (auto& entry: g_pendingNotifications) {
|
for (auto& entry: g_pendingNotifications) {
|
||||||
if (entry.uid == uid)
|
if (entry.uid == uid)
|
||||||
@@ -192,7 +197,7 @@ void finalizePending(uint32_t uid) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
cardboy::sdk::INotificationCenter::Notification note{};
|
cardboy::sdk::INotificationCenter::Notification note{};
|
||||||
note.timestamp = static_cast<std::uint64_t>(time(nullptr));
|
note.timestamp = static_cast<std::uint64_t>(time(nullptr));
|
||||||
note.externalId = uid;
|
note.externalId = uid;
|
||||||
if (!it->title.empty()) {
|
if (!it->title.empty()) {
|
||||||
note.title = it->title;
|
note.title = it->title;
|
||||||
@@ -1461,12 +1466,23 @@ int gapEventHandler(struct ble_gap_event* event, void* /*arg*/) {
|
|||||||
|
|
||||||
case BLE_GAP_EVENT_REPEAT_PAIRING: {
|
case BLE_GAP_EVENT_REPEAT_PAIRING: {
|
||||||
ble_gap_conn_desc desc{};
|
ble_gap_conn_desc desc{};
|
||||||
if (ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc) == 0) {
|
const int findRc = ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc);
|
||||||
ESP_LOGI(kLogTag, "Repeat pairing requested by %02X:%02X:%02X:%02X:%02X:%02X; keeping existing bond",
|
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[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]);
|
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:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user