Bluetooth: Mesh: Add helpers for starting/stopping Node ID
We'll soon extend the start functionality with a bit more stuff (prioritizing the started subnet), so in order to avoid excessive code duplication, create helpers for these actions. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
62777755f9
commit
86ac86c6ca
3 changed files with 23 additions and 8 deletions
|
@ -801,8 +801,7 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
|
|||
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
|
||||
|
||||
if (sub->net_idx != BT_MESH_KEY_UNUSED) {
|
||||
sub->node_id = BT_MESH_NODE_IDENTITY_STOPPED;
|
||||
sub->node_id_start = 0;
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2234,8 +2233,11 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
*/
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
|
||||
bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED) {
|
||||
sub->node_id = node_id;
|
||||
sub->node_id_start = node_id ? k_uptime_get_32() : 0;
|
||||
if (node_id) {
|
||||
bt_mesh_proxy_identity_start(sub);
|
||||
} else {
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
}
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
||||
|
|
|
@ -337,6 +337,18 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
|
|||
}
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
sub->node_id = BT_MESH_NODE_IDENTITY_RUNNING;
|
||||
sub->node_id_start = k_uptime_get_32();
|
||||
}
|
||||
|
||||
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub)
|
||||
{
|
||||
sub->node_id = BT_MESH_NODE_IDENTITY_STOPPED;
|
||||
sub->node_id_start = 0;
|
||||
}
|
||||
|
||||
int bt_mesh_proxy_identity_enable(void)
|
||||
{
|
||||
/* FIXME: Add support for multiple subnets */
|
||||
|
@ -360,8 +372,7 @@ int bt_mesh_proxy_identity_enable(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub->node_id = BT_MESH_NODE_IDENTITY_RUNNING;
|
||||
sub->node_id_start = k_uptime_get_32();
|
||||
bt_mesh_proxy_identity_start(sub);
|
||||
bt_mesh_adv_update();
|
||||
|
||||
return 0;
|
||||
|
@ -1081,8 +1092,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
|
|||
active, remaining);
|
||||
node_id_adv(sub);
|
||||
} else {
|
||||
sub->node_id = BT_MESH_NODE_IDENTITY_STOPPED;
|
||||
sub->node_id_start = 0;
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
BT_DBG("Node ID stopped");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ struct net_buf_simple *bt_mesh_proxy_get_buf(void);
|
|||
s32_t bt_mesh_proxy_adv_start(void);
|
||||
void bt_mesh_proxy_adv_stop(void);
|
||||
|
||||
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub);
|
||||
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub);
|
||||
|
||||
bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst);
|
||||
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue