net: openthread: Add NCP start-up and required platform changes
When NCP starts-up some of the initialisation functions of a regular OpenThread device do not need to be called, because they get triggered by wpantund via UART. Instead NCP initialisation needs to be called. A small typo has been fixed as well. Also initialisation for raw link packet interface has been added. Can be used for picking up 802.15.4 frames and interpreting them in the application. Signed-off-by: Markus Becker <markus.becker@tridonic.com>
This commit is contained in:
parent
71ce94e0ed
commit
0651141d84
4 changed files with 53 additions and 8 deletions
|
@ -22,6 +22,8 @@ LOG_MODULE_REGISTER(net_l2_openthread, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
|
|||
#include <openthread/cli.h>
|
||||
#include <openthread/ip6.h>
|
||||
#include <openthread/link.h>
|
||||
#include <openthread/link_raw.h>
|
||||
#include <openthread/ncp.h>
|
||||
#include <openthread/message.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/tasklet.h>
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -25,3 +25,8 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
|||
|
||||
return OT_PLAT_RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
||||
void otPlatWakeHost(void)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
|
|
@ -29,4 +29,8 @@ void otSysProcessDrivers(otInstance *aInstance)
|
|||
{
|
||||
platformRadioProcess(aInstance);
|
||||
platformAlarmProcess(aInstance);
|
||||
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) {
|
||||
platformUartProcess(aInstance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue