Bluetooth: Mesh: Fix heartbeat sending on Friendship established/lost
Mesh Profile 3.6.7.2 Publishing Heartbeat messages: " Triggered publishing of Heartbeat messages is enabled by the Heartbeat Publication Features state (see Section 4.2.17.5): ... - If the Low Power bit is set to 1, a Heartbeat message shall be published when the node establishes or loses Friendship (see Section 3.6.6.1). " Fixes #18194 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
39edab1013
commit
94fcb211de
2 changed files with 12 additions and 3 deletions
|
@ -199,6 +199,7 @@ static int send_friend_clear(void)
|
|||
|
||||
static void clear_friendship(bool force, bool disable)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get();
|
||||
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
|
||||
|
||||
BT_DBG("force %u disable %u", force, disable);
|
||||
|
@ -246,6 +247,10 @@ static void clear_friendship(bool force, bool disable)
|
|||
*/
|
||||
lpn->groups_changed = 1U;
|
||||
|
||||
if (cfg->hb_pub.feat & BT_MESH_FEAT_LOW_POWER) {
|
||||
bt_mesh_heartbeat_send();
|
||||
}
|
||||
|
||||
if (disable) {
|
||||
lpn_set_state(BT_MESH_LPN_DISABLED);
|
||||
return;
|
||||
|
@ -944,6 +949,8 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
|
|||
}
|
||||
|
||||
if (!lpn->established) {
|
||||
struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get();
|
||||
|
||||
/* This is normally checked on the transport layer, however
|
||||
* in this state we're also still accepting master
|
||||
* credentials so we need to ensure the right ones (Friend
|
||||
|
@ -958,6 +965,10 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
|
|||
|
||||
BT_INFO("Friendship established with 0x%04x", lpn->frnd);
|
||||
|
||||
if (cfg->hb_pub.feat & BT_MESH_FEAT_LOW_POWER) {
|
||||
bt_mesh_heartbeat_send();
|
||||
}
|
||||
|
||||
if (lpn_cb) {
|
||||
lpn_cb(lpn->frnd, true);
|
||||
}
|
||||
|
|
|
@ -1547,11 +1547,9 @@ void bt_mesh_heartbeat_send(void)
|
|||
feat |= BT_MESH_FEAT_FRIEND;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_LOW_POWER)
|
||||
if (bt_mesh.lpn.state != BT_MESH_LPN_DISABLED) {
|
||||
if (bt_mesh_lpn_established()) {
|
||||
feat |= BT_MESH_FEAT_LOW_POWER;
|
||||
}
|
||||
#endif
|
||||
|
||||
hb.feat = sys_cpu_to_be16(feat);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue