From f31f8c1f3c786a2465000e0ae18b85238618475f Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 6 Feb 2019 08:42:37 -0800 Subject: [PATCH] [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. --- src/core/api/link_api.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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);