mirror of
https://github.com/espressif/openthread.git
synced 2026-10-19 14:08:13 +00:00
[link-raw] disable/enable MAC layer when link-raw is enabled/disabled (#5956)
This commit addresses an issue with `LinkRaw` on FTD/MTD builds. In FTD/MTD builds, we add code to disable/enable MAC layer when link-raw is being enabled/disabled. This ensures to avoid any conflict in control of radio and sub-mac between `Mac` and `LinkRaw`. In RADIO build, we directly enable/disable sub-mac (note that in FTD/MTD build then `Mac` layer would be enable sub-mac).
This commit is contained in:
@@ -72,8 +72,14 @@ otError LinkRaw::SetReceiveDone(otLinkRawReceiveDone aCallback)
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
VerifyOrExit(!Get<ThreadNetif>().IsUp(), error = OT_ERROR_INVALID_STATE);
|
||||
#endif
|
||||
|
||||
// In MTD/FTD build, `Mac` has already enabled sub-mac. We ensure to
|
||||
// disable/enable MAC layer when link-raw is being enabled/disabled to
|
||||
// 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);
|
||||
#else
|
||||
if (aCallback)
|
||||
{
|
||||
SuccessOrExit(error = mSubMac.Enable());
|
||||
@@ -82,6 +88,7 @@ otError LinkRaw::SetReceiveDone(otLinkRawReceiveDone aCallback)
|
||||
{
|
||||
IgnoreError(mSubMac.Disable());
|
||||
}
|
||||
#endif
|
||||
|
||||
mReceiveDoneCallback = aCallback;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user