Bluetooth: Mesh: Proxy: Don't try to advertise when it's not possible
If we have the maximum number of supported connections, then it doesn't make sense to try to do connectable advertising. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
e4cac812df
commit
8b51b60634
1 changed files with 14 additions and 3 deletions
|
@ -503,6 +503,8 @@ static ssize_t proxy_recv(struct bt_conn *conn,
|
|||
return len;
|
||||
}
|
||||
|
||||
static int conn_count;
|
||||
|
||||
static void proxy_connected(struct bt_conn *conn, u8_t err)
|
||||
{
|
||||
struct bt_mesh_proxy_client *client;
|
||||
|
@ -510,13 +512,15 @@ static void proxy_connected(struct bt_conn *conn, u8_t err)
|
|||
|
||||
BT_DBG("conn %p err 0x%02x", conn, err);
|
||||
|
||||
conn_count++;
|
||||
|
||||
/* Since we use ADV_OPT_ONE_TIME */
|
||||
proxy_adv_enabled = false;
|
||||
|
||||
#if CONFIG_BT_MAX_CONN > 1
|
||||
/* Try to re-enable advertising in case it's possible */
|
||||
bt_mesh_adv_update();
|
||||
#endif
|
||||
if (conn_count < CONFIG_BT_MAX_CONN) {
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
for (client = NULL, i = 0; i < ARRAY_SIZE(clients); i++) {
|
||||
if (!clients[i].conn) {
|
||||
|
@ -542,6 +546,8 @@ static void proxy_disconnected(struct bt_conn *conn, u8_t reason)
|
|||
|
||||
BT_DBG("conn %p reason 0x%02x", conn, reason);
|
||||
|
||||
conn_count--;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(clients); i++) {
|
||||
struct bt_mesh_proxy_client *client = &clients[i];
|
||||
|
||||
|
@ -1087,6 +1093,11 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
|
|||
|
||||
BT_DBG("");
|
||||
|
||||
if (conn_count == CONFIG_BT_MAX_CONN) {
|
||||
BT_WARN("Connectable advertising deferred (max connections)");
|
||||
return remaining;
|
||||
}
|
||||
|
||||
if (!sub) {
|
||||
BT_WARN("No subnets to advertise on");
|
||||
return remaining;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue