From e5b159a20fec6504ada7d3eb58e9aa6152cffadb Mon Sep 17 00:00:00 2001 From: Zhangwx Date: Fri, 21 Nov 2025 13:50:52 +0800 Subject: [PATCH] [csl] update CSL sync time whenever CSL parameters are re-initialized (#12161) When the CSL feature is first enabled on a child device, the OpenThread stack starts CSL sampling before sending the Child Update Request packet. The last CSL sync sample time, initialized as `0`, is updated only when the Child Update Request is sent. However, since CSL sampling begins earlier, the first CSL receive operation calculates the elapsed time in `GetCslWindowEdges` using `0` as the last sync time. Similarly, when CSL parameters are re-initialized, the stack should update `mCslLastSync`. Continuing to use an outdated sync time results in inaccurate calculations and is not reasonable behavior. This commit fixed this issue. --- src/core/mac/sub_mac_csl_receiver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/mac/sub_mac_csl_receiver.cpp b/src/core/mac/sub_mac_csl_receiver.cpp index bfe032659..01ab254eb 100644 --- a/src/core/mac/sub_mac_csl_receiver.cpp +++ b/src/core/mac/sub_mac_csl_receiver.cpp @@ -131,6 +131,8 @@ void SubMac::SetCslParams(uint16_t aPeriod, uint8_t aChannel, ShortAddress aShor { mCslSampleTimeRadio = static_cast(Get().GetNow()); mCslSampleTimeLocal = TimerMicro::GetNow(); + // Update CSL sync time whenever CSL parameters are re-initialized. + mCslLastSync = mCslSampleTimeLocal; HandleCslTimer(); }