diff --git a/subsys/net/l2/openthread/openthread.c b/subsys/net/l2/openthread/openthread.c index bc441ca8d4c..d92bd067ae6 100644 --- a/subsys/net/l2/openthread/openthread.c +++ b/subsys/net/l2/openthread/openthread.c @@ -22,6 +22,8 @@ LOG_MODULE_REGISTER(net_l2_openthread, CONFIG_OPENTHREAD_L2_LOG_LEVEL); #include #include #include +#include +#include #include #include #include @@ -196,7 +198,7 @@ void ot_receive_handler(otMessage *aMessage, void *context) pkt_list_add(ot_context, pkt); pkt = NULL; } else { - NET_INFO("Pacet list is full"); + NET_INFO("Packet list is full"); } out: if (pkt) { @@ -341,7 +343,11 @@ static void openthread_start(struct openthread_context *ot_context) otLinkSetPollPeriod(ot_context->instance, OT_POLL_PERIOD); } - if (otDatasetIsCommissioned(ot_instance)) { + if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) { + /* In NCP mode wpantund will instruct what to do. */ + NET_DBG("OpenThread NCP."); + return; + } else if (otDatasetIsCommissioned(ot_instance)) { /* OpenThread already has dataset stored - skip the * configuration. */ @@ -401,13 +407,25 @@ static int openthread_init(struct net_if *iface) platformShellInit(ot_context->instance); } - otIp6SetEnabled(ot_context->instance, true); + if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) { + otNcpInit(ot_context->instance); + } - otIp6SetReceiveFilterEnabled(ot_context->instance, true); - otIp6SetReceiveCallback(ot_context->instance, - ot_receive_handler, ot_context); - otSetStateChangedCallback(ot_context->instance, - &ot_state_changed_handler, ot_context); + if (IS_ENABLED(CONFIG_OPENTHREAD_RAW)) { + otLinkRawSetEnable(ot_context->instance, true); + } else { + otIp6SetEnabled(ot_context->instance, true); + } + + if (!IS_ENABLED(CONFIG_OPENTHREAD_NCP)) { + otIp6SetReceiveFilterEnabled(ot_context->instance, true); + otIp6SetReceiveCallback(ot_context->instance, + ot_receive_handler, ot_context); + otSetStateChangedCallback( + ot_context->instance, + &ot_state_changed_handler, + ot_context); + } ll_addr = net_if_get_link_addr(iface); diff --git a/subsys/net/lib/openthread/platform/misc.c b/subsys/net/lib/openthread/platform/misc.c index 8484c22c877..b940c999413 100644 --- a/subsys/net/lib/openthread/platform/misc.c +++ b/subsys/net/lib/openthread/platform/misc.c @@ -25,3 +25,8 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance) return OT_PLAT_RESET_REASON_POWER_ON; } + +void otPlatWakeHost(void) +{ + /* TODO */ +} diff --git a/subsys/net/lib/openthread/platform/platform.c b/subsys/net/lib/openthread/platform/platform.c index 0495604b193..d5df9741d7d 100644 --- a/subsys/net/lib/openthread/platform/platform.c +++ b/subsys/net/lib/openthread/platform/platform.c @@ -29,4 +29,8 @@ void otSysProcessDrivers(otInstance *aInstance) { platformRadioProcess(aInstance); platformAlarmProcess(aInstance); + + if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) { + platformUartProcess(aInstance); + } } diff --git a/subsys/net/lib/openthread/platform/radio.c b/subsys/net/lib/openthread/platform/radio.c index b12e2f1ca1d..8e3ebf0be28 100644 --- a/subsys/net/lib/openthread/platform/radio.c +++ b/subsys/net/lib/openthread/platform/radio.c @@ -432,6 +432,24 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, u8_t aScanChannel, return OT_ERROR_NONE; } +otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, + int8_t *aThreshold) +{ + OT_UNUSED_VARIABLE(aInstance); + OT_UNUSED_VARIABLE(aThreshold); + + return OT_ERROR_NOT_IMPLEMENTED; +} + +otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, + int8_t aThreshold) +{ + OT_UNUSED_VARIABLE(aInstance); + OT_UNUSED_VARIABLE(aThreshold); + + return OT_ERROR_NOT_IMPLEMENTED; +} + void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) { ARG_UNUSED(aInstance);