mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-17 22:49:55 +00:00
apps/bttester: handle GAP Pairing Complete event
Send event when peer fails pairing procedure with reason code. This is required by SM/CEN/KDU/BI-02-C.
This commit is contained in:
committed by
Michał Narajowski
parent
0c9bb5d050
commit
f7ebfaf95b
@@ -418,6 +418,13 @@ struct gap_bond_lost_ev {
|
|||||||
uint8_t address[6];
|
uint8_t address[6];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
#define GAP_EV_SEC_PAIRING_FAILED 0x8c
|
||||||
|
struct gap_sec_pairing_failed_ev {
|
||||||
|
uint8_t address_type;
|
||||||
|
uint8_t address[6];
|
||||||
|
uint8_t reason;
|
||||||
|
} __packed;
|
||||||
|
|
||||||
/* GATT Service */
|
/* GATT Service */
|
||||||
/* commands */
|
/* commands */
|
||||||
#define GATT_READ_SUPPORTED_COMMANDS 0x01
|
#define GATT_READ_SUPPORTED_COMMANDS 0x01
|
||||||
|
|||||||
+34
-1
@@ -980,6 +980,31 @@ static void le_identity_resolved(uint16_t conn_handle)
|
|||||||
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void le_pairing_failed(uint16_t conn_handle, int reason)
|
||||||
|
{
|
||||||
|
struct ble_gap_conn_desc desc;
|
||||||
|
struct gap_sec_pairing_failed_ev ev;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
SYS_LOG_DBG("");
|
||||||
|
|
||||||
|
rc = ble_gap_conn_find(conn_handle, &desc);
|
||||||
|
if (rc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
peer_id_addr = desc.peer_id_addr;
|
||||||
|
peer_ota_addr = desc.peer_ota_addr;
|
||||||
|
|
||||||
|
ev.address_type = desc.peer_ota_addr.type;
|
||||||
|
memcpy(ev.address, desc.peer_ota_addr.val, sizeof(ev.address));
|
||||||
|
|
||||||
|
ev.reason = reason;
|
||||||
|
|
||||||
|
tester_send(BTP_SERVICE_ID_GAP, GAP_EV_SEC_PAIRING_FAILED,
|
||||||
|
CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev));
|
||||||
|
}
|
||||||
|
|
||||||
static void le_conn_param_update(struct ble_gap_conn_desc *desc)
|
static void le_conn_param_update(struct ble_gap_conn_desc *desc)
|
||||||
{
|
{
|
||||||
struct gap_conn_param_update_ev ev;
|
struct gap_conn_param_update_ev ev;
|
||||||
@@ -1262,7 +1287,15 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg)
|
|||||||
event->conn_update_req.peer_params->supervision_timeout == REJECT_SUPERVISION_TIMEOUT) {
|
event->conn_update_req.peer_params->supervision_timeout == REJECT_SUPERVISION_TIMEOUT) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
case BLE_GAP_EVENT_PARING_COMPLETE:
|
||||||
|
console_printf("received pairing complete: "
|
||||||
|
"conn_handle=%d status=%d\n",
|
||||||
|
event->pairing_complete.conn_handle,
|
||||||
|
event->pairing_complete.status);
|
||||||
|
if (event->pairing_complete.status != BLE_SM_ERR_SUCCESS) {
|
||||||
|
le_pairing_failed(event->pairing_complete.conn_handle, event->pairing_complete.status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2059,7 +2059,6 @@ ble_sm_key_exch_success(struct ble_sm_proc *proc, struct ble_sm_result *res)
|
|||||||
res->app_status = 0;
|
res->app_status = 0;
|
||||||
res->enc_cb = 1;
|
res->enc_cb = 1;
|
||||||
res->bonded = bonded;
|
res->bonded = bonded;
|
||||||
|
|
||||||
res->sm_err = BLE_SM_ERR_SUCCESS;
|
res->sm_err = BLE_SM_ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user