diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 1157fbd89..59a60aebf 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2387,10 +2387,14 @@ void Mac::SetCslPeriod(uint16_t aPeriod) Get().RecalculatePollPeriod(); - if (IsCslEnabled()) + if ((GetCslPeriod() == 0) || IsCslEnabled()) { IgnoreError(Get().EnableCsl(GetCslPeriod(), Get().GetParent().GetRloc16(), &Get().GetParent().GetExtAddress())); + } + + if (IsCslEnabled()) + { Get().ScheduleChildUpdateRequest(); } @@ -2399,7 +2403,12 @@ void Mac::SetCslPeriod(uint16_t aPeriod) bool Mac::IsCslEnabled(void) const { - return (GetCslPeriod() > 0) && !GetRxOnWhenIdle() && Get().IsChild() && + return !GetRxOnWhenIdle() && IsCslCapable(); +} + +bool Mac::IsCslCapable(void) const +{ + return (GetCslPeriod() > 0) && Get().IsChild() && Get().GetParent().IsEnhancedKeepAliveSupported(); } diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 7a0e2e763..88262a3a6 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -702,6 +702,14 @@ public: */ bool IsCslEnabled(void) const; + /** + * This method indicates whether Link is capable of starting CSL. + * + * @retval TURE if Link is capable of starting CSL, FALSE otherwise. + * + */ + bool IsCslCapable(void) const; + /** * This method returns CSL parent clock accuracy, in ± ppm. * @@ -739,7 +747,6 @@ public: { mLinks.GetSubMac().SetCslParentUncertainty(aCslParentUncert); } - #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE private: diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 8d6e13c4e..21b1b8e34 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -692,10 +692,10 @@ void Mle::SetStateChild(uint16_t aRloc16) #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE - if (Get().IsCslEnabled()) + if (Get().IsCslCapable()) { - IgnoreError(Get().EnableCsl(Get().GetCslPeriod(), GetParent().GetRloc16(), - &GetParent().GetExtAddress())); + uint32_t period = IsRxOnWhenIdle() ? 0 : Get().GetCslPeriod(); + IgnoreError(Get().EnableCsl(period, GetParent().GetRloc16(), &GetParent().GetExtAddress())); ScheduleChildUpdateRequest(); } #endif