[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:
Abtin Keshavarzian
2019-02-06 08:42:37 -08:00
committed by Jonathan Hui
parent bd4ca8113d
commit f31f8c1f3c
+21 -1
View File
@@ -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);