mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 11:10:08 +00:00
[link-raw] handle get/set channel when LinkRaw is enabled (#3559)
This commit updates `otLinkGetChannel()` and `otLinkSetChannel()` to handle the situation where raw-link mode is enabled.
This commit is contained in:
committed by
Jonathan Hui
parent
bd4ca8113d
commit
f31f8c1f3c
@@ -45,8 +45,20 @@ static void HandleEnergyScanResult(void *aContext, otEnergyScanResult *aResult);
|
||||
uint8_t otLinkGetChannel(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
uint8_t channel;
|
||||
|
||||
return instance.GetThreadNetif().GetMac().GetPanChannel();
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
if (instance.GetLinkRaw().IsEnabled())
|
||||
{
|
||||
channel = instance.GetLinkRaw().GetChannel();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
channel = instance.GetThreadNetif().GetMac().GetPanChannel();
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
|
||||
@@ -54,6 +66,14 @@ otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
|
||||
otError error;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
if (instance.GetLinkRaw().IsEnabled())
|
||||
{
|
||||
error = instance.GetLinkRaw().SetChannel(aChannel);
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
|
||||
VerifyOrExit(instance.GetThreadNetif().GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user