From f2ea6f2149bd98b1dc16045f287c397a64a370fd Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Fri, 4 Nov 2022 16:10:14 +0100 Subject: [PATCH] Bluetooth: Mesh: Check avail conn before restarting pb-gatt srv adv When a provisioner connects to the device, gatt_connected callback is called in pb_gatt_srv.c, then pb-gatt advertising is stopped and adv_sent callback is triggered in adv_ext.c. adv_sent callback reschedules advertising and eventually calls bt_mesh_adv_gatt_send. Since the device is not provisioned yet, it tries to start pb-gatt advertising again. If number of available connections is reached, this results in "Advertising failed" error in adv_ext.c. Signed-off-by: Pavel Vasilyev --- subsys/bluetooth/mesh/pb_gatt_srv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/pb_gatt_srv.c b/subsys/bluetooth/mesh/pb_gatt_srv.c index f409914ab94..945ac48e92e 100644 --- a/subsys/bluetooth/mesh/pb_gatt_srv.c +++ b/subsys/bluetooth/mesh/pb_gatt_srv.c @@ -270,7 +270,8 @@ int bt_mesh_pb_gatt_srv_adv_start(void) { BT_DBG(""); - if (!service_registered || bt_mesh_is_provisioned()) { + if (!service_registered || bt_mesh_is_provisioned() || + bt_mesh_proxy_conn_count_get() == CONFIG_BT_MAX_CONN) { return -ENOTSUP; }