mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 16:50:05 +00:00
[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:
+14
-1
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user