Bluetooth: Mesh: Filter out unknown conns and disconns in pb-gatt srv

Ensure that another established connection with the mesh device don't
mess up pb-gatt server state.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2022-11-23 14:54:51 +01:00 committed by Carles Cufí
commit c32ee7199f

View file

@ -100,7 +100,7 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err)
bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
bt_mesh_is_provisioned() || info.id != BT_ID_DEFAULT) {
bt_mesh_is_provisioned() || info.id != BT_ID_DEFAULT || cli) {
return;
}
@ -115,14 +115,12 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
info.id != BT_ID_DEFAULT) {
info.id != BT_ID_DEFAULT || !cli || cli->conn != conn) {
return;
}
if (cli) {
bt_mesh_proxy_role_cleanup(cli);
cli = NULL;
}
bt_mesh_proxy_role_cleanup(cli);
cli = NULL;
bt_mesh_pb_gatt_close(conn);