bluetooth: mesh: fix lpn receive window timing error
APIs for enabling and disabling the scanner may take larger time than expected and scheduling of the lpn state machine is affected by it. Since these type of latencies are factored into timeouts and scheduling times, we need to call scan enable/disable APIs after scheduling the next event time for LPN state machine to be more accurate. Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
This commit is contained in:
parent
f33306ab2f
commit
c93859c659
1 changed files with 10 additions and 10 deletions
|
@ -296,11 +296,11 @@ static void clear_friendship(bool force, bool disable)
|
|||
if (!disable) {
|
||||
lpn_set_state(BT_MESH_LPN_ENABLED);
|
||||
|
||||
k_work_reschedule(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
|
||||
bt_mesh_scan_enable();
|
||||
}
|
||||
|
||||
k_work_reschedule(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
|
||||
}
|
||||
|
||||
if (was_established) {
|
||||
|
@ -570,7 +570,6 @@ static void friend_response_received(struct bt_mesh_lpn *lpn)
|
|||
lpn->fsn++;
|
||||
}
|
||||
|
||||
bt_mesh_scan_disable();
|
||||
lpn_set_state(BT_MESH_LPN_ESTABLISHED);
|
||||
lpn->req_attempts = 0U;
|
||||
lpn->sent_req = 0U;
|
||||
|
@ -581,6 +580,7 @@ static void friend_response_received(struct bt_mesh_lpn *lpn)
|
|||
int32_t timeout = poll_timeout(lpn);
|
||||
|
||||
k_work_reschedule(&lpn->timer, K_MSEC(timeout));
|
||||
bt_mesh_scan_disable();
|
||||
}
|
||||
|
||||
void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx)
|
||||
|
@ -857,9 +857,9 @@ static void update_timeout(struct bt_mesh_lpn *lpn)
|
|||
{
|
||||
if (lpn->established) {
|
||||
LOG_WRN("No response from Friend during ReceiveWindow");
|
||||
bt_mesh_scan_disable();
|
||||
lpn_set_state(BT_MESH_LPN_ESTABLISHED);
|
||||
k_work_reschedule(&lpn->timer, K_MSEC(POLL_RETRY_TIMEOUT));
|
||||
bt_mesh_scan_disable();
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
|
||||
bt_mesh_scan_disable();
|
||||
|
@ -903,19 +903,19 @@ static void lpn_timeout(struct k_work *work)
|
|||
send_friend_req(lpn);
|
||||
break;
|
||||
case BT_MESH_LPN_REQ_WAIT:
|
||||
bt_mesh_scan_enable();
|
||||
k_work_reschedule(&lpn->timer, K_MSEC(lpn->adv_duration + FRIEND_REQ_SCAN));
|
||||
lpn_set_state(BT_MESH_LPN_WAIT_OFFER);
|
||||
bt_mesh_scan_enable();
|
||||
break;
|
||||
case BT_MESH_LPN_WAIT_OFFER:
|
||||
LOG_WRN("No acceptable Friend Offers received");
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
|
||||
bt_mesh_scan_disable();
|
||||
}
|
||||
|
||||
lpn_set_state(BT_MESH_LPN_ENABLED);
|
||||
lpn->sent_req = 0U;
|
||||
k_work_reschedule(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
|
||||
bt_mesh_scan_disable();
|
||||
}
|
||||
break;
|
||||
case BT_MESH_LPN_ESTABLISHED:
|
||||
if (lpn->req_attempts < REQ_ATTEMPTS(lpn)) {
|
||||
|
@ -939,8 +939,8 @@ static void lpn_timeout(struct k_work *work)
|
|||
case BT_MESH_LPN_RECV_DELAY:
|
||||
k_work_reschedule(&lpn->timer,
|
||||
K_MSEC(SCAN_LATENCY + lpn->recv_win + RX_DELAY_CORRECTION(lpn)));
|
||||
bt_mesh_scan_enable();
|
||||
lpn_set_state(BT_MESH_LPN_WAIT_UPDATE);
|
||||
bt_mesh_scan_enable();
|
||||
break;
|
||||
case BT_MESH_LPN_WAIT_UPDATE:
|
||||
update_timeout(lpn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue