mirror of
https://github.com/espressif/openthread.git
synced 2026-10-08 00:37:40 +00:00
[csl] fix switch between SSED -> MED -> SSED modes (#6891)
This commit introduces two changes. First is adding capability to turn off CSL, by implementing missing 0 value handling. Secondly adds proper transition between SSED (CSL on) and MED states (CSL off).
This commit is contained in:
+11
-2
@@ -2387,10 +2387,14 @@ void Mac::SetCslPeriod(uint16_t aPeriod)
|
|||||||
|
|
||||||
Get<DataPollSender>().RecalculatePollPeriod();
|
Get<DataPollSender>().RecalculatePollPeriod();
|
||||||
|
|
||||||
if (IsCslEnabled())
|
if ((GetCslPeriod() == 0) || IsCslEnabled())
|
||||||
{
|
{
|
||||||
IgnoreError(Get<Radio>().EnableCsl(GetCslPeriod(), Get<Mle::Mle>().GetParent().GetRloc16(),
|
IgnoreError(Get<Radio>().EnableCsl(GetCslPeriod(), Get<Mle::Mle>().GetParent().GetRloc16(),
|
||||||
&Get<Mle::Mle>().GetParent().GetExtAddress()));
|
&Get<Mle::Mle>().GetParent().GetExtAddress()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsCslEnabled())
|
||||||
|
{
|
||||||
Get<Mle::Mle>().ScheduleChildUpdateRequest();
|
Get<Mle::Mle>().ScheduleChildUpdateRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2399,7 +2403,12 @@ void Mac::SetCslPeriod(uint16_t aPeriod)
|
|||||||
|
|
||||||
bool Mac::IsCslEnabled(void) const
|
bool Mac::IsCslEnabled(void) const
|
||||||
{
|
{
|
||||||
return (GetCslPeriod() > 0) && !GetRxOnWhenIdle() && Get<Mle::MleRouter>().IsChild() &&
|
return !GetRxOnWhenIdle() && IsCslCapable();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Mac::IsCslCapable(void) const
|
||||||
|
{
|
||||||
|
return (GetCslPeriod() > 0) && Get<Mle::MleRouter>().IsChild() &&
|
||||||
Get<Mle::Mle>().GetParent().IsEnhancedKeepAliveSupported();
|
Get<Mle::Mle>().GetParent().IsEnhancedKeepAliveSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -702,6 +702,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool IsCslEnabled(void) const;
|
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.
|
* This method returns CSL parent clock accuracy, in ± ppm.
|
||||||
*
|
*
|
||||||
@@ -739,7 +747,6 @@ public:
|
|||||||
{
|
{
|
||||||
mLinks.GetSubMac().SetCslParentUncertainty(aCslParentUncert);
|
mLinks.GetSubMac().SetCslParentUncertainty(aCslParentUncert);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -692,10 +692,10 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||||
if (Get<Mac::Mac>().IsCslEnabled())
|
if (Get<Mac::Mac>().IsCslCapable())
|
||||||
{
|
{
|
||||||
IgnoreError(Get<Radio>().EnableCsl(Get<Mac::Mac>().GetCslPeriod(), GetParent().GetRloc16(),
|
uint32_t period = IsRxOnWhenIdle() ? 0 : Get<Mac::Mac>().GetCslPeriod();
|
||||||
&GetParent().GetExtAddress()));
|
IgnoreError(Get<Radio>().EnableCsl(period, GetParent().GetRloc16(), &GetParent().GetExtAddress()));
|
||||||
ScheduleChildUpdateRequest();
|
ScheduleChildUpdateRequest();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user