From ba1d46035b8ef1c8e5804a6fe63e9c69684d6290 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 3 Jan 2019 09:19:50 -0800 Subject: [PATCH] [mac] post operation task on rx-on-idle mode change (#3425) The `SetRxOnWhenIdle()` is changed such that if it needs to stop operation `WaitingForData`, the next operation gets started from the `mOperationTask` tasklet. This change makes the behavior of the `SetRxOnWhenIdle()` consistent with other MAC APIs (i.e., new operations are started only from tasklet or from a radio/timer callback and not from any MAC APIs). This commit also updates the `HandleTimer()` to check for operation being `kOperationIdle` when timer is used for delaying sleep. --- src/core/mac/mac.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 1ed3d8da8..c21914ff2 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -329,7 +329,7 @@ void Mac::SetRxOnWhenIdle(bool aRxOnWhenIdle) { mTimer.Stop(); FinishOperation(); - PerformNextOperation(); + mOperationTask.Post(); } #if OPENTHREAD_CONFIG_STAY_AWAKE_BETWEEN_FRAGMENTS @@ -1232,14 +1232,20 @@ void Mac::HandleTimer(void) PerformNextOperation(); break; - default: #if OPENTHREAD_CONFIG_STAY_AWAKE_BETWEEN_FRAGMENTS - otLogDebgMac("Sleep delay timeout expired"); - mDelayingSleep = false; - UpdateIdleMode(); -#else - assert(false); + case kOperationIdle: + if (mDelayingSleep) + { + otLogDebgMac("Sleep delay timeout expired"); + mDelayingSleep = false; + UpdateIdleMode(); + } + + break; #endif + + default: + assert(false); break; } }