From 11c08b86ab692e0fea47fe2933a233ee5d582ee4 Mon Sep 17 00:00:00 2001 From: Li Cao Date: Tue, 8 Dec 2020 01:53:11 +0800 Subject: [PATCH] [mac] stop timer before starting non-idle operation (#5921) --- src/core/mac/mac.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 8a285d38a..c5e873a88 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -845,6 +845,8 @@ void Mac::PerformNextOperation(void) if (mOperation != kOperationIdle) { otLogDebgMac("Starting operation \"%s\"", OperationToString(mOperation)); + mTimer.Stop(); // Stop the timer before any non-idle operation, have the operation itself be responsible to + // start the timer (if it wants to). } switch (mOperation) @@ -876,6 +878,7 @@ void Mac::PerformNextOperation(void) case kOperationWaitingForData: IgnoreError(mSubMac.Receive(mRadioChannel)); + mTimer.Start(kDataPollTimeout); break; } @@ -1416,7 +1419,6 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, otError aError if (IsEnabled() && framePending) { - mTimer.Start(kDataPollTimeout); StartOperation(kOperationWaitingForData); }