From bf942bdf9abb0d7bed83f6297ccb79d443e85d69 Mon Sep 17 00:00:00 2001 From: Trond Einar Snekvik Date: Thu, 15 Apr 2021 12:30:47 +0200 Subject: [PATCH] Bluetooth: Mesh: Report configured LPNTimeout in cfg_srv Changes lpn_timeout_get behavior in the config server to report the configured LPN timeout, instead of the currently remaining timeout time. According to the Bluetooth Mesh Profile specification, section 4.2.21, the PollTimeout list is a list of the PollTimeout timer values, and according to table 4.32 in this section, values 1-9 are prohibited. Although this is not explicitly stated, this indicates that the PollTimeout value is the configured poll timeout time - not the time remaining until the timeout value expires. This patch changes the implementation to reflect this. Split out from #33782. Signed-off-by: Trond Einar Snekvik --- subsys/bluetooth/mesh/cfg_srv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index 589d85d19a2..475c16f4db5 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -2051,8 +2051,8 @@ static void lpn_timeout_get(struct bt_mesh_model *model, { BT_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5); struct bt_mesh_friend *frnd; + int32_t timeout_steps; uint16_t lpn_addr; - int32_t timeout_ms; lpn_addr = net_buf_simple_pull_le16(buf); @@ -2068,20 +2068,21 @@ static void lpn_timeout_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&msg, lpn_addr); if (!IS_ENABLED(CONFIG_BT_MESH_FRIEND)) { - timeout_ms = 0; + timeout_steps = 0; goto send_rsp; } frnd = bt_mesh_friend_find(BT_MESH_KEY_ANY, lpn_addr, true, true); if (!frnd) { - timeout_ms = 0; + timeout_steps = 0; goto send_rsp; } - timeout_ms = k_delayed_work_remaining_get(&frnd->timer) / 100; + /* PollTimeout should be reported in steps of 100ms. */ + timeout_steps = frnd->poll_to / 100; send_rsp: - net_buf_simple_add_le24(&msg, timeout_ms); + net_buf_simple_add_le24(&msg, timeout_steps); if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { BT_ERR("Unable to send LPN PollTimeout Status");