diff --git a/subsys/bluetooth/mesh/proxy.h b/subsys/bluetooth/mesh/proxy.h index 7f06be8f13f802..a2f6bb45ff61c9 100644 --- a/subsys/bluetooth/mesh/proxy.h +++ b/subsys/bluetooth/mesh/proxy.h @@ -36,3 +36,4 @@ void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub); bool bt_mesh_proxy_relay(struct net_buf *buf, uint16_t dst); void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, uint16_t addr); +uint8_t bt_mesh_proxy_srv_connected_cnt(void); diff --git a/subsys/bluetooth/mesh/proxy_cli.c b/subsys/bluetooth/mesh/proxy_cli.c index 4b95e894c9c6b0..a0a25751b413ab 100644 --- a/subsys/bluetooth/mesh/proxy_cli.c +++ b/subsys/bluetooth/mesh/proxy_cli.c @@ -391,3 +391,12 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) BT_MESH_SUBNET_CB_DEFINE(proxy_cli) = { .evt_handler = subnet_evt, }; + +bool bt_mesh_proxy_cli_is_connected(uint16_t net_idx) +{ + if (find_proxy_srv(net_idx, true, false)) { + return true; + } + + return false; +} diff --git a/subsys/bluetooth/mesh/proxy_cli.h b/subsys/bluetooth/mesh/proxy_cli.h index 9f8ec96458dcc1..8c1fae10e84a10 100644 --- a/subsys/bluetooth/mesh/proxy_cli.h +++ b/subsys/bluetooth/mesh/proxy_cli.h @@ -9,3 +9,5 @@ void bt_mesh_proxy_cli_adv_recv(const struct bt_le_scan_recv_info *info, struct net_buf_simple *buf); bool bt_mesh_proxy_cli_relay(struct net_buf *buf); + +bool bt_mesh_proxy_cli_is_connected(uint16_t net_idx); diff --git a/subsys/bluetooth/mesh/proxy_srv.c b/subsys/bluetooth/mesh/proxy_srv.c index 12775b936510b2..4e260f8e93743c 100644 --- a/subsys/bluetooth/mesh/proxy_srv.c +++ b/subsys/bluetooth/mesh/proxy_srv.c @@ -1157,3 +1157,16 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { .connected = gatt_connected, .disconnected = gatt_disconnected, }; + +uint8_t bt_mesh_proxy_srv_connected_cnt(void) +{ + uint8_t cnt = 0; + + for (int i = 0; i < ARRAY_SIZE(clients); i++) { + if (clients[i].cli) { + cnt++; + } + } + + return cnt; +}