From 27336a95cf0ed74b4a3abca5d9cea2632a81f62e Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 20 Aug 2019 08:39:24 -0700 Subject: [PATCH] [sub-mac] relax the requirement for TxDone callback (#4113) This commit changes the `SubMac::BeginTrasnmit()` by moving the call to `Transmit()` on radio platform after the state change to `kStateTransmit` (and pcap callback). This relaxes the requirement for radio platform implementation and allow it to invoke `TxDone` callback directly from the `Transmit()` call itself (instead of requiring `TxDone` to be called only after the `Transmit()` call returns). --- src/core/mac/sub_mac.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index b6029352c..5f19197d9 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -286,9 +286,6 @@ void SubMac::BeginTransmit(void) error = Get().Receive(mTransmitFrame.GetChannel()); assert(error == OT_ERROR_NONE); - error = Get().Transmit(mTransmitFrame); - assert(error == OT_ERROR_NONE); - SetState(kStateTransmit); if (mPcapCallback) @@ -296,6 +293,9 @@ void SubMac::BeginTransmit(void) mPcapCallback(&mTransmitFrame, true, mPcapCallbackContext); } + error = Get().Transmit(mTransmitFrame); + assert(error == OT_ERROR_NONE); + exit: return; }