From 46d9c979912e62a34209a98541408a406aee8803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Storr=C3=B8?= Date: Wed, 25 Oct 2023 11:08:21 +0200 Subject: [PATCH] Bluetooth: Mesh: HB pub status for unassigned addr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue where Heartbeat Publication Status message sends garbage data when destination field is set to the unassigned address. MshPRTv1.1, section 4.4.1.2.15: "When the Destination field is set to the unassigned address, the values of the CountLog, PeriodLog, TTL, and Features fields shall be set to 0x00 and NetKeyIndex field shall be set to 0x0000." Signed-off-by: Anders Storrø --- subsys/bluetooth/mesh/cfg_srv.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index c45b627d194..d9df5550720 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -2267,11 +2267,15 @@ static int hb_pub_send_status(struct bt_mesh_model *model, net_buf_simple_add_u8(&msg, status); net_buf_simple_add_le16(&msg, pub->dst); - net_buf_simple_add_u8(&msg, hb_pub_count_log(pub->count)); - net_buf_simple_add_u8(&msg, bt_mesh_hb_log(pub->period)); - net_buf_simple_add_u8(&msg, pub->ttl); - net_buf_simple_add_le16(&msg, pub->feat); - net_buf_simple_add_le16(&msg, pub->net_idx); + if (pub->dst == BT_MESH_ADDR_UNASSIGNED) { + (void)memset(net_buf_simple_add(&msg, 7), 0, 7); + } else { + net_buf_simple_add_u8(&msg, hb_pub_count_log(pub->count)); + net_buf_simple_add_u8(&msg, bt_mesh_hb_log(pub->period)); + net_buf_simple_add_u8(&msg, pub->ttl); + net_buf_simple_add_le16(&msg, pub->feat); + net_buf_simple_add_le16(&msg, pub->net_idx); + } if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { LOG_ERR("Unable to send Heartbeat Publication Status");