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 <omkar.kulkarni@nordicsemi.no>
This commit is contained in:
Omkar Kulkarni 2022-11-16 10:45:43 +01:00 committed by Carles Cufí
commit 7e3b509ae1
2 changed files with 7 additions and 7 deletions

View file

@ -832,8 +832,8 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err)
struct bt_conn_info info;
bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL ||
!service_registered) {
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
info.id != BT_ID_DEFAULT) {
return;
}
@ -858,7 +858,7 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
struct bt_mesh_proxy_client *client;
bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL) {
if (info.role != BT_CONN_ROLE_PERIPHERAL || info.id != BT_ID_DEFAULT) {
return;
}