Bluetooth: host: Pairing callback fail and complete for SSP
Proved the Authentication callback for pairing failed and pairing complete when BR/EDR SSP is complete. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
1fb68828ef
commit
3263f93747
3 changed files with 39 additions and 0 deletions
|
@ -744,6 +744,21 @@ static int ssp_confirm_neg_reply(struct bt_conn *conn)
|
|||
NULL);
|
||||
}
|
||||
|
||||
void bt_conn_ssp_auth_complete(struct bt_conn *conn, u8_t status)
|
||||
{
|
||||
if (!status) {
|
||||
bool bond = !atomic_test_bit(conn->flags, BT_CONN_BR_NOBOND);
|
||||
|
||||
if (bt_auth && bt_auth->pairing_complete) {
|
||||
bt_auth->pairing_complete(conn, bond);
|
||||
}
|
||||
} else {
|
||||
if (bt_auth && bt_auth->pairing_failed) {
|
||||
bt_auth->pairing_failed(conn, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_conn_ssp_auth(struct bt_conn *conn, u32_t passkey)
|
||||
{
|
||||
conn->br.pairing_method = ssp_pair_method(conn);
|
||||
|
|
|
@ -173,6 +173,7 @@ void bt_conn_pin_code_req(struct bt_conn *conn);
|
|||
u8_t bt_conn_get_io_capa(void);
|
||||
u8_t bt_conn_ssp_get_auth(const struct bt_conn *conn);
|
||||
void bt_conn_ssp_auth(struct bt_conn *conn, u32_t passkey);
|
||||
void bt_conn_ssp_auth_complete(struct bt_conn *conn, u8_t status);
|
||||
|
||||
void bt_conn_disconnect_all(u8_t id);
|
||||
|
||||
|
|
|
@ -1679,6 +1679,28 @@ int bt_unpair(u8_t id, const bt_addr_le_t *addr)
|
|||
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
#if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR)
|
||||
static enum bt_security_err security_err_get(u8_t hci_err)
|
||||
{
|
||||
switch (hci_err) {
|
||||
case BT_HCI_ERR_SUCCESS:
|
||||
return BT_SECURITY_ERR_SUCCESS;
|
||||
case BT_HCI_ERR_AUTHENTICATION_FAIL:
|
||||
return BT_SECURITY_ERR_AUTHENTICATION_FAIL;
|
||||
case BT_HCI_ERR_PIN_OR_KEY_MISSING:
|
||||
return BT_SECURITY_ERR_PIN_OR_KEY_MISSING;
|
||||
case BT_HCI_ERR_PAIRING_NOT_SUPPORTED:
|
||||
return BT_SECURITY_ERR_PAIR_NOT_SUPPORTED;
|
||||
case BT_HCI_ERR_PAIRING_NOT_ALLOWED:
|
||||
return BT_SECURITY_ERR_PAIR_NOT_ALLOWED;
|
||||
case BT_HCI_ERR_INVALID_PARAM:
|
||||
return BT_SECURITY_ERR_INVALID_PARAM;
|
||||
default:
|
||||
return BT_SECURITY_ERR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
#endif /* defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR) */
|
||||
|
||||
#if defined(CONFIG_BT_BREDR)
|
||||
static void reset_pairing(struct bt_conn *conn)
|
||||
{
|
||||
|
@ -2186,6 +2208,7 @@ static void ssp_complete(struct net_buf *buf)
|
|||
return;
|
||||
}
|
||||
|
||||
bt_conn_ssp_auth_complete(conn, security_err_get(evt->status));
|
||||
if (evt->status) {
|
||||
bt_conn_disconnect(conn, BT_HCI_ERR_AUTHENTICATION_FAIL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue