Skip to content

Commit ce3c875

Browse files
alxelaxmbolivar-nordic
authored andcommitted
[nrf fromlist] Bluetooth: Mesh: correction lpn rx delay
If extended advertiser is used, then advertiser sends callback quite close to the real tx end time. No necessity to consider advertisement time in lpn rx delay. It allows lpn to spend less time in active scanning and save more power. Unfortunately, legacy advertiser shows very slow precision. It is mandatory to consider adv time for it. Additionally, unnecessary considering of the advertisement duration has been removed for receive window in lpn. It makes scanner window longer for a couple of milliseconds. This is the responsibility of friend node to configure window that it can manage. Upstream PR: zephyrproject-rtos/zephyr#54679 Signed-off-by: Aleksandr Khromykh <[email protected]> (cherry picked from commit 8713810)
1 parent 4786f1a commit ce3c875

File tree

1 file changed

+8
-3
lines changed
  • subsys/bluetooth/mesh

1 file changed

+8
-3
lines changed

subsys/bluetooth/mesh/lpn.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ LOG_MODULE_REGISTER(bt_mesh_lpn);
3838
CONFIG_LOG_MODE_DEFERRED Kconfig option when Low Power node feature is enabled.
3939
#endif
4040

41+
#if defined(CONFIG_BT_MESH_ADV_LEGACY)
42+
#define RX_DELAY_CORRECTION(lpn) ((lpn)->adv_duration)
43+
#else
44+
#define RX_DELAY_CORRECTION(lpn) 0
45+
#endif
46+
4147
#if defined(CONFIG_BT_MESH_LPN_AUTO)
4248
#define LPN_AUTO_TIMEOUT (CONFIG_BT_MESH_LPN_AUTO_TIMEOUT * MSEC_PER_SEC)
4349
#else
@@ -414,8 +420,7 @@ static void req_send_end(int err, void *user_data)
414420
* response data due to HCI and other latencies.
415421
*/
416422
k_work_reschedule(&lpn->timer,
417-
K_MSEC(LPN_RECV_DELAY - SCAN_LATENCY -
418-
(int32_t)lpn->adv_duration));
423+
K_MSEC(LPN_RECV_DELAY - SCAN_LATENCY - RX_DELAY_CORRECTION(lpn)));
419424
} else {
420425
lpn_set_state(BT_MESH_LPN_WAIT_UPDATE);
421426
k_work_reschedule(&lpn->timer, K_MSEC(LPN_RECV_DELAY + lpn->recv_win));
@@ -912,7 +917,7 @@ static void lpn_timeout(struct k_work *work)
912917
break;
913918
case BT_MESH_LPN_RECV_DELAY:
914919
k_work_reschedule(&lpn->timer,
915-
K_MSEC(lpn->adv_duration + SCAN_LATENCY + lpn->recv_win));
920+
K_MSEC(SCAN_LATENCY + lpn->recv_win + RX_DELAY_CORRECTION(lpn)));
916921
bt_mesh_scan_enable();
917922
lpn_set_state(BT_MESH_LPN_WAIT_UPDATE);
918923
break;

0 commit comments

Comments
 (0)