Skip to content

Commit

Permalink
Bluetooth: Mesh: Add proxy test API
Browse files Browse the repository at this point in the history
Adds internal proxy API to enhance testabillity of
the proxy implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
  • Loading branch information
Andrewpini authored and carlescufi committed Oct 20, 2023
1 parent 5551b4c commit 6f2ebb9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions subsys/bluetooth/mesh/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
9 changes: 9 additions & 0 deletions subsys/bluetooth/mesh/proxy_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions subsys/bluetooth/mesh/proxy_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
13 changes: 13 additions & 0 deletions subsys/bluetooth/mesh/proxy_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 6f2ebb9

Please sign in to comment.