Skip to content

Commit

Permalink
Bluetooth: Add run-time option to disable SMP bondable mode
Browse files Browse the repository at this point in the history
This adds a function that will disable Bonding flag in
Authentication Requirements flag in SMP Pairing Request/Response.
This is needed for qualification purposes.

Signed-off-by: Mariusz Skamra <[email protected]>
  • Loading branch information
MariuszSkamra authored and jhedberg committed Sep 19, 2018
1 parent 7ff9eee commit 4f74f69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,18 @@ struct bt_conn_cb {
*/
void bt_conn_cb_register(struct bt_conn_cb *cb);

/** Enable/disable bonding.
*
* Set/clear the Bonding flag in the Authentication Requirements of
* SMP Pairing Request/Response data.
* The initial value of this flag depends on BT_BONDABLE Kconfig setting.
* For the vast majority of applications calling this function shouldn't be
* needed.
*
* @param enable Value allowing/disallowing to be bondable.
*/
void bt_set_bondable(bool enable);

/** @def BT_PASSKEY_INVALID
*
* Special passkey value that can be used to disable a previously
Expand Down
12 changes: 12 additions & 0 deletions subsys/bluetooth/host/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ static struct bt_smp_br bt_smp_br_pool[CONFIG_BT_MAX_CONN];
#endif /* CONFIG_BT_BREDR */

static struct bt_smp bt_smp_pool[CONFIG_BT_MAX_CONN];
static bool bondable = IS_ENABLED(CONFIG_BT_BONDABLE);
static bool sc_supported;
static bool sc_local_pkey_valid;
static u8_t sc_public_key[64];
Expand Down Expand Up @@ -2267,6 +2268,11 @@ static int smp_init(struct bt_smp *smp)
return 0;
}

void bt_set_bondable(bool enable)
{
bondable = enable;
}

static u8_t get_auth(u8_t auth)
{
if (sc_supported) {
Expand All @@ -2281,6 +2287,12 @@ static u8_t get_auth(u8_t auth)
auth |= BT_SMP_AUTH_MITM;
}

if (bondable) {
auth |= BT_SMP_AUTH_BONDING;
} else {
auth &= ~BT_SMP_AUTH_BONDING;
}

return auth;
}

Expand Down

0 comments on commit 4f74f69

Please sign in to comment.