Skip to content

Bluetooth: Mesh: Report configured LPNTimeout in cfg_srv #34312

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

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions subsys/bluetooth/mesh/cfg_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,8 +2045,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);

Expand All @@ -2062,20 +2062,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");
Expand Down