Bluetooth: Host: Add auth_info_cb struct
Add a new callback structure for Bluetooth authentication This struct is meant to replace the information-only callbacks in bt_conn_auth_cb. The reason for this is that due to the nature of bt_conn_auth_cb, it can only be registered once. To allow mulitple users gain information about pairing and bond deletions, this new struct is needed. Samples, tests, etc. are updated to use the new struct. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
f1d2e567a7
commit
9c2cf4ded5
12 changed files with 185 additions and 30 deletions
|
@ -201,7 +201,7 @@ static void update_conn(struct bt_conn *conn, bool bonded)
|
|||
}
|
||||
}
|
||||
|
||||
static struct bt_conn_auth_cb auth_cb_success = {
|
||||
static struct bt_conn_auth_info_cb auth_cb_success = {
|
||||
.pairing_complete = update_conn,
|
||||
};
|
||||
|
||||
|
@ -225,7 +225,7 @@ static void connected(struct bt_conn *conn, uint8_t conn_err)
|
|||
|
||||
if (encrypt_link) {
|
||||
k_sleep(K_MSEC(500));
|
||||
bt_conn_auth_cb_register(&auth_cb_success);
|
||||
bt_conn_auth_info_cb_register(&auth_cb_success);
|
||||
err = bt_conn_set_security(conn, BT_SECURITY_L2);
|
||||
if (err) {
|
||||
FAIL("bt_conn_set_security failed (err %d)\n", err);
|
||||
|
|
|
@ -957,6 +957,11 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded)
|
|||
#endif
|
||||
}
|
||||
|
||||
static struct bt_conn_auth_info_cb auth_info_cb = {
|
||||
.pairing_failed = auth_pairing_failed,
|
||||
.pairing_complete = auth_pairing_complete,
|
||||
};
|
||||
|
||||
static void set_io_cap(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
const struct gap_set_io_cap_cmd *cmd = (void *) data;
|
||||
|
@ -998,8 +1003,6 @@ static void set_io_cap(const uint8_t *data, uint16_t len)
|
|||
}
|
||||
|
||||
cb.pairing_accept = auth_pairing_accept;
|
||||
cb.pairing_failed = auth_pairing_failed;
|
||||
cb.pairing_complete = auth_pairing_complete;
|
||||
|
||||
if (bt_conn_auth_cb_register(&cb)) {
|
||||
status = BTP_STATUS_FAILED;
|
||||
|
@ -1362,6 +1365,7 @@ uint8_t tester_init_gap(void)
|
|||
if (bt_conn_auth_cb_register(&cb)) {
|
||||
return BTP_STATUS_FAILED;
|
||||
}
|
||||
bt_conn_auth_info_cb_register(&auth_info_cb);
|
||||
|
||||
err = bt_enable(tester_init_gap_cb);
|
||||
if (err < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue