|
@@ -31,6 +31,7 @@
|
|
|
|
|
|
static const ble_uuid16_t s_device_name_chr_uuid = BLE_UUID16_INIT(0x2A00);
|
|
static const ble_uuid16_t s_device_name_chr_uuid = BLE_UUID16_INIT(0x2A00);
|
|
static char s_device_name[BT_DEVICE_NAME_BUFFER_SIZE];
|
|
static char s_device_name[BT_DEVICE_NAME_BUFFER_SIZE];
|
|
|
|
+static bool s_pairing_in_progress;
|
|
|
|
|
|
static int prv_device_name_read_event_cb(uint16_t conn_handle, const struct ble_gatt_error *error,
|
|
static int prv_device_name_read_event_cb(uint16_t conn_handle, const struct ble_gatt_error *error,
|
|
struct ble_gatt_attr *attr, void *arg) {
|
|
struct ble_gatt_attr *attr, void *arg) {
|
|
@@ -115,6 +116,9 @@ static void prv_handle_connection_event(struct ble_gap_event *event) {
|
|
|
|
|
|
nimble_conn_params_to_pebble(&desc, &complete_event.conn_params);
|
|
nimble_conn_params_to_pebble(&desc, &complete_event.conn_params);
|
|
nimble_addr_to_pebble_device(&desc.peer_id_addr, &complete_event.peer_address);
|
|
nimble_addr_to_pebble_device(&desc.peer_id_addr, &complete_event.peer_address);
|
|
|
|
+
|
|
|
|
+ s_pairing_in_progress = false;
|
|
|
|
+
|
|
bt_driver_handle_le_connection_complete_event(&complete_event);
|
|
bt_driver_handle_le_connection_complete_event(&complete_event);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,12 +189,18 @@ static void prv_handle_passkey_event(struct ble_gap_event *event) {
|
|
|
|
|
|
snprintf(passkey_str, sizeof(passkey_str), "%06lu", passkey);
|
|
snprintf(passkey_str, sizeof(passkey_str), "%06lu", passkey);
|
|
bt_driver_cb_pairing_confirm_handle_request(ctx, device_name, passkey_str);
|
|
bt_driver_cb_pairing_confirm_handle_request(ctx, device_name, passkey_str);
|
|
|
|
+ s_pairing_in_progress = true;
|
|
}
|
|
}
|
|
|
|
|
|
static void prv_handle_pairing_complete_event(struct ble_gap_event *event) {
|
|
static void prv_handle_pairing_complete_event(struct ble_gap_event *event) {
|
|
|
|
+ if (!s_pairing_in_progress) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
PairingUserConfirmationCtx *ctx =
|
|
PairingUserConfirmationCtx *ctx =
|
|
(PairingUserConfirmationCtx *)((uintptr_t)event->pairing_complete.conn_handle);
|
|
(PairingUserConfirmationCtx *)((uintptr_t)event->pairing_complete.conn_handle);
|
|
bt_driver_cb_pairing_confirm_handle_completed(ctx, event->pairing_complete.status == 0);
|
|
bt_driver_cb_pairing_confirm_handle_completed(ctx, event->pairing_complete.status == 0);
|
|
|
|
+ s_pairing_in_progress = false;
|
|
}
|
|
}
|
|
|
|
|
|
static void prv_handle_identity_resolved_event(struct ble_gap_event *event) {
|
|
static void prv_handle_identity_resolved_event(struct ble_gap_event *event) {
|