[mac] enable/disable radio together with MAC (#9156)

Fix the behavior of `Mac::SetEnabled` for also enabling/disabling
the radio.

This ensures that the radio is turned off when `otLinkSetEnabled(false)`
is used.
This commit is contained in:
Eduardo Montoya
2023-06-14 13:31:49 -07:00
committed by GitHub
parent 55e3440ee2
commit 068ec09135
2 changed files with 15 additions and 2 deletions
+14 -1
View File
@@ -119,7 +119,6 @@ Mac::Mac(Instance &aInstance)
ResetCounters();
SetEnabled(true);
mLinks.Enable();
Get<KeyManager>().UpdateKeyMaterial();
SetPanId(mPanId);
@@ -129,6 +128,20 @@ Mac::Mac(Instance &aInstance)
mMode2KeyMaterial.SetFrom(AsCoreType(&sMode2Key));
}
void Mac::SetEnabled(bool aEnable)
{
mEnabled = aEnable;
if (aEnable)
{
mLinks.Enable();
}
else
{
mLinks.Disable();
}
}
Error Mac::ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler, void *aContext)
{
Error error = kErrorNone;
+1 -1
View File
@@ -576,7 +576,7 @@ public:
* @param[in] aEnable The requested State for the MAC layer. true - Start, false - Stop.
*
*/
void SetEnabled(bool aEnable) { mEnabled = aEnable; }
void SetEnabled(bool aEnable);
/**
* Indicates whether or not the link layer is enabled.