Skip to content

Commit e5353e6

Browse files
omkar3141rlubos
authored andcommitted
[nrf fromtree] bluetooth: mesh: check id in connection callbacks
When application uses multiple identities mesh stack keeps reacting on connection events not related to the own identity (BT_ID_DEFAULT) causing it to trigger additional advertising and this leads to errors. Though not harmful, this also leads to mesh stack counting connections wrongly and consuming internal resources. This commit fixes the issue described above by checking the connection id before proceeding further. Signed-off-by: Omkar Kulkarni <[email protected]> (cherry picked from commit 7e3b509)
1 parent a9821b0 commit e5353e6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

subsys/bluetooth/mesh/pb_gatt_srv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err)
9999
struct bt_conn_info info;
100100

101101
bt_conn_get_info(conn, &info);
102-
if (info.role != BT_CONN_ROLE_PERIPHERAL ||
103-
!service_registered || bt_mesh_is_provisioned()) {
102+
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
103+
bt_mesh_is_provisioned() || info.id != BT_ID_DEFAULT) {
104104
return;
105105
}
106106

@@ -114,8 +114,8 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
114114
struct bt_conn_info info;
115115

116116
bt_conn_get_info(conn, &info);
117-
if (info.role != BT_CONN_ROLE_PERIPHERAL ||
118-
!service_registered) {
117+
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
118+
info.id != BT_ID_DEFAULT) {
119119
return;
120120
}
121121

subsys/bluetooth/mesh/proxy_srv.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err)
832832
struct bt_conn_info info;
833833

834834
bt_conn_get_info(conn, &info);
835-
if (info.role != BT_CONN_ROLE_PERIPHERAL ||
836-
!service_registered) {
835+
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
836+
info.id != BT_ID_DEFAULT) {
837837
return;
838838
}
839839

@@ -858,7 +858,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
858858
struct bt_mesh_proxy_client *client;
859859

860860
bt_conn_get_info(conn, &info);
861-
if (info.role != BT_CONN_ROLE_PERIPHERAL) {
861+
if (info.role != BT_CONN_ROLE_PERIPHERAL || info.id != BT_ID_DEFAULT) {
862862
return;
863863
}
864864

0 commit comments

Comments
 (0)