Bluetooth: Host: Add option to force pairing in bt_conn_security

Add option to force the host to initiate pairing procedure even if the
host has encryption keys for the peer.
This option can be used to pair with a bonded peer that has deleted its
bonding information without deleting the keys. If new pairing results
in weaker keys the pairing will be aborted.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-08-21 10:51:14 +02:00 committed by Carles Cufí
commit 128cf42d8a
4 changed files with 12 additions and 1 deletions

View file

@ -1058,7 +1058,9 @@ int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
return 0;
}
conn->required_sec_level = sec;
atomic_set_bit_to(conn->flags, BT_CONN_FORCE_PAIR,
sec & BT_SECURITY_FORCE_PAIR);
conn->required_sec_level = sec & ~BT_SECURITY_FORCE_PAIR;
err = start_security(conn);