[link-raw] do not disable link raw during transmit/scan operation (#6026)

This commit is contained in:
Jonathan Hui
2021-01-05 09:36:30 -08:00
committed by GitHub
parent f64c597fc6
commit ee4bdc6bbe
2 changed files with 22 additions and 4 deletions
+13 -4
View File
@@ -66,9 +66,10 @@ LinkRaw::LinkRaw(Instance &aInstance)
otError LinkRaw::SetReceiveDone(otLinkRawReceiveDone aCallback)
{
otError error = OT_ERROR_NONE;
otError error = OT_ERROR_NONE;
bool enable = aCallback != nullptr;
otLogDebgMac("LinkRaw::Enabled(%s)", (aCallback != nullptr ? "true" : "false"));
otLogDebgMac("LinkRaw::Enabled(%s)", (enable ? "true" : "false"));
#if OPENTHREAD_MTD || OPENTHREAD_FTD
VerifyOrExit(!Get<ThreadNetif>().IsUp(), error = OT_ERROR_INVALID_STATE);
@@ -78,9 +79,17 @@ otError LinkRaw::SetReceiveDone(otLinkRawReceiveDone aCallback)
// avoid any conflict in control of radio and sub-mac between `Mac` and
// `LinkRaw`. in RADIO build, we directly enable/disable sub-mac.
Get<Mac>().SetEnabled(aCallback == nullptr);
if (!enable)
{
// When disabling link-raw, make sure there is no ongoing
// transmit or scan operation. Otherwise Mac will attempt to
// handle an unexpected "done" callback.
VerifyOrExit(!mSubMac.IsTransmittingOrScanning(), error = OT_ERROR_BUSY);
}
Get<Mac>().SetEnabled(!enable);
#else
if (aCallback)
if (enable)
{
SuccessOrExit(error = mSubMac.Enable());
}
+9
View File
@@ -287,6 +287,15 @@ public:
*/
otError Sleep(void);
/**
* This method indicates whether the sub-mac is busy transmitting or scanning.
*
* @retval TRUE if the sub-mac is busy transmitting or scanning.
* @retval FALSE if the sub-mac is not busy transmitting or scanning.
*
*/
bool IsTransmittingOrScanning(void) const { return (mState == kStateTransmit) || (mState == kStateEnergyScan); }
/**
* This method transitions the radio to Receive.
*