[config] ncp (#4020)

This commit is contained in:
Jonathan Hui
2019-07-31 14:16:30 -07:00
parent 953c9db6b7
commit df379636da
39 changed files with 309 additions and 222 deletions
+11 -9
View File
@@ -70,7 +70,8 @@ python --version || die
-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_JOINER_ENABLE=1 \
-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1"
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
scan-build ./configure \
--enable-builtin-mbedtls=no \
@@ -84,7 +85,6 @@ python --version || die
--enable-mtd \
--enable-mtd-network-diagnostic \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-service \
--enable-sntp-client \
@@ -106,7 +106,6 @@ python --version || die
--enable-mtd \
--enable-mtd-network-diagnostic \
--enable-ncp \
--with-ncp-bus=spi \
--enable-radio-only \
--enable-service \
--enable-sntp-client \
@@ -355,7 +354,8 @@ build_samr21() {
-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \
-DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1"
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1"
git checkout -- . || die
git clean -xfd || die
@@ -364,7 +364,6 @@ build_samr21() {
--enable-ncp \
--enable-ftd \
--enable-mtd \
--with-ncp-bus=spi \
--with-examples=posix \
--enable-jam-detection \
--enable-legacy \
@@ -380,7 +379,6 @@ build_samr21() {
./configure \
--enable-cli \
--enable-mtd \
--with-ncp-bus=spi \
--with-examples=posix \
--enable-legacy \
--enable-service \
@@ -388,7 +386,10 @@ build_samr21() {
--disable-tests || die
make -j 8 || die
export CPPFLAGS="-DOPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1 -DOPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE=1"
export CPPFLAGS=" \
-DOPENTHREAD_CONFIG_ANOUNCE_SENDER_ENABLE=1 \
-DOPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1 \
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
git checkout -- . || die
git clean -xfd || die
@@ -399,7 +400,6 @@ build_samr21() {
--enable-ftd \
--enable-mtd \
--enable-radio-only \
--with-ncp-bus=uart \
--with-examples=posix || die
make -j 8 || die
}
@@ -437,8 +437,10 @@ build_samr21() {
}
[ $BUILD_TARGET != posix-ncp-spi ] || {
CPPFLAGS="-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1"
./bootstrap || die
make -f examples/Makefile-posix check configure_OPTIONS="--enable-ncp --enable-ftd --with-ncp-bus=spi --with-examples=posix" || die
make -f examples/Makefile-posix check configure_OPTIONS="--enable-ncp --enable-ftd --with-examples=posix" || die
}
[ $BUILD_TARGET != posix-app-ncp ] || {
-1
View File
@@ -37,7 +37,6 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-service \
--with-examples=posix \
-44
View File
@@ -702,49 +702,6 @@ AC_SUBST(OPENTHREAD_ENABLE_NCP)
AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP], [test "${enable_ncp}" = "yes"])
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_NCP], [${OPENTHREAD_ENABLE_NCP}], [Define to 1 to build NCP library.])
#
# NCP BUS - how does the NCP talk to the host?
#
AC_ARG_WITH(
[ncp-bus],
[AS_HELP_STRING([--with-ncp-bus],[Specify the NCP bus (none|spi|uart) @<:@default=none@:>@.])],
[
case "${with_ncp_bus}" in
"none")
OPENTHREAD_ENABLE_NCP_SPI=0
OPENTHREAD_ENABLE_NCP_UART=0
;;
"spi")
OPENTHREAD_ENABLE_NCP_SPI=1
OPENTHREAD_ENABLE_NCP_UART=0
;;
"uart")
OPENTHREAD_ENABLE_NCP_SPI=0
OPENTHREAD_ENABLE_NCP_UART=1
;;
*)
AC_MSG_ERROR([unexpected --with-ncp-bus=${with_ncp_bus}])
;;
esac
],
[
OPENTHREAD_ENABLE_NCP_SPI=0
OPENTHREAD_ENABLE_NCP_UART=0
])
AC_SUBST(OPENTHREAD_ENABLE_NCP_SPI)
AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_SPI], [test "${with_ncp_bus}" = "spi"])
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_NCP_SPI],[${OPENTHREAD_ENABLE_NCP_SPI}],[Define to 1 to enable the NCP SPI interface.])
AC_MSG_CHECKING([should NCP support SPI])
AC_MSG_RESULT([${OPENTHREAD_ENABLE_SPI}])
AC_SUBST(OPENTHREAD_ENABLE_NCP_UART)
AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_UART], [test "${with_ncp_bus}" = "uart"])
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_NCP_UART],[${OPENTHREAD_ENABLE_NCP_UART}],[Define to 1 to enable the NCP UART interface.])
AC_MSG_CHECKING([should NCP support UART])
AC_MSG_RESULT([${OPENTHREAD_ENABLE_UART}])
#
# Readline - readline library to use for POSIX CLI
#
@@ -1558,7 +1515,6 @@ AC_MSG_NOTICE([
OpenThread Radio Only support : ${enable_radio_only}
OpenThread CLI support : ${enable_cli}
OpenThread NCP support : ${enable_ncp}
OpenThread NCP-BUS Configuration : ${with_ncp_bus}
OpenThread NCP Vendor Hook Source : ${with_ncp_vendor_hook_source}
OpenThread NCP Spinel Encrypter : ${with_ncp_spinel_encrypter_libs}
OpenThread Vendor Extension Source : ${with_vendor_extension}
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--with-examples=cc1352 \
MBEDTLS_CPPFLAGS="$(CC1352_MBEDTLS_CPPFLAGS)" \
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=cc2538 \
-1
View File
@@ -45,7 +45,6 @@ configure_OPTIONS = \
--enable-cli \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=cc2650 \
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--with-examples=cc2652 \
MBEDTLS_CPPFLAGS="$(CC2652_MBEDTLS_CPPFLAGS)" \
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=efr32mg12 \
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=efr32mg21 \
-1
View File
@@ -46,7 +46,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=kw41z \
+2 -2
View File
@@ -97,10 +97,10 @@ configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
configure_OPTIONS += --with-ncp-bus=spi
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
configure_OPTIONS += --with-ncp-bus=uart
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
configure_OPTIONS += --enable-cli
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
+2 -2
View File
@@ -103,9 +103,9 @@ configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
configure_OPTIONS += --with-ncp-bus=spi
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
configure_OPTIONS += --with-ncp-bus=uart
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
configure_OPTIONS += --enable-cli
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
+6 -1
View File
@@ -73,7 +73,6 @@ configure_OPTIONS = \
--enable-ncp \
--enable-radio-only \
--with-examples=posix \
--with-ncp-bus=uart \
$(NULL)
# Platform specific switches
@@ -84,6 +83,12 @@ COMMONCFLAGS += \
$(NULL)
endif
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
endif # NCP_SPI == 1
ifeq ($(VIRTUAL_TIME),1)
COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME=1
endif
-1
View File
@@ -47,7 +47,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=qpg6095 \
-1
View File
@@ -61,7 +61,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=samr21 \
@@ -60,4 +60,12 @@
*/
#define SETTINGS_CONFIG_PAGE_NUM (2)
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif /* OPENTHREAD_CORE_CC1352_CONFIG_H_ */
@@ -100,6 +100,14 @@
*/
#define SETTINGS_CONFIG_PAGE_SIZE 2048
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_CC2538_WITH_CC2592
*
@@ -44,4 +44,12 @@
*/
#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 32
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif /* OPENTHREAD_CORE_CC2650_CONFIG_H_ */
@@ -60,4 +60,12 @@
*/
#define SETTINGS_CONFIG_PAGE_NUM (2)
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif /* OPENTHREAD_CORE_CC2650_CONFIG_H_ */
@@ -143,4 +143,12 @@
*/
#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 6
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_EFR32_CONFIG_H_
@@ -100,4 +100,12 @@
*/
#define OPENTHREAD_CONFIG_SOFTWARE_CSMA_BACKOFF_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_KW41Z_CONFIG_H_
+2 -2
View File
@@ -35,7 +35,7 @@
#include <openthread/platform/spi-slave.h>
#include <openthread/platform/uart.h>
#if OPENTHREAD_ENABLE_NCP_SPI
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLE
// Spi-slave stubs
@@ -84,4 +84,4 @@ void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
OT_UNUSED_VARIABLE(aBufLength);
}
#endif // OPENTHREAD_ENABLE_NCP_SPI
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLE
@@ -50,4 +50,12 @@
*/
#define OPENTHREAD_CONFIG_PLATFORM_INFO "QPG6095"
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_QPG6095_CONFIG_H_
@@ -95,4 +95,12 @@ extern uint32_t __d_nv_mem_end;
*/
#define OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER 5
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_SAMR21_CONFIG_H_
+1 -1
View File
@@ -54,7 +54,7 @@
#define OPENTHREAD_ENABLE_LEGACY 1
/* Define to 1 to enable the NCP UART interface. */
#define OPENTHREAD_ENABLE_NCP_UART 1
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
/* Define to 1 to build posix application. */
#define OPENTHREAD_PLATFORM_POSIX_APP 1
@@ -308,75 +308,6 @@
#define OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS 1
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE
*
* The size of NCP message buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE
#define OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE 512
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE
*
* The size of NCP UART TX chunk in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE
#define OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE 128
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
*
* The size of NCP UART RX buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
#if OPENTHREAD_RADIO
#define OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE 512
#else
#define OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE 1300
#endif
#endif // OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
*
* The size of NCP SPI (RX/TX) buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
#if OPENTHREAD_RADIO
#define OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE 512
#else
#define OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE 1300
#endif
#endif // OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE
*
* The size of extra data to be allocated in UART buffer,
* needed by NCP Spinel Encrypter.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
*
* The maximum OpenThread log string size (number of chars) supported by NCP using Spinel `StreamWrite`.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE 150
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
*
@@ -499,57 +430,6 @@
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -65
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
*
* Define as 1 to enable peek/poke functionality on NCP.
*
* Peek/Poke allows the host to read/write to memory addresses on NCP. This is intended for debugging.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
#define OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE
*
* Size of NCP Spinel command response queue.
*
* NCP guarantees that it can respond up to `OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE` spinel commands at the
* same time. The spinel protocol defines a Transaction ID (TID) as part of spinel command frame (the TID can be
* a value 0-15 where TID 0 is used for frames which require no response). Spinel protocol can support at most support
* 15 simultaneous commands.
*
* The host driver implementation may further limit the number of simultaneous Spinel command frames (e.g., wpantund
* limits this to two). This configuration option can be used to reduce the response queue size.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE 15
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL
*
* Define to 1 to enable support controlling of desired power state of NCP's micro-controller.
*
* The power state specifies the desired power state of NCP's micro-controller (MCU) when the underlying platform's
* operating system enters idle mode (i.e., all active tasks/events are processed and the MCU can potentially enter a
* energy-saving power state).
*
* The power state primarily determines how the host should interact with the NCP and whether the host needs an
* external trigger (a "poke") before it can communicate with the NCP or not.
*
* When enabled, the platform is expected to provide `otPlatSetMcuPowerState()` and `otPlatGetMcuPowerState()`
* functions (please see `openthread/platform/misc.h`). Host can then control the power state using
* `SPINEL_PROP_MCU_POWER_STATE`.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL
#define OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL 0
#endif
/**
* @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
*
+1
View File
@@ -86,6 +86,7 @@ COMMON_SOURCES = \
ncp_base_dispatcher.cpp \
ncp_buffer.cpp \
ncp_buffer.hpp \
ncp_config.h \
ncp_spi.cpp \
ncp_spi.hpp \
ncp_uart.cpp \
+2 -2
View File
@@ -36,7 +36,7 @@
#include "common/code_utils.hpp"
#if OPENTHREAD_ENABLE_NCP_UART || OPENTHREAD_PLATFORM_POSIX_APP
#if OPENTHREAD_CONFIG_NCP_UART_ENABLE || OPENTHREAD_PLATFORM_POSIX_APP
namespace ot {
namespace Hdlc {
@@ -301,4 +301,4 @@ void Decoder::Decode(const uint8_t *aData, uint16_t aLength)
} // namespace Hdlc
} // namespace ot
#endif // OPENTHREAD_ENABLE_NCP_UART || OPENTHREAD_PLATFORM_POSIX_APP
#endif // OPENTHREAD_CONFIG_NCP_UART_ENABLE || OPENTHREAD_PLATFORM_POSIX_APP
+2
View File
@@ -35,6 +35,8 @@
#include "openthread-core-config.h"
#include "ncp/ncp_config.h"
#if OPENTHREAD_MTD || OPENTHREAD_FTD
#include <openthread/ip6.h>
#else
+178
View File
@@ -0,0 +1,178 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes compile-time configurations for the NCP.
*
*/
#ifndef CONFIG_NCP_H_
#define CONFIG_NCP_H_
/**
* @def OPENTHREAD_CONFIG_NCP_SPI_ENABLE
*
* Define to 1 to enable NCP SPI support.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPI_ENABLE
#define OPENTHREAD_CONFIG_NCP_SPI_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_UART_ENABLE
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE
*
* The size of NCP message buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE
#define OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE 512
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE
*
* The size of NCP UART TX chunk in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE
#define OPENTHREAD_CONFIG_NCP_UART_TX_CHUNK_SIZE 128
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
*
* The size of NCP UART RX buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
#if OPENTHREAD_RADIO
#define OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE 512
#else
#define OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE 1300
#endif
#endif // OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
*
* The size of NCP SPI (RX/TX) buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
#if OPENTHREAD_RADIO
#define OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE 512
#else
#define OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE 1300
#endif
#endif // OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE
*
* The size of extra data to be allocated in UART buffer,
* needed by NCP Spinel Encrypter.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
*
* The maximum OpenThread log string size (number of chars) supported by NCP using Spinel `StreamWrite`.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE 150
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
*
* Define as 1 to enable peek/poke functionality on NCP.
*
* Peek/Poke allows the host to read/write to memory addresses on NCP. This is intended for debugging.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
#define OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE
*
* Size of NCP Spinel command response queue.
*
* NCP guarantees that it can respond up to `OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE` spinel commands at the
* same time. The spinel protocol defines a Transaction ID (TID) as part of spinel command frame (the TID can be
* a value 0-15 where TID 0 is used for frames which require no response). Spinel protocol can support at most support
* 15 simultaneous commands.
*
* The host driver implementation may further limit the number of simultaneous Spinel command frames (e.g., wpantund
* limits this to two). This configuration option can be used to reduce the response queue size.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_RESPONSE_QUEUE_SIZE 15
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL
*
* Define to 1 to enable support controlling of desired power state of NCP's micro-controller.
*
* The power state specifies the desired power state of NCP's micro-controller (MCU) when the underlying platform's
* operating system enters idle mode (i.e., all active tasks/events are processed and the MCU can potentially enter a
* energy-saving power state).
*
* The power state primarily determines how the host should interact with the NCP and whether the host needs an
* external trigger (a "poke") before it can communicate with the NCP or not.
*
* When enabled, the platform is expected to provide `otPlatSetMcuPowerState()` and `otPlatGetMcuPowerState()`
* functions (please see `openthread/platform/misc.h`). Host can then control the power state using
* `SPINEL_PROP_MCU_POWER_STATE`.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL
#define OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL 0
#endif
#endif // CONFIG_NCP_H_
+3 -3
View File
@@ -44,7 +44,7 @@
#include "net/ip6.hpp"
#include "utils/static_assert.hpp"
#if OPENTHREAD_ENABLE_NCP_SPI
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLE
#if OPENTHREAD_CONFIG_DIAG_ENABLE
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <=
@@ -75,7 +75,7 @@ extern "C" void otNcpInit(otInstance *aInstance)
}
}
#endif // OPENTHREAD_ENABLE_SPINEL_VENDOR_SUPPORT == 0
#endif // OPENTHREAD_ENABLE_NCP_VENDOR_HOOK == 0
NcpSpi::NcpSpi(Instance *aInstance)
: NcpBase(aInstance)
@@ -379,4 +379,4 @@ void NcpSpi::HandleRxFrame(void)
} // namespace Ncp
} // namespace ot
#endif // OPENTHREAD_ENABLE_NCP_SPI
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLE
+11 -11
View File
@@ -47,7 +47,7 @@
#include "net/ip6.hpp"
#include "utils/static_assert.hpp"
#if OPENTHREAD_ENABLE_NCP_UART
#if OPENTHREAD_CONFIG_NCP_UART_ENABLE
#if OPENTHREAD_CONFIG_DIAG_ENABLE
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE -
@@ -79,7 +79,7 @@ extern "C" void otNcpInit(otInstance *aInstance)
}
}
#endif // OPENTHREAD_ENABLE_SPINEL_VENDOR_SUPPORT == 0
#endif // OPENTHREAD_ENABLE_NCP_VENDOR_HOOK == 0
NcpUart::NcpUart(Instance *aInstance)
: NcpBase(aInstance)
@@ -91,9 +91,9 @@ NcpUart::NcpUart(Instance *aInstance)
, mRxBuffer()
, mUartSendImmediate(false)
, mUartSendTask(*aInstance, EncodeAndSendToUart, this)
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
, mTxFrameBufferEncrypterReader(mTxFrameBuffer)
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
{
mTxFrameBuffer.SetFrameAddedCallback(HandleFrameAddedToNcpBuffer, this);
@@ -133,11 +133,11 @@ void NcpUart::EncodeAndSendToUart(void)
{
uint16_t len;
bool prevHostPowerState;
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
NcpFrameBufferEncrypterReader &txFrameBuffer = mTxFrameBufferEncrypterReader;
#else
NcpFrameBuffer &txFrameBuffer = mTxFrameBuffer;
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
while (!txFrameBuffer.IsEmpty() || (mState == kFinalizingFrame))
{
@@ -257,7 +257,7 @@ void NcpUart::HandleFrame(otError aError)
if (aError == OT_ERROR_NONE)
{
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
size_t dataLen = bufLength;
if (SpinelEncrypter::DecryptInbound(buf, kRxBufferSize, &dataLen))
{
@@ -265,7 +265,7 @@ void NcpUart::HandleFrame(otError aError)
}
#else
super_t::HandleReceive(buf, bufLength);
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
}
else
{
@@ -308,7 +308,7 @@ void NcpUart::HandleError(otError aError, uint8_t *aBuf, uint16_t aBufLength)
otNcpStreamWrite(0, reinterpret_cast<uint8_t *>(hexbuf + 1), static_cast<int>(strlen(hexbuf) - 1));
}
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
NcpUart::NcpFrameBufferEncrypterReader::NcpFrameBufferEncrypterReader(NcpFrameBuffer &aTxFrameBuffer)
: mTxFrameBuffer(aTxFrameBuffer)
@@ -373,9 +373,9 @@ void NcpUart::NcpFrameBufferEncrypterReader::Reset(void)
mDataBufferReadIndex = 0;
}
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
} // namespace Ncp
} // namespace ot
#endif // OPENTHREAD_ENABLE_NCP_UART
#endif // OPENTHREAD_CONFIG_NCP_UART_ENABLE
+6 -6
View File
@@ -38,9 +38,9 @@
#include "ncp/hdlc.hpp"
#include "ncp/ncp_base.hpp"
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
#include "spinel_encrypter.hpp"
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
namespace ot {
namespace Ncp {
@@ -85,7 +85,7 @@ private:
kFinalizingFrame, // Finalizing a frame.
};
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
/**
* Wraps NcpFrameBuffer allowing to read data through spinel encrypter.
* Creates additional buffers to allow transforming of the whole spinel frames.
@@ -112,7 +112,7 @@ private:
size_t mDataBufferReadIndex;
size_t mOutputDataLength;
};
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
void EncodeAndSendToUart(void);
void HandleFrame(otError aError);
@@ -136,9 +136,9 @@ private:
bool mUartSendImmediate;
Tasklet mUartSendTask;
#if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
NcpFrameBufferEncrypterReader mTxFrameBufferEncrypterReader;
#endif // OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
#endif // OPENTHREAD_CONFIG_NCP_SPI_ENABLENEL_ENCRYPTER
};
} // namespace Ncp
-1
View File
@@ -73,7 +73,6 @@ configure_OPTIONS = \
--enable-ftd \
--enable-ncp \
--enable-posix-app \
--with-ncp-bus=uart \
$(NULL)
# Platform specific switches
@@ -54,4 +54,12 @@
#define OPENTHREAD_CONFIG_UART_CLI_RAW 1
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
#endif // OPENTHREAD_CORE_POSIX_CONFIG_H_
+1
View File
@@ -37,6 +37,7 @@
#include <openthread/platform/radio.h>
#include "hdlc_interface.hpp"
#include "ncp/ncp_config.h"
#include "ncp/spinel.h"
namespace ot {
-2
View File
@@ -83,7 +83,6 @@ configure_options=" \
--enable-legacy \
--enable-ncp \
--enable-service \
--with-ncp-bus=uart \
"
cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config.h\"'
@@ -110,7 +109,6 @@ case ${build_config} in
CPPFLAGS="$cppflags_config" \
--enable-coverage=${coverage} \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--with-examples=posix \
--disable-docs \
@@ -218,6 +218,14 @@
*/
#define OPENTHREAD_CONFIG_LOG_PLATFORM 1
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
*
* Define to 1 to enable NCP UART support.
*
*/
#define OPENTHREAD_CONFIG_NCP_UART_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE
*
+1 -6
View File
@@ -126,16 +126,11 @@ check_PROGRAMS += \
if OPENTHREAD_ENABLE_NCP
check_PROGRAMS += \
test-hdlc \
test-ncp-buffer \
test-spinel-decoder \
test-spinel-encoder \
$(NULL)
if OPENTHREAD_ENABLE_NCP_UART
check_PROGRAMS += \
test-hdlc \
$(NULL)
endif
endif
endif # OPENTHREAD_ENABLE_FTD