Skip to content

Commit a9993c7

Browse files
carlescufimbolivar-nordic
authored andcommitted
[nrf fromtree] Bluetooth: host: Optionally disable GATT sec re-establish
Some centrals deal poorly with receiving a security request immediately after reconnection whenever reconnecting with characteristics that are notifiable or indicatable and requiring security. In particular, Android 9 and earlier devices may lose bond information when this happens, some Microsoft Surface devices will enter an invalid state and, on top of that, Apple's Bluetooth Low Energy guidelines explicitly discourage this behavior. In order to allow interoperability with those devices, make the GATT automatic security request sending as a peripheral optional by introducing a new Kconfig option, BT_GATT_AUTO_SEC_REQ. Signed-off-by: Carles Cufi <[email protected]> (cherry picked from commit f8cf454)
1 parent 74462e3 commit a9993c7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

subsys/bluetooth/host/Kconfig.gatt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ config BT_EATT_SEC_LEVEL
5555

5656
endif # BT_EATT
5757

58+
config BT_GATT_AUTO_SEC_REQ
59+
bool "Automatic security re-establishment request as a peripheral"
60+
default y
61+
depends on BT_SMP
62+
help
63+
This option requests security re-establishment automatically whenever
64+
a reconnection to a GATT client is established and
65+
there are notifiable or indicatable characteristics for which security
66+
is required. This configuration option only applies to the peripheral
67+
role, which sends a Security Request for this purpose.
68+
When disabled, it is the application's responsibility to call
69+
bt_conn_set_security() to re-establish security prior to sending any
70+
notifications or indications on the characteristics that require
71+
security (unless the central does that first).
72+
This option has been introduced to avoid interoperability issues with
73+
commercially available central devices that react negatively to
74+
receiving a Security Request immediately after reconnection.
75+
5876
config BT_GATT_SERVICE_CHANGED
5977
bool "GATT Service Changed support"
6078
default y

subsys/bluetooth/host/gatt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4848,6 +4848,8 @@ void bt_gatt_connected(struct bt_conn *conn)
48484848
* enabling encryption will fail.
48494849
*/
48504850
if (IS_ENABLED(CONFIG_BT_SMP) &&
4851+
(conn->role == BT_HCI_ROLE_MASTER ||
4852+
IS_ENABLED(CONFIG_BT_GATT_AUTO_SEC_REQ)) &&
48514853
bt_conn_get_security(conn) < data.sec) {
48524854
bt_conn_set_security(conn, data.sec);
48534855
}

0 commit comments

Comments
 (0)