From 7b6071671304b5b6bb1fdcd6b8b845f568b6c4f5 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 19 Jul 2022 15:55:59 -0700 Subject: [PATCH] [csl] ensure `SubMac`is informed when CSL support changes (#7918) This commit changes `Mac::UpdateCsl()` to ensure we inform `SubMac` and disable CSL when CSL support changes (e.g., device gets detached). This ensures that `SubMac` internal variables (CSL period, channel) are updated on a detach and if the device later attaches again, we detect the change in CSL configuration and trigger the tx of MLE Child Update Request. --- src/core/mac/mac.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index dbe3c974a..8ad0518fe 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2267,27 +2267,24 @@ exit: #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE void Mac::UpdateCsl(void) { - uint16_t period; - uint8_t channel; - - VerifyOrExit(IsCslSupported()); - - period = Get().IsRxOnWhenIdle() ? 0 : GetCslPeriod(); - channel = GetCslChannel() ? GetCslChannel() : mRadioChannel; + uint16_t period = IsCslEnabled() ? GetCslPeriod() : 0; + uint8_t channel = GetCslChannel() ? GetCslChannel() : mRadioChannel; if (mLinks.UpdateCsl(period, channel, Get().GetParent().GetRloc16(), &Get().GetParent().GetExtAddress())) { - Get().RecalculatePollPeriod(); - if (period) + if (Get().IsChild()) { - Get().ScheduleChildUpdateRequest(); + Get().RecalculatePollPeriod(); + + if (period != 0) + { + Get().ScheduleChildUpdateRequest(); + } } + UpdateIdleMode(); } - -exit: - return; } void Mac::SetCslChannel(uint8_t aChannel)