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 <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2022-11-04 16:10:14 +01:00 committed by Carles Cufí
parent 0f80133571
commit f2ea6f2149

View File

@ -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;
}