From a68cd059cc7293b6a2ed449bfc9cd944a4ca3ed3 Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Mon, 18 Jul 2022 23:12:20 +0200 Subject: [PATCH] [csl] update CSL information in radio when parent changes (#7911) Cover the case of parent change while the CSL child is still attached. --- src/core/mac/sub_mac.cpp | 9 ++++++--- src/core/mac/sub_mac.hpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 01243de7a..7d5cccdc9 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -97,6 +97,7 @@ void SubMac::Init(void) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE mCslPeriod = 0; mCslChannel = 0; + mCslPeerShort = 0; mIsCslSampling = false; mCslSampleTime = TimeMicro{0}; mCslLastSync = TimeMicro{0}; @@ -1051,13 +1052,15 @@ bool SubMac::UpdateCsl(uint16_t aPeriod, uint8_t aChannel, otShortAddress aShort { bool diffPeriod = aPeriod != mCslPeriod; bool diffChannel = aChannel != mCslChannel; - bool retval = diffPeriod || diffChannel; + bool diffPeer = aShortAddr != mCslPeerShort; + bool retval = diffPeriod || diffChannel || diffPeer; VerifyOrExit(retval); mCslChannel = aChannel; - VerifyOrExit(diffPeriod); - mCslPeriod = aPeriod; + VerifyOrExit(diffPeriod || diffPeer); + mCslPeriod = aPeriod; + mCslPeerShort = aShortAddr; IgnoreError(Get().EnableCsl(aPeriod, aShortAddr, aExtAddr)); mCslTimer.Stop(); diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index 0904351e3..8eccfe9f5 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -662,6 +662,7 @@ private: uint8_t mCslChannel : 7; // The CSL sample channel. bool mIsCslSampling : 1; // Indicates that the radio is receiving in CSL state for platforms not supporting delayed // reception. + uint16_t mCslPeerShort; // The CSL peer short address. TimeMicro mCslSampleTime; // The CSL sample time of the current period. TimeMicro mCslLastSync; // The timestamp of the last successful CSL synchronization. uint8_t mCslParentAccuracy; // Drift of timer used for scheduling CSL tx by the parent, in ± ppm.