net: openthread: OpenThread RCP mode integration into Zephyr
* Add RCP library. * Conditionally remove non required libraries not required for RCP. * Drop :option: marker for CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM Signed-off-by: Markus Becker <markus.becker@tridonic.com>
This commit is contained in:
parent
65395f30ec
commit
638b5f389f
|
@ -576,7 +576,6 @@ Drivers and Sensors
|
|||
application relies on any of the following Kconfig options, then
|
||||
it shall also enable the USB subsystem:
|
||||
|
||||
* :option:`CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM`
|
||||
* :option:`CONFIG_USB_DEVICE_NETWORK_ECM`
|
||||
* :option:`CONFIG_USB_DEVICE_NETWORK_EEM`
|
||||
* :option:`CONFIG_USB_DEVICE_NETWORK_RNDIS`
|
||||
|
|
60
samples/net/openthread/coprocessor/README.rst
Normal file
60
samples/net/openthread/coprocessor/README.rst
Normal file
|
@ -0,0 +1,60 @@
|
|||
.. _coprocessor-sample:
|
||||
|
||||
OpenThread Co-Processor
|
||||
#######################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
OpenThread Co-Processor allows building a Thread Border Router. The code in this
|
||||
sample is only the MCU target part of a complete Thread Border Router.
|
||||
The Co-Processor can act in two variants: Network Co-Processor (NCP) and Radio
|
||||
Co-Processor (RCP), see https://openthread.io/platforms/co-processor.
|
||||
|
||||
Additional required host-side tools (e.g. otbr-agent) to build a Thread Border
|
||||
Router can be obtained by following
|
||||
https://openthread.io/guides/border-router/build#set-up-the-border-router.
|
||||
|
||||
The preferred Co-Processor configuration of OpenThread is RCP now.
|
||||
|
||||
The source code for this sample application can be found at:
|
||||
:zephyr_file:`samples/net/openthread/coprocessor`.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
Build the OpenThread NCP sample application like this:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/openthread/coprocessor
|
||||
:board: <board to use>
|
||||
:conf: <config file to use>
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
Example building for the nrf52840dk_nrf52840 for RCP:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/openthread/coprocessor
|
||||
:host-os: unix
|
||||
:board: nrf52840dk_nrf52840
|
||||
:conf: "prj.conf overlay-rcp.conf"
|
||||
:goals: run
|
||||
:compact:
|
||||
|
||||
There are configuration files for different boards and setups in the
|
||||
coprocessor directory:
|
||||
|
||||
- :file:`prj.conf`
|
||||
Generic NCP config file. Use this, if you want the NCP configuration.
|
||||
|
||||
- :file:`overlay-rcp.conf`
|
||||
RCP overlay file. Use this in combination with prj.conf, if you want the RCP
|
||||
configuration.
|
||||
|
||||
- :file:`overlay-tri-n4m-br.conf`
|
||||
This is an overlay for the dedicated Thread Border Router hardware
|
||||
https://www.tridonic.com/com/en/products/net4more-borderROUTER-PoE-Thread.asp.
|
||||
The board support is not part of the Zephyr repositories, but the
|
||||
product is based on NXP K64 and AT86RF233. This file can be used as an
|
||||
example for a development set-up based on development boards.
|
7
samples/net/openthread/coprocessor/overlay-rcp.conf
Normal file
7
samples/net/openthread/coprocessor/overlay-rcp.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This overlay switches from NCP to RCP, use in combination with prj.conf
|
||||
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_NCP=n
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_RCP=y
|
||||
|
||||
CONFIG_NET_PKT_RX_COUNT=8
|
||||
CONFIG_NET_PKT_TX_COUNT=8
|
|
@ -4,17 +4,18 @@ CONFIG_UART_SHELL_ON_DEV_NAME="UART_0"
|
|||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0"
|
||||
CONFIG_SHELL_PROMPT_UART="ncp-uart:~$ "
|
||||
|
||||
# Use UART_1 for NCP
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME="UART_1"
|
||||
# Use UART_1 for Co-Processor
|
||||
#CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="UART_1"
|
||||
|
||||
# Use USB-CDC-ACM for NCP
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
|
||||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DEVICE_STACK=y
|
||||
CONFIG_USB_DEVICE_PRODUCT="OpenThread NCP K64"
|
||||
CONFIG_USB_DEVICE_PRODUCT="OpenThread Co-Processor K64"
|
||||
CONFIG_LOG=y
|
||||
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
|
||||
CONFIG_USB_CDC_ACM=y
|
|
@ -5,12 +5,12 @@ CONFIG_UART_SHELL_ON_DEV_NAME="UART_0"
|
|||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0"
|
||||
CONFIG_SHELL_PROMPT_UART="ncp-uart:~$ "
|
||||
|
||||
# Use USB-CDC-ACM for NCP
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
# Use USB-CDC-ACM for Co-Processor
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DEVICE_STACK=y
|
||||
CONFIG_USB_DEVICE_PRODUCT="OpenThread NCP NRF"
|
||||
CONFIG_USB_DEVICE_PRODUCT="OpenThread CoProcessor NRF"
|
||||
CONFIG_USB_CDC_ACM=y
|
||||
CONFIG_UART_LINE_CTRL=y
|
||||
CONFIG_USB_REQUEST_BUFFER_SIZE=2048
|
38
samples/net/openthread/coprocessor/prj.conf
Normal file
38
samples/net/openthread/coprocessor/prj.conf
Normal file
|
@ -0,0 +1,38 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_L2_OPENTHREAD=y
|
||||
|
||||
# Disable certain parts of Zephyr IPv6 stack
|
||||
CONFIG_NET_IPV6_NBR_CACHE=n
|
||||
CONFIG_NET_IPV6_MLD=n
|
||||
|
||||
# Logging
|
||||
CONFIG_LOG=y
|
||||
CONFIG_LOG_MAX_LEVEL=1
|
||||
CONFIG_LOG_MINIMAL=n
|
||||
CONFIG_LOG_BACKEND_SPINEL=y
|
||||
CONFIG_LOG_BACKEND_RTT=y
|
||||
CONFIG_LOG_BACKEND_UART=n
|
||||
CONFIG_BOOT_BANNER=n
|
||||
|
||||
# Kernel options
|
||||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
# Increase logging thread stack size due to Spinel backend needs
|
||||
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
|
||||
|
||||
# Set OpenThread NCP architecture
|
||||
CONFIG_OPENTHREAD_COPROCESSOR=y
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_NCP=y
|
||||
|
||||
# Add features required for NCP
|
||||
CONFIG_OPENTHREAD_DIAG=y
|
||||
CONFIG_OPENTHREAD_DHCP6_SERVER=y
|
||||
CONFIG_OPENTHREAD_COMMISSIONER=y
|
||||
CONFIG_OPENTHREAD_BORDER_AGENT=y
|
||||
CONFIG_OPENTHREAD_BORDER_ROUTER=y
|
||||
CONFIG_OPENTHREAD_UDP_FORWARD=y
|
||||
CONFIG_OPENTHREAD_ENABLE_SERVICE=y
|
||||
|
||||
# Move console to other UART to not interfere with NCP
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1"
|
|
@ -17,13 +17,13 @@ LOG_MODULE_REGISTER(ot_br, LOG_LEVEL_DBG);
|
|||
|
||||
void main(void)
|
||||
{
|
||||
#if defined(CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM)
|
||||
#if defined(CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM)
|
||||
const struct device *dev;
|
||||
uint32_t baudrate = 0U;
|
||||
int ret;
|
||||
|
||||
dev = device_get_binding(
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME);
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME);
|
||||
if (!dev) {
|
||||
LOG_ERR("UART device not found");
|
||||
return;
|
||||
|
@ -44,7 +44,7 @@ void main(void)
|
|||
} else {
|
||||
LOG_INF("Baudrate detected: %d", baudrate);
|
||||
}
|
||||
#endif /* CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM */
|
||||
#endif /* CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM */
|
||||
|
||||
LOG_INF(APP_BANNER, CONFIG_NET_SAMPLE_APPLICATION_VERSION);
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
.. _ncp-sample:
|
||||
|
||||
OpenThread NCP
|
||||
##############
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
OpenThread NCP allows building a Thread Border Router. The code in this
|
||||
sample is only the MCU target part of a complete Thread Border Router.
|
||||
The Linux tools from https://openthread.io/guides/border-router
|
||||
(especially wpantund and wpanctl) are required to get a complete Thread
|
||||
Border Router.
|
||||
|
||||
The source code for this sample application can be found at:
|
||||
:zephyr_file:`samples/net/openthread/ncp`.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
Build the OpenThread NCP sample application like this:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/openthread/ncp
|
||||
:board: <board to use>
|
||||
:conf: <config file to use>
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
There are configuration files for different boards and setups in the
|
||||
ncp directory:
|
||||
|
||||
- :file:`prj.conf`
|
||||
Generic config file, normally you should use this.
|
||||
|
||||
- :file:`overlay-tri-n4m-br.conf`
|
||||
This is an overlay for the dedicated Thread Border Router hardware
|
||||
https://www.tridonic.com/com/en/products/net4more-borderROUTER-PoE-Thread.asp.
|
||||
The board support is not part of the Zephyr repositories, but the
|
||||
product is based on NXP K64 and AT86RF233. This file can be used as an
|
||||
example for a development set-up based on development boards.
|
|
@ -1,69 +0,0 @@
|
|||
# Generic networking options
|
||||
CONFIG_NETWORKING=y
|
||||
|
||||
CONFIG_NET_CONFIG_NEED_IPV6=y
|
||||
CONFIG_NET_CONFIG_NEED_IPV4=n
|
||||
|
||||
# disable certain parts of Zephyr IPv6 stack
|
||||
CONFIG_NET_IPV6_NBR_CACHE=n
|
||||
CONFIG_NET_IPV6_MLD=n
|
||||
|
||||
# Kernel options
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_MAIN_STACK_SIZE=4096
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
#CONFIG_DEBUG_OPTIMIZATIONS=y
|
||||
|
||||
# Logging
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_PRINTK=y
|
||||
|
||||
# Network buffers
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=80
|
||||
CONFIG_NET_BUF_TX_COUNT=80
|
||||
CONFIG_NET_CONTEXT_NET_PKT_POOL=y
|
||||
|
||||
# Thread by default registers quite a lot addresses.
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
# Allow monitoring of stacks
|
||||
# CONFIG_KERNEL_SHELL=y
|
||||
|
||||
# mbedTLS tweaks
|
||||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=768
|
||||
# CONFIG_MBEDTLS_DEBUG=y
|
||||
# CONFIG_MBEDTLS_DEBUG_LEVEL=4
|
||||
|
||||
# Enable OpenThread
|
||||
CONFIG_NET_L2_OPENTHREAD=y
|
||||
|
||||
# Configure OpenThread
|
||||
CONFIG_OPENTHREAD_CHANNEL=26
|
||||
# Use PANID 0xffff to be able to commission
|
||||
CONFIG_OPENTHREAD_PANID=65535
|
||||
|
||||
# Increase a few stack and other sizes for OpenThread
|
||||
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
|
||||
CONFIG_SHELL_STACK_SIZE=3072
|
||||
CONFIG_OPENTHREAD_THREAD_STACK_SIZE=8192
|
||||
CONFIG_OPENTHREAD_PKT_LIST_SIZE=20
|
||||
|
||||
# Settings for the Border Router
|
||||
# from https://openthread.io/guides/border-router/build#build-and-flash-ncp
|
||||
|
||||
# CONFIG_OPENTHREAD_DHCP6_CLIENT is not set
|
||||
CONFIG_OPENTHREAD_DHCP6_SERVER=y
|
||||
CONFIG_OPENTHREAD_COMMISSIONER=y
|
||||
CONFIG_OPENTHREAD_BORDER_AGENT=y
|
||||
CONFIG_OPENTHREAD_BORDER_ROUTER=y
|
||||
CONFIG_OPENTHREAD_UDP_FORWARD=y
|
||||
CONFIG_OPENTHREAD_NCP=y
|
||||
CONFIG_OPENTHREAD_ENABLE_SERVICE=y
|
||||
|
||||
# OpenThread shell interferes with Zephyr shell
|
||||
CONFIG_OPENTHREAD_SHELL=n
|
|
@ -427,7 +427,7 @@ endif # LOG_BACKEND_RTT
|
|||
|
||||
config LOG_BACKEND_SPINEL
|
||||
bool "Enable OpenThread dedicated Spinel protocol backend"
|
||||
depends on (OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME!=UART_CONSOLE_ON_DEV_NAME || !LOG_BACKEND_UART)
|
||||
depends on (OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME!=UART_CONSOLE_ON_DEV_NAME || !LOG_BACKEND_UART)
|
||||
depends on NET_L2_OPENTHREAD
|
||||
help
|
||||
When enabled, backend will use OpenThread dedicated SPINEL protocol for logging.
|
||||
|
|
|
@ -141,6 +141,7 @@ endmenu # "Zephyr optimizations"
|
|||
|
||||
config OPENTHREAD_SHELL
|
||||
bool "Enable OpenThread shell"
|
||||
depends on !OPENTHREAD_COPROCESSOR
|
||||
select SHELL
|
||||
default y
|
||||
|
||||
|
@ -173,43 +174,49 @@ config OPENTHREAD_MBEDTLS_LIB_NAME
|
|||
This option allows to specify one or more mbedtls library files to be
|
||||
linked with OpenThread. Separate multiple values with space " ".
|
||||
|
||||
menuconfig OPENTHREAD_NCP
|
||||
bool "Network Co-Processor"
|
||||
config OPENTHREAD_COPROCESSOR
|
||||
bool "OpenThread Co-Processor"
|
||||
select OPENTHREAD_MANUAL_START
|
||||
select RING_BUFFER
|
||||
select UART_INTERRUPT_DRIVEN
|
||||
help
|
||||
Enable NCP in OpenThread stack.
|
||||
Enable Co-Processor in OpenThread stack.
|
||||
|
||||
if OPENTHREAD_NCP
|
||||
|
||||
config OPENTHREAD_NCP_RADIO
|
||||
bool "Network Co-Processor as Radio"
|
||||
choice
|
||||
prompt "OpenThread Co-Processor type"
|
||||
help
|
||||
Enable NCP in OpenThread stack as radio-only.
|
||||
This option selects Thread network co-processor type
|
||||
|
||||
config OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME
|
||||
string "UART device to use for NCP SPINEL"
|
||||
config OPENTHREAD_COPROCESSOR_NCP
|
||||
bool "NCP - Network Co-Processor"
|
||||
config OPENTHREAD_COPROCESSOR_RCP
|
||||
bool "RCP - Radio Co-Processor"
|
||||
endchoice
|
||||
|
||||
if OPENTHREAD_COPROCESSOR
|
||||
|
||||
config OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME
|
||||
string "UART device to use for Co-Processor SPINEL"
|
||||
default "UART_0"
|
||||
help
|
||||
UART device to use for NCP SPINEL.
|
||||
UART device to use for Co-Processor SPINEL.
|
||||
|
||||
config OPENTHREAD_NCP_UART_RING_BUFFER_SIZE
|
||||
int "Set NCP UART ring buffer size"
|
||||
config OPENTHREAD_COPROCESSOR_UART_RING_BUFFER_SIZE
|
||||
int "Set Co-Processor UART ring buffer size"
|
||||
default 4096
|
||||
help
|
||||
TX buffer size for the OpenThread NCP UART.
|
||||
TX buffer size for the OpenThread Co-Processor UART.
|
||||
|
||||
config OPENTHREAD_NCP_SPINEL_ON_UART_ACM
|
||||
config OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
bool "Run SPINEL over USB-ACM"
|
||||
depends on USB_CDC_ACM
|
||||
help
|
||||
Is the SPINEL device a USB-CDC-ACM device.
|
||||
|
||||
config OPENTHREAD_NCP_VENDOR_HOOK_SOURCE
|
||||
string "Path to NCP vendor hook source file"
|
||||
config OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE
|
||||
string "Path to vendor hook source file"
|
||||
help
|
||||
Provides path to compile ncp vendor hook file inside NCP component.
|
||||
Provides path to compile vendor hook file.
|
||||
|
||||
config OPENTHREAD_NCP_BUFFER_SIZE
|
||||
int "The size of the NCP buffers"
|
||||
|
@ -217,7 +224,7 @@ config OPENTHREAD_NCP_BUFFER_SIZE
|
|||
help
|
||||
The size of the NCP buffers.
|
||||
|
||||
endif # OPENTHREAD_NCP
|
||||
endif # OPENTHREAD_COPROCESSOR
|
||||
|
||||
config OPENTHREAD_PLATFORM_INFO
|
||||
string "Platform information for OpenThread"
|
||||
|
|
|
@ -147,7 +147,7 @@ static void ot_state_changed_handler(uint32_t flags, void *context)
|
|||
struct openthread_context *ot_context = context;
|
||||
|
||||
NET_INFO("State changed! Flags: 0x%08" PRIx32 " Current role: %d",
|
||||
flags, otThreadGetDeviceRole(ot_context->instance));
|
||||
flags, otThreadGetDeviceRole(ot_context->instance));
|
||||
|
||||
if (flags & OT_CHANGED_IP6_ADDRESS_REMOVED) {
|
||||
NET_DBG("Ipv6 address removed");
|
||||
|
@ -194,9 +194,7 @@ static void ot_receive_handler(otMessage *aMessage, void *context)
|
|||
pkt_buf = pkt->buffer;
|
||||
|
||||
while (1) {
|
||||
read_len = otMessageRead(aMessage,
|
||||
offset,
|
||||
pkt_buf->data,
|
||||
read_len = otMessageRead(aMessage, offset, pkt_buf->data,
|
||||
net_buf_tailroom(pkt_buf));
|
||||
if (!read_len) {
|
||||
break;
|
||||
|
@ -326,10 +324,17 @@ int openthread_send(struct net_if *iface, struct net_pkt *pkt)
|
|||
int openthread_start(struct openthread_context *ot_context)
|
||||
{
|
||||
otInstance *ot_instance = ot_context->instance;
|
||||
otError error;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
openthread_api_mutex_lock(ot_context);
|
||||
|
||||
NET_INFO("OpenThread version: %s", otGetVersionString());
|
||||
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR)) {
|
||||
NET_DBG("OpenThread co-processor.");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
otIp6SetEnabled(ot_context->instance, true);
|
||||
|
||||
/* Sleepy End Device specific configuration. */
|
||||
|
@ -377,7 +382,6 @@ int openthread_start(struct openthread_context *ot_context)
|
|||
otThreadSetExtendedPanId(ot_instance, &xpanid);
|
||||
}
|
||||
|
||||
NET_INFO("OpenThread version: %s", otGetVersionString());
|
||||
NET_INFO("Network name: %s",
|
||||
log_strdup(otThreadGetNetworkName(ot_instance)));
|
||||
|
||||
|
@ -397,6 +401,10 @@ int openthread_stop(struct openthread_context *ot_context)
|
|||
{
|
||||
otError error;
|
||||
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
openthread_api_mutex_lock(ot_context);
|
||||
|
||||
error = otThreadSetEnabled(ot_context->instance, false);
|
||||
|
@ -430,29 +438,25 @@ static int openthread_init(struct net_if *iface)
|
|||
platformShellInit(ot_context->instance);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) {
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR)) {
|
||||
otNcpInit(ot_context->instance);
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_OPENTHREAD_NCP)) {
|
||||
} else {
|
||||
otIp6SetReceiveFilterEnabled(ot_context->instance, true);
|
||||
otIp6SetReceiveCallback(ot_context->instance,
|
||||
ot_receive_handler, ot_context);
|
||||
otSetStateChangedCallback(
|
||||
ot_context->instance,
|
||||
&ot_state_changed_handler,
|
||||
ot_context);
|
||||
}
|
||||
otSetStateChangedCallback(ot_context->instance,
|
||||
&ot_state_changed_handler,
|
||||
ot_context);
|
||||
|
||||
net_mgmt_init_event_callback(&ip6_addr_cb, ipv6_addr_event_handler,
|
||||
NET_EVENT_IPV6_ADDR_ADD |
|
||||
NET_EVENT_IPV6_MADDR_ADD);
|
||||
net_mgmt_add_event_callback(&ip6_addr_cb);
|
||||
net_mgmt_init_event_callback(
|
||||
&ip6_addr_cb, ipv6_addr_event_handler,
|
||||
NET_EVENT_IPV6_ADDR_ADD | NET_EVENT_IPV6_MADDR_ADD);
|
||||
net_mgmt_add_event_callback(&ip6_addr_cb);
|
||||
}
|
||||
|
||||
ot_tid = k_thread_create(&ot_thread_data, ot_stack_area,
|
||||
K_KERNEL_STACK_SIZEOF(ot_stack_area),
|
||||
openthread_process,
|
||||
ot_context, NULL, NULL,
|
||||
openthread_process, ot_context, NULL, NULL,
|
||||
OT_PRIORITY, 0, K_NO_WAIT);
|
||||
k_thread_name_set(&ot_thread_data, "openthread");
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ zephyr_library_sources(
|
|||
)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_DIAG diag.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_NCP uart.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_COPROCESSOR uart.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_SHELL shell.c)
|
||||
zephyr_library_sources_ifndef(CONFIG_LOG_BACKEND_SPINEL logging.c)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void otSysProcessDrivers(otInstance *aInstance)
|
|||
platformRadioProcess(aInstance);
|
||||
platformAlarmProcess(aInstance);
|
||||
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_NCP)) {
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR)) {
|
||||
platformUartProcess(aInstance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,7 +409,12 @@ void platformRadioProcess(otInstance *aInstance)
|
|||
while ((tx_pkt = (struct net_pkt *)k_fifo_get(&tx_pkt_fifo,
|
||||
K_NO_WAIT))
|
||||
!= NULL) {
|
||||
openthread_handle_frame_to_send(aInstance, tx_pkt);
|
||||
if (IS_ENABLED(CONFIG_OPENTHREAD_COPROCESSOR_RCP)) {
|
||||
net_pkt_unref(tx_pkt);
|
||||
} else {
|
||||
openthread_handle_frame_to_send(aInstance,
|
||||
tx_pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <sys/ring_buffer.h>
|
||||
#include <sys/atomic.h>
|
||||
|
||||
#ifdef CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM
|
||||
#ifdef CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
#include <usb/usb_device.h>
|
||||
#endif
|
||||
|
||||
|
@ -41,7 +41,7 @@ struct openthread_uart {
|
|||
.rx_ringbuf = &_name##_rx_ringbuf, \
|
||||
}
|
||||
|
||||
OT_UART_DEFINE(ot_uart, CONFIG_OPENTHREAD_NCP_UART_RING_BUFFER_SIZE);
|
||||
OT_UART_DEFINE(ot_uart, CONFIG_OPENTHREAD_COPROCESSOR_UART_RING_BUFFER_SIZE);
|
||||
|
||||
#define RX_FIFO_SIZE 128
|
||||
|
||||
|
@ -148,7 +148,7 @@ void platformUartProcess(otInstance *aInstance)
|
|||
otError otPlatUartEnable(void)
|
||||
{
|
||||
ot_uart.dev = device_get_binding(
|
||||
CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_DEV_NAME);
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME);
|
||||
|
||||
if ((&ot_uart)->dev == NULL) {
|
||||
LOG_ERR("UART device not found");
|
||||
|
@ -165,7 +165,7 @@ otError otPlatUartEnable(void)
|
|||
|
||||
otError otPlatUartDisable(void)
|
||||
{
|
||||
#ifdef CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM
|
||||
#ifdef CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
int ret = usb_disable();
|
||||
|
||||
if (ret) {
|
||||
|
|
2
west.yml
2
west.yml
|
@ -111,7 +111,7 @@ manifest:
|
|||
revision: 3f545d76a2e6d1db83a470ccdb5bebd1f484e137
|
||||
path: modules/lib/loramac-node
|
||||
- name: openthread
|
||||
revision: 07f430dac6c400abdd358ba1173c0f94b94a5a80
|
||||
revision: f9fbfad0119d7b0d473eaac50c2f0a0a483c2823
|
||||
path: modules/lib/openthread
|
||||
- name: segger
|
||||
revision: 874d9e9696b00c09f9eeefe839028dc25fe44983
|
||||
|
|
Loading…
Reference in a new issue