Skip to content

Commit 4f74f69

Browse files
MariuszSkamrajhedberg
authored andcommitted
Bluetooth: Add run-time option to disable SMP bondable mode
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 <mariusz.skamra@codecoup.pl>
1 parent 7ff9eee commit 4f74f69

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/bluetooth/conn.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,18 @@ struct bt_conn_cb {
386386
*/
387387
void bt_conn_cb_register(struct bt_conn_cb *cb);
388388

389+
/** Enable/disable bonding.
390+
*
391+
* Set/clear the Bonding flag in the Authentication Requirements of
392+
* SMP Pairing Request/Response data.
393+
* The initial value of this flag depends on BT_BONDABLE Kconfig setting.
394+
* For the vast majority of applications calling this function shouldn't be
395+
* needed.
396+
*
397+
* @param enable Value allowing/disallowing to be bondable.
398+
*/
399+
void bt_set_bondable(bool enable);
400+
389401
/** @def BT_PASSKEY_INVALID
390402
*
391403
* Special passkey value that can be used to disable a previously

subsys/bluetooth/host/smp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static struct bt_smp_br bt_smp_br_pool[CONFIG_BT_MAX_CONN];
249249
#endif /* CONFIG_BT_BREDR */
250250

251251
static struct bt_smp bt_smp_pool[CONFIG_BT_MAX_CONN];
252+
static bool bondable = IS_ENABLED(CONFIG_BT_BONDABLE);
252253
static bool sc_supported;
253254
static bool sc_local_pkey_valid;
254255
static u8_t sc_public_key[64];
@@ -2267,6 +2268,11 @@ static int smp_init(struct bt_smp *smp)
22672268
return 0;
22682269
}
22692270

2271+
void bt_set_bondable(bool enable)
2272+
{
2273+
bondable = enable;
2274+
}
2275+
22702276
static u8_t get_auth(u8_t auth)
22712277
{
22722278
if (sc_supported) {
@@ -2281,6 +2287,12 @@ static u8_t get_auth(u8_t auth)
22812287
auth |= BT_SMP_AUTH_MITM;
22822288
}
22832289

2290+
if (bondable) {
2291+
auth |= BT_SMP_AUTH_BONDING;
2292+
} else {
2293+
auth &= ~BT_SMP_AUTH_BONDING;
2294+
}
2295+
22842296
return auth;
22852297
}
22862298

0 commit comments

Comments
 (0)