From 68e3b049b58b22c503df9bddb8507c0c9c2a55f1 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 26 Jul 2021 21:46:13 -0700 Subject: [PATCH] [radio-spinel] fix incorrect RX channel after frame TX on another channel (#6837) This commit fixes a bug in `RadioSpinel` platform implementation where the request from OT core stack to enter RX mode may be ignored causing the RCP/radio to stay in RX mode on an incorrect channel. This situation can happen after a frame TX request on a different channel (note that the `otRadioFrame` struct specifies the channel on which the frame should be transmitted). After frame TX, radio driver is expected to enter RX mode on the same channel on which the frame TX happened. The OpenThread MAC layer always explicitly instructs the radio to enter RX mode on the PAN channel (from `Mac::UpdateIdleMode()` which in turn calls the radio platform API `otPlatRadioRecive()` with the channel passed in as a parameter). The earlier `RadioSpinel` platform implementation did not update `mChannel` on a tx request which caused the subsequent `Receive()` to skip setting the channel on RCP if the channel was same as before. --- src/lib/spinel/radio_spinel_impl.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/spinel/radio_spinel_impl.hpp b/src/lib/spinel/radio_spinel_impl.hpp index 5a113e52a..dfeee4b55 100644 --- a/src/lib/spinel/radio_spinel_impl.hpp +++ b/src/lib/spinel/radio_spinel_impl.hpp @@ -1514,6 +1514,8 @@ otError RadioSpinel::EnergyScan(uint8_t aScan SuccessOrExit(error = Set(SPINEL_PROP_MAC_SCAN_PERIOD, SPINEL_DATATYPE_UINT16_S, aScanDuration)); SuccessOrExit(error = Set(SPINEL_PROP_MAC_SCAN_STATE, SPINEL_DATATYPE_UINT8_S, SPINEL_SCAN_STATE_ENERGY)); + mChannel = aScanChannel; + exit: return error; } @@ -1923,6 +1925,7 @@ otError RadioSpinel::Transmit(otRadioFrame &a // Waiting for `TransmitDone` event. mState = kStateTransmitting; mTxRadioEndUs = otPlatTimeGet() + TX_WAIT_US; + mChannel = mTransmitFrame->mChannel; } exit: