[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.
This commit is contained in:
Zhangwx
2025-11-20 21:50:52 -08:00
committed by GitHub
parent ae5075682b
commit e5b159a20f
+2
View File
@@ -131,6 +131,8 @@ void SubMac::SetCslParams(uint16_t aPeriod, uint8_t aChannel, ShortAddress aShor
{
mCslSampleTimeRadio = static_cast<uint32_t>(Get<Radio>().GetNow());
mCslSampleTimeLocal = TimerMicro::GetNow();
// Update CSL sync time whenever CSL parameters are re-initialized.
mCslLastSync = mCslSampleTimeLocal;
HandleCslTimer();
}