Skip to content

Commit 127640d

Browse files
MarekPietaanangl
authored andcommitted
caf: ble_state: Optional security request
Change makes security level 2 request optional. The security request is no longer enabled by default for peripheral. Jira: NCSDK-14084 Signed-off-by: Marek Pieta <[email protected]>
1 parent 1f18ce7 commit 127640d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

subsys/caf/modules/Kconfig.ble_state

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ menuconfig CAF_BLE_STATE
1717

1818
if CAF_BLE_STATE
1919

20+
config CAF_BLE_STATE_SECURITY_REQ
21+
bool "Request connection encryption (security level 2)"
22+
help
23+
Automatically request connection encryption right after the connection is established.
24+
2025
config CAF_BLE_STATE_PM
2126
bool "Enable bluetooth LE power manager integration"
2227
depends on CAF_BLE_STATE

subsys/caf/modules/ble_state.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ static void connected(struct bt_conn *conn, uint8_t error)
205205
LOG_INF("Already bonded to %s", log_strdup(addr_str));
206206
goto disconnect;
207207
}
208+
}
209+
210+
if (IS_ENABLED(CONFIG_CAF_BLE_STATE_SECURITY_REQ)) {
208211
/* Security must be enabled after peer event is sent.
209212
* This is to make sure notification events are propagated
210213
* in the right order.
@@ -279,7 +282,7 @@ static void security_changed(struct bt_conn *conn, bt_security_t level,
279282
} else {
280283
LOG_WRN("Security with %s failed, level %u err %d",
281284
log_strdup(addr), level, bt_err);
282-
if (IS_ENABLED(CONFIG_BT_PERIPHERAL)) {
285+
if (IS_ENABLED(CONFIG_CAF_BLE_STATE_SECURITY_REQ)) {
283286
disconnect_peer(conn);
284287
}
285288

0 commit comments

Comments
 (0)