Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesh: Fix GATT Proxy behavior to match Mesh Profile Spec 1.0.1 #724

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 1 addition & 28 deletions nimble/host/mesh/src/cfg_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,28 +805,6 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
bt_mesh_store_cfg();
}

if (cfg->gatt_proxy == BT_MESH_GATT_PROXY_DISABLED) {
int i;

/* Section 4.2.11.1: "When the GATT Proxy state is set to
* 0x00, the Node Identity state for all subnets shall be set
* to 0x00 and shall not be changed."
*/
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];

if (sub->net_idx != BT_MESH_KEY_UNUSED) {
bt_mesh_proxy_identity_stop(sub);
}
}

/* Section 4.2.11: "Upon transition from GATT Proxy state 0x01
* to GATT Proxy state 0x00 the GATT Bearer Server shall
* disconnect all GATT Bearer Clients.
*/
bt_mesh_proxy_gatt_disconnect();
}

bt_mesh_adv_update();

if (cfg->hb_pub.feat & BT_MESH_FEAT_PROXY) {
Expand Down Expand Up @@ -2482,12 +2460,7 @@ static void node_identity_set(struct bt_mesh_model *model,
net_buf_simple_add_u8(msg, STATUS_SUCCESS);
net_buf_simple_add_le16(msg, idx);

/* Section 4.2.11.1: "When the GATT Proxy state is set to
* 0x00, the Node Identity state for all subnets shall be set
* to 0x00 and shall not be changed."
*/
if (MYNEWT_VAL(BLE_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED) {
if (MYNEWT_VAL(BLE_MESH_GATT_PROXY)) {
if (node_id) {
bt_mesh_proxy_identity_start(sub);
} else {
Expand Down
12 changes: 9 additions & 3 deletions nimble/host/mesh/src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,13 +1325,19 @@ void bt_mesh_net_recv(struct os_mbuf *data, s8_t rssi,
/* Save the state so the buffer can later be relayed */
net_buf_simple_save(buf, &state);

rx.local_match = (bt_mesh_fixed_group_match(rx.ctx.recv_dst) ||
bt_mesh_elem_find(rx.ctx.recv_dst));

if ((MYNEWT_VAL(BLE_MESH_GATT_PROXY)) &&
net_if == BT_MESH_NET_IF_PROXY) {
bt_mesh_proxy_addr_add(data, rx.ctx.addr);
}

rx.local_match = (bt_mesh_fixed_group_match(rx.ctx.recv_dst) ||
bt_mesh_elem_find(rx.ctx.recv_dst));
if (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_DISABLED &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If the Proxy feature is disabled, a GATT client device can connect
over GATT to that node for configuration and control. Messages from
the GATT bearer are not relayed to the advertising bearer."

I'm not 100% sure if this means we should drop messages that are not directed at us or that we just shouldn't relay messages to ADV (see bt_mesh_net_relay() call below).

!rx.local_match) {
BT_INFO("Proxy is disabled; ignoring message");
goto done;
}
}

/* The transport layer has indicated that it has rejected the message,
* but would like to see it again if it is received in the future.
Expand Down
8 changes: 2 additions & 6 deletions nimble/host/mesh/src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ static bool advertise_subnet(struct bt_mesh_subnet *sub)
}

return (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING ||
bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED);
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED);
}

static struct bt_mesh_subnet *next_sub(void)
Expand Down Expand Up @@ -1225,11 +1225,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
}

if (sub->node_id == BT_MESH_NODE_IDENTITY_STOPPED) {
if (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED) {
net_id_adv(sub);
} else {
return gatt_proxy_advertise(next_sub());
}
net_id_adv(sub);
}

subnet_count = sub_count();
Expand Down