diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index 6ad3dcadb..4930f2bf0 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -45,8 +45,20 @@ static void HandleEnergyScanResult(void *aContext, otEnergyScanResult *aResult); uint8_t otLinkGetChannel(otInstance *aInstance) { Instance &instance = *static_cast(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(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);