diff --git a/.travis/script.sh b/.travis/script.sh
index c109a8bcb..d0869d36d 100755
--- a/.travis/script.sh
+++ b/.travis/script.sh
@@ -37,13 +37,13 @@ set -x
[ $BUILD_TARGET != pretty-check ] || {
export PATH=/tmp/astyle/build/gcc/bin:$PATH || die
./bootstrap || die
- ./configure --enable-ftd --enable-cli --enable-diag --enable-dhcp6-client --enable-dhcp6-server --enable-dns-client --enable-commissioner --enable-joiner --enable-application-coap --with-examples=posix || die
+ ./configure --enable-cli-app=all --enable-ncp-app=all --enable-diag --enable-dhcp6-client --enable-dhcp6-server --enable-dns-client --enable-commissioner --enable-joiner --enable-application-coap --with-examples=posix || die
make pretty-check || die
}
[ $BUILD_TARGET != scan-build ] || {
./bootstrap || die
- scan-build ./configure --with-examples=posix --enable-ftd --enable-cli --enable-ncp || die
+ scan-build ./configure --with-examples=posix --enable-cli-app=all --enable-ncp-app=all --with-ncp-bus=uart || die
scan-build --status-bugs -analyze-headers -v make || die
}
@@ -144,7 +144,7 @@ set -x
[ $BUILD_TARGET != posix-ncp-spi ] || {
./bootstrap || die
- make -f examples/Makefile-posix check configure_OPTIONS="--enable-ftd --enable-ncp=spi --with-examples=posix --with-platform-info=POSIX" || die
+ make -f examples/Makefile-posix check configure_OPTIONS="--enable-ncp-app=ftd --with-ncp-bus=spi --with-examples=posix --with-platform-info=POSIX" || die
}
[ $BUILD_TARGET != posix-ncp ] || {
diff --git a/Makefile.am b/Makefile.am
index bc2a996c0..8c6145985 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,9 +32,9 @@ AM_MAKEFLAGS = --no-print-directory
AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-address-sanitizer \
- --enable-ftd \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=all \
+ --enable-ncp-app=all \
+ --with-ncp-bus=uart \
--enable-diag \
--with-examples=posix \
--enable-commissioner \
diff --git a/configure.ac b/configure.ac
index f99a3bb3e..94736639b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -349,81 +349,161 @@ NL_ENABLE_TESTS([yes])
AM_CONDITIONAL([OPENTHREAD_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"])
-#
-# Full Thread Device
-#
-
-AC_MSG_CHECKING([whether to enable FTD])
-AC_ARG_ENABLE(ftd,
- [AS_HELP_STRING([--enable-ftd],[Enable Full Thread Device features @<:@default=no@:>@.])],
- [
- case "${enableval}" in
-
- no|yes)
- enable_ftd=${enableval}
- ;;
-
- *)
- AC_MSG_ERROR([Invalid value ${enable_ftd} for --enable-ftd])
- ;;
- esac
- ],
- [enable_ftd=no])
-AC_MSG_RESULT(${enable_ftd})
-AM_CONDITIONAL([OPENTHREAD_ENABLE_FTD], [test "${enable_ftd}" = "yes"])
-
#
# CLI Library
#
-
-AC_MSG_CHECKING([whether to enable the CLI app])
-AC_ARG_ENABLE(cli,
- [AS_HELP_STRING([--enable-cli],[Enable CLI support @<:@default=no@:>@.])],
+AC_ARG_ENABLE(cli-app,
+ [AS_HELP_STRING([--enable-cli-app],[Enable CLI support (no|mtd|ftd|all) @<:@default=no@:>@.])],
[
+ case "${enableval}" in
+ all|both)
+ enable_cli_app=yes
+ enable_cli_app_mtd=yes
+ enable_cli_app_ftd=yes
+ ;;
+ no|yes)
+ enable_cli_app=${enableval}
+ enable_cli_app_mtd=${enableval}
+ enable_cli_app_ftd=${enableval}
+ ;;
+ mtd)
+ enable_cli_app=yes
+ enable_cli_app_mtd=yes
+ enable_cli_app_ftd=no
+ ;;
+ ftd)
+ enable_cli_app=yes
+ enable_cli_app_mtd=no
+ enable_cli_app_ftd=yes
+ ;;
+ *)
+ AC_MSG_ERROR([Invalid value ${enableval} for --enable-cli-app])
+ ;;
+ esac
+ ],
+ [
+ enable_cli_app=no
+ enable_cli_app_mtd=no
+ enable_cli_app_ftd=no])
+
+
+AC_MSG_CHECKING([cli-app modes])
+AC_MSG_RESULT(${enable_cli_app})
+AM_CONDITIONAL([OPENTHREAD_ENABLE_CLI], [test "${enable_cli_app}" == "yes"])
+AM_CONDITIONAL([OPENTHREAD_ENABLE_CLI_MTD], [test "${enable_cli_app_mtd}" == "yes"])
+AM_CONDITIONAL([OPENTHREAD_ENABLE_CLI_FTD], [test "${enable_cli_app_ftd}" == "yes"])
+AC_SUBST(OPENTHREAD_ENABLE_CLI)
+AC_SUBST(OPENTHREAD_ENABLE_CLI_FTD)
+AC_SUBST(OPENTHREAD_ENABLE_CLI_MTD)
+
+
+#
+# NCP app
+#
+AC_ARG_ENABLE(ncp-app,
+ [AS_HELP_STRING([--enable-ncp-app],[Enable NCP support (no|mtd|ftd|all) @<:@default=no@:>@.])],
+ [
+ # Map all & both to yes
+ case "${enableval}" in
+ all|both)
+ enableval=yes
+ ;;
+
+ *)
+ ;;
+
+ esac
+
case "${enableval}" in
no|yes)
- enable_cli=${enableval}
+ enable_ncp_app=${enableval}
+ enable_ncp_app_mtd=${enableval}
+ enable_ncp_app_ftd=${enableval}
+ ;;
+
+ mtd)
+ enable_ncp_app=yes
+ enable_ncp_app_mtd=yes
+ enable_ncp_app_ftd=no
+ ;;
+
+ ftd)
+ enable_ncp_app=yes
+ enable_ncp_app_mtd=no
+ enable_ncp_app_ftd=yes
;;
*)
- AC_MSG_ERROR([Invalid value ${with_cli} for --enable-cli])
+ AC_MSG_ERROR([Invalid value ${enableval} for --enable-ncp-app])
;;
esac
],
- [enable_cli=no])
-AC_MSG_RESULT(${enable_cli})
-AM_CONDITIONAL([OPENTHREAD_ENABLE_CLI], [test "${enable_cli}" != "no"])
-
-#
-# NCP Library
-#
-
-AC_MSG_CHECKING([whether to enable the NCP app, and the bus it uses])
-AC_ARG_ENABLE(ncp,
- [AS_HELP_STRING([--enable-ncp[[=spi|uart]]],[Enable NCP support @<:@default=no@:>@.])],
[
- case "${enableval}" in
+ enable_ncp_app=no
+ enable_ncp_app_ftd=no
+ enable_ncp_app_mtd=no
+ ]
+ )
- no|spi|uart)
- enable_ncp=${enableval}
+
+AC_MSG_CHECKING([ncp-app modes])
+AC_MSG_RESULT(${enable_ncp_app})
+AC_MSG_CHECKING([should NCP support ftd])
+AC_MSG_RESULT(${enable_ncp_app_ftd})
+AC_MSG_CHECKING([should NCP support mtd])
+AC_MSG_RESULT(${enable_ncp_app_mtd})
+
+AC_SUBST(OPENTHREAD_ENABLE_NCP)
+AC_SUBST(OPENTHREAD_ENABLE_NCP_MTD)
+AC_SUBST(OPENTHREAD_ENABLE_NCP_FTD)
+
+AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP], [test "${enable_ncp_app}" == "yes"])
+AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_MTD], [test "${enable_ncp_app_mtd}" == "yes"])
+AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_FTD], [test "${enable_ncp_app_ftd}" == "yes"])
+
+#
+# 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
;;
-
- yes)
- enable_ncp=uart
+ "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([Invalid value ${with_ncp} for --enable-ncp])
+ AC_MSG_ERROR([unexpected --with-ncp-bus=${with_ncp_bus}])
;;
esac
],
- [enable_ncp=no])
-AC_MSG_RESULT(${enable_ncp})
-AC_MSG_CHECKING([determine ncp bus])
-AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP], [test "${enable_ncp}" != "no"])
-AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_SPI], [test "${enable_ncp}" = "spi"])
-AM_CONDITIONAL([OPENTHREAD_ENABLE_NCP_UART], [test "${enable_ncp}" = "uart"])
+ [
+ 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([sould NCP support UART])
+AC_MSG_RESULT([${OPENTHREAD_ENABLE_UART}])
#
# Builtin mbedtls
@@ -1172,9 +1252,13 @@ AC_MSG_NOTICE([
Pretty args : ${PRETTY_ARGS:--}
Pretty check : ${PRETTY_CHECK:--}
Pretty check args : ${PRETTY_CHECK_ARGS:--}
- OpenThread Full Thread Device support : ${enable_ftd}
- OpenThread CLI support : ${enable_cli}
- OpenThread NCP support : ${enable_ncp}
+ OpenThread CLI support : ${enable_cli_app}
+ OpenThread CLI-MTD support : ${enable_cli_app_mtd}
+ OpenThread CLI-FTD support : ${enable_cli_app_ftd}
+ OpenThread NCP support : ${enable_ncp_app}
+ OpenThread NCP-MTD support : ${enable_ncp_app_mtd}
+ OpenThread NCP-FTD support : ${enable_ncp_app_ftd}
+ OpenThread NCP-BUS Configuration : ${with_ncp_bus}
OpenThread builtin mbedtls support : ${enable_builtin_mbedtls}
OpenThread Commissioner support : ${enable_commissioner}
OpenThread Joiner support : ${enable_joiner}
diff --git a/etc/visual-studio/UnitTests.vcxproj b/etc/visual-studio/UnitTests.vcxproj
index 74b9f468f..cb6b197a6 100644
--- a/etc/visual-studio/UnitTests.vcxproj
+++ b/etc/visual-studio/UnitTests.vcxproj
@@ -50,6 +50,7 @@
MBEDTLS_CONFIG_FILE="mbedtls-config.h";
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
Level3
true
diff --git a/etc/visual-studio/libopenthread-cli-windows.vcxproj b/etc/visual-studio/libopenthread-cli-windows.vcxproj
index da4e86421..e24ef0840 100644
--- a/etc/visual-studio/libopenthread-cli-windows.vcxproj
+++ b/etc/visual-studio/libopenthread-cli-windows.vcxproj
@@ -42,6 +42,7 @@
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OTDLL;
OTBUILD;
+ OPENTHREAD_FTD=1;
%(AdditionalIncludeDirectories);
diff --git a/etc/visual-studio/libopenthread-cli.vcxproj b/etc/visual-studio/libopenthread-cli.vcxproj
index e3bed0786..98e8898ad 100644
--- a/etc/visual-studio/libopenthread-cli.vcxproj
+++ b/etc/visual-studio/libopenthread-cli.vcxproj
@@ -41,6 +41,7 @@
MBEDTLS_CONFIG_FILE="mbedtls-config.h";
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
OTBUILD;
diff --git a/etc/visual-studio/libopenthread-ncp-spi.vcxproj b/etc/visual-studio/libopenthread-ncp-spi.vcxproj
index e7a7fd165..495e3f2bb 100644
--- a/etc/visual-studio/libopenthread-ncp-spi.vcxproj
+++ b/etc/visual-studio/libopenthread-ncp-spi.vcxproj
@@ -41,6 +41,9 @@
MBEDTLS_CONFIG_FILE="mbedtls-config.h";
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
+ OPENTHREAD_ENABLE_NCP_SPI=1;
+ OPENTHREAD_ENABLE_NCP_UART=0;
OTBUILD;
diff --git a/etc/visual-studio/libopenthread-ncp-uart.vcxproj b/etc/visual-studio/libopenthread-ncp-uart.vcxproj
index 08c5700d1..4288e9660 100644
--- a/etc/visual-studio/libopenthread-ncp-uart.vcxproj
+++ b/etc/visual-studio/libopenthread-ncp-uart.vcxproj
@@ -41,6 +41,9 @@
MBEDTLS_CONFIG_FILE="mbedtls-config.h";
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
+ OPENTHREAD_ENABLE_NCP_SPI=0;
+ OPENTHREAD_ENABLE_NCP_UART=1;
OTBUILD;
@@ -73,4 +76,4 @@
-
+
\ No newline at end of file
diff --git a/etc/visual-studio/libopenthread-windows.vcxproj b/etc/visual-studio/libopenthread-windows.vcxproj
index b3d924bcd..f3c1a09b7 100644
--- a/etc/visual-studio/libopenthread-windows.vcxproj
+++ b/etc/visual-studio/libopenthread-windows.vcxproj
@@ -41,6 +41,7 @@
%(PreprocessorDefinitions);
_CRT_SECURE_NO_WARNINGS;
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
+ OPENTHREAD_FTD=1;
OTBUILD;
diff --git a/etc/visual-studio/libopenthread.vcxproj b/etc/visual-studio/libopenthread.vcxproj
index d97eada37..bfd77af42 100644
--- a/etc/visual-studio/libopenthread.vcxproj
+++ b/etc/visual-studio/libopenthread.vcxproj
@@ -41,6 +41,7 @@
MBEDTLS_CONFIG_FILE="mbedtls-config.h";
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
OTBUILD;
diff --git a/etc/visual-studio/libopenthread_k.vcxproj b/etc/visual-studio/libopenthread_k.vcxproj
index 2b747e36d..8dfe37bf7 100644
--- a/etc/visual-studio/libopenthread_k.vcxproj
+++ b/etc/visual-studio/libopenthread_k.vcxproj
@@ -43,6 +43,7 @@
OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-windows-config.h";
WINDOWS_LOGGING;
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_FTD=1;
OTBUILD;
diff --git a/etc/visual-studio/ot-cli.vcxproj b/etc/visual-studio/ot-cli.vcxproj
index 2c18ad24f..e21d9e438 100644
--- a/etc/visual-studio/ot-cli.vcxproj
+++ b/etc/visual-studio/ot-cli.vcxproj
@@ -39,6 +39,7 @@
%(PreprocessorDefinitions);
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
+ OPENTHREAD_FTD=1;
OPENTHREAD_MULTIPLE_INSTANCE;
diff --git a/etc/visual-studio/ot-ncp-spi.vcxproj b/etc/visual-studio/ot-ncp-spi.vcxproj
index 0dbf5c68f..db8ae459a 100644
--- a/etc/visual-studio/ot-ncp-spi.vcxproj
+++ b/etc/visual-studio/ot-ncp-spi.vcxproj
@@ -39,7 +39,10 @@
%(PreprocessorDefinitions);
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
+ OPENTHREAD_FTD=1;
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_ENABLE_NCP_SPI=1;
+ OPENTHREAD_ENABLE_NCP_UART=0;
%(AdditionalIncludeDirectories);
diff --git a/etc/visual-studio/ot-ncp-uart.vcxproj b/etc/visual-studio/ot-ncp-uart.vcxproj
index 5536ecf99..bb8fff8e5 100644
--- a/etc/visual-studio/ot-ncp-uart.vcxproj
+++ b/etc/visual-studio/ot-ncp-uart.vcxproj
@@ -39,7 +39,10 @@
%(PreprocessorDefinitions);
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
+ OPENTHREAD_FTD=1;
OPENTHREAD_MULTIPLE_INSTANCE;
+ OPENTHREAD_ENABLE_NCP_SPI=0;
+ OOPENTHREAD_ENABLE_NCP_UART=1;
%(AdditionalIncludeDirectories);
diff --git a/etc/visual-studio/otApi.vcxproj b/etc/visual-studio/otApi.vcxproj
index f051e2117..fe08047a7 100644
--- a/etc/visual-studio/otApi.vcxproj
+++ b/etc/visual-studio/otApi.vcxproj
@@ -39,6 +39,7 @@
Level3
%(PreprocessorDefinitions);
+ OPENTHREAD_FTD=1;
OTAPI_EXPORTS;
true
diff --git a/etc/visual-studio/otCli.vcxproj b/etc/visual-studio/otCli.vcxproj
index 3ff87126f..70c5229ce 100644
--- a/etc/visual-studio/otCli.vcxproj
+++ b/etc/visual-studio/otCli.vcxproj
@@ -38,6 +38,7 @@
%(PreprocessorDefinitions);
+ OPENTHREAD_FTD=1;
OTDLL;
diff --git a/etc/visual-studio/otLwf.vcxproj b/etc/visual-studio/otLwf.vcxproj
index 4811f0a7d..83880616a 100644
--- a/etc/visual-studio/otLwf.vcxproj
+++ b/etc/visual-studio/otLwf.vcxproj
@@ -40,6 +40,7 @@
%(PreProcessorDefinitions);
NDIS_WDM=1;
NDIS630=1;
+ OPENTHREAD_FTD=1;
OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-windows-config.h";
OPENTHREAD_MULTIPLE_INSTANCE;
diff --git a/etc/visual-studio/otNodeApi.vcxproj b/etc/visual-studio/otNodeApi.vcxproj
index d918a4b68..b84edde81 100644
--- a/etc/visual-studio/otNodeApi.vcxproj
+++ b/etc/visual-studio/otNodeApi.vcxproj
@@ -37,6 +37,7 @@
%(PreprocessorDefinitions);
+ OPENTHREAD_FTD=1;
OTAPI_EXPORTS;
diff --git a/etc/visual-studio/spinel_k.vcxproj b/etc/visual-studio/spinel_k.vcxproj
index 3d350d4bd..8778d122c 100644
--- a/etc/visual-studio/spinel_k.vcxproj
+++ b/etc/visual-studio/spinel_k.vcxproj
@@ -39,6 +39,7 @@
%(PreprocessorDefinitions);
HAVE_STRNLEN=1;
+ OPENTHREAD_FTD=1;
SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR=1;
diff --git a/examples/Makefile-cc2538 b/examples/Makefile-cc2538
index 2dc1e1a31..00e1d0c9c 100644
--- a/examples/Makefile-cc2538
+++ b/examples/Makefile-cc2538
@@ -42,9 +42,9 @@ OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
- --enable-ftd \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=all \
+ --enable-ncp-app=all \
+ --with-ncp-bus=uart \
--enable-diag \
--enable-default-logging \
--with-examples=cc2538 \
diff --git a/examples/Makefile-cc2650 b/examples/Makefile-cc2650
index 9c7cc5de8..b9f7934aa 100644
--- a/examples/Makefile-cc2650
+++ b/examples/Makefile-cc2650
@@ -42,8 +42,9 @@ OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=mtd \
+ --enable-ncp-app=mtd \
+ --with-ncp-bus=uart \
--with-examples=cc2650 \
--with-platform-info=cc2650 \
MBEDTLS_CPPFLAGS="$(CC2650_MBEDTLS_CPPFLAGS)" \
diff --git a/examples/Makefile-da15000 b/examples/Makefile-da15000
index 0cdd6c4dd..bac7000bb 100644
--- a/examples/Makefile-da15000
+++ b/examples/Makefile-da15000
@@ -42,9 +42,9 @@ OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
- --enable-ftd \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=all \
+ --enable-ncp-app=all \
+ --with-ncp-bus=uart \
--enable-default-logging \
--with-examples=da15000 \
--with-platform-info=DA15000 \
diff --git a/examples/Makefile-nrf52840 b/examples/Makefile-nrf52840
index 425aef8e6..3cdca0828 100644
--- a/examples/Makefile-nrf52840
+++ b/examples/Makefile-nrf52840
@@ -42,9 +42,9 @@ OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
- --enable-ftd \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=all \
+ --enable-ncp-app=all \
+ --with-ncp-bus=uart \
--enable-diag \
--with-examples=nrf52840 \
--with-platform-info=NRF52840 \
diff --git a/examples/Makefile-posix b/examples/Makefile-posix
index 851647d38..4e8ed4aca 100644
--- a/examples/Makefile-posix
+++ b/examples/Makefile-posix
@@ -82,9 +82,9 @@ TargetTuple = $(shell ${AbsTopSourceDir}/third_party/nlbuild
# accordingly.
configure_OPTIONS = \
- --enable-ftd \
- --enable-cli \
- --enable-ncp \
+ --enable-cli-app=all \
+ --enable-ncp-app=all \
+ --with-ncp-bus=uart \
--enable-diag \
--enable-default-logging \
--enable-raw-link-api=no \
diff --git a/examples/apps/cli/Makefile.am b/examples/apps/cli/Makefile.am
index 1e23f6866..d2ea4e038 100644
--- a/examples/apps/cli/Makefile.am
+++ b/examples/apps/cli/Makefile.am
@@ -112,17 +112,19 @@ LDFLAGS_COMMON += \
$(NULL)
endif
-if OPENTHREAD_ENABLE_FTD
+
+if OPENTHREAD_ENABLE_CLI_FTD
bin_PROGRAMS += \
ot-cli-ftd \
$(NULL)
+endif
ot_cli_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_cli_ftd_LDADD = \
- $(top_builddir)/src/cli/libopenthread-cli.a \
+ $(top_builddir)/src/cli/libopenthread-cli-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(NULL)
@@ -134,18 +136,19 @@ ot_cli_ftd_LDFLAGS = \
ot_cli_ftd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
-endif # OPENTHREAD_ENABLE_FTD
+if OPENTHREAD_ENABLE_CLI_MTD
bin_PROGRAMS += \
ot-cli-mtd \
$(NULL)
+endif
ot_cli_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_cli_mtd_LDADD = \
- $(top_builddir)/src/cli/libopenthread-cli.a \
+ $(top_builddir)/src/cli/libopenthread-cli-mtd.a \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(NULL)
diff --git a/examples/apps/ncp/Makefile.am b/examples/apps/ncp/Makefile.am
index 3611255e5..4ee5a55d2 100644
--- a/examples/apps/ncp/Makefile.am
+++ b/examples/apps/ncp/Makefile.am
@@ -112,17 +112,20 @@ LDFLAGS_COMMON += \
$(NULL)
endif
-if OPENTHREAD_ENABLE_FTD
+
+
+if OPENTHREAD_ENABLE_NCP_FTD
bin_PROGRAMS += \
ot-ncp-ftd \
$(NULL)
+endif
ot_ncp_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_ncp_ftd_LDADD = \
- $(top_builddir)/src/ncp/libopenthread-ncp.a \
+ $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(NULL)
@@ -134,18 +137,19 @@ ot_ncp_ftd_LDFLAGS = \
ot_ncp_ftd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
-endif # OPENTHREAD_ENABLE_FTD
+if OPENTHREAD_ENABLE_NCP_MTD
bin_PROGRAMS += \
ot-ncp-mtd \
$(NULL)
+endif
ot_ncp_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_ncp_mtd_LDADD = \
- $(top_builddir)/src/ncp/libopenthread-ncp.a \
+ $(top_builddir)/src/ncp/libopenthread-ncp-mtd.a \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(NULL)
diff --git a/include/openthread-windows-config.h b/include/openthread-windows-config.h
index 6440daf4b..dc74c35cf 100644
--- a/include/openthread-windows-config.h
+++ b/include/openthread-windows-config.h
@@ -26,6 +26,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* Define to 1 to enable the NCP UART interface. */
+// On the command line: #define OPENTHREAD_ENABLE_NCP_UART 0
+
+/* Define to 1 to enable the NCP SPI interface. */
+// On the command line: #define OPENTHREAD_ENABLE_NCP_SPI 1
+
/* Define to 1 if you want to enable default logging */
#define OPENTHREAD_ENABLE_DEFAULT_LOGGING 1
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 5e1f1f3cd..3b9f7b13c 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -28,9 +28,92 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
-lib_LIBRARIES = libopenthread-cli.a
+#----------------------------------------
+#
+# This library on the face of it, appears to be identical
+# for both the MTD and FTD varients, however ...
+#
+# The source code here includes numerous OpenThread internal headers.
+# Due to the "domino-effect" other internal headers are included.
+#
+# For example:
+# cli.cpp includes:
+# src/core/openthread-instance.h
+# Which Includes:
+# src/core/therad/thread_netif.hpp
+# Which Includes:
+# src/core/meshcop/dataset_manager.hpp
+# Which Includes:
+# src/core/threadnetwork_data_leader.hpp
+#
+# That header (and others) is either an MTD or FTD class flavor.
+#
+# The FTD flavor has many private components (class variables).
+# The MTD flavor has no private components.
+#
+# Bottom line: The Class(structs) are thus different in the downstream
+# libs. At this level (in the CLI, and likewise in the NCP) they are
+# functionally identical.
+#
+# ORIGINALLY (historical note about how things are/where built):
+#
+# The difference between MTD and FTD was a define.. -DOPENTHREAD_MTD
+# There was no "FTD" define, it is/was assumed that FTD is the default.
+#
+# Historically this library -DOPENTHREAD_MTD was not defined/set.
+# (it is set via a commandline define in 'lib-openthread')
+#
+# Thus, the existing(previous) way *THIS* library was compiled is
+# exactly the FTD path. Meaning the "cli" library always sees
+# the FTD varients of various headers/classes.
+#
+# The same is true of the "ncp" library.
+#
+# HOWEVER there are two varients of the CLI application, CLI-MTD
+# and CLI-FTD (and likewise, two varients of the ncp application)
+# These applications link against two different OpenThread libraries.
+#
+# Which flavor, you get depends upon which library: "mtd" or "ftd" is linked.
+#
+# Which on the surface appear to link fine against the MTD/FTD library.
+#
+# In this description/example we focus on the "nework_data_leader"
+# header file. The FTD varient has many private variables, functions
+# and other things of "FTD" (ie: full) implementation items.
+#
+# In contrast the MTD is generaly stubbed out with stub-functions
+# inlined in the header that return "error not implemented" or similar.
+#
+# Thus it works... here ... With this file and this example.
+#
+# The unknown:
+# What about the other files?
+# What about the other c++ classes?
+# Is this true always? Is this robust?
+# Or is there a hidden "got-ya" that will snag the next person?
+#
+# This also fails static analisys, checks.
+# Application - with MTD vrs FTD class.
+# Library #1 (cli-lib) with FTD selected.
+# Library #2 (openthread) with two different class flavors.
+#
+# The static analisys tools will say: "NOPE" different classes!
+# Perhaps this will change if/when nothing is implemented in the 'mtd-header'
+#
+# Additionally, tools that perform "whole program optimization" will
+# throw errors becuase the data structures differ greatly.
+#
+# Hence, CLI library (and NCP) must exist in two flavors.
+#
+# Unless and until these libraries do not "accidently" suck in
+# a "flavored" header file somewhere.
-libopenthread_cli_a_CPPFLAGS = \
+lib_LIBRARIES = \
+ libopenthread-cli-mtd.a \
+ libopenthread-cli-ftd.a \
+ $(NULL)
+
+CPPFLAGS_COMMON = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
@@ -38,17 +121,33 @@ libopenthread_cli_a_CPPFLAGS = \
$(MISSING_CPPFLAGS) \
$(NULL)
-libopenthread_cli_a_SOURCES = \
+
+libopenthread_cli_mtd_a_CPPFLAGS = \
+ -DOPENTHREAD_MTD=1 \
+ $(CPPFLAGS_COMMON) \
+ $(NULL)
+
+libopenthread_cli_ftd_a_CPPFLAGS = \
+ -DOPENTHREAD_FTD=1 \
+ $(CPPFLAGS_COMMON) \
+ $(NULL)
+
+SOURCES_COMMON = \
cli.cpp \
cli_console.cpp \
cli_dataset.cpp \
cli_uart.cpp \
+ cli_coap.cpp \
cli_udp.cpp \
$(NULL)
-
-if OPENTHREAD_ENABLE_APPLICATION_COAP
-libopenthread_cli_a_SOURCES += cli_coap.cpp
-endif
+
+libopenthread_cli_ftd_a_SOURCES = \
+ $(SOURCES_COMMON) \
+ $(NULL)
+
+libopenthread_cli_mtd_a_SOURCES = \
+ $(SOURCES_COMMON) \
+ $(NULL)
noinst_HEADERS = \
cli.hpp \
@@ -56,12 +155,9 @@ noinst_HEADERS = \
cli_dataset.hpp \
cli_uart.hpp \
cli_server.hpp \
+ cli_coap.hpp \
cli_udp.hpp \
$(NULL)
-
-if OPENTHREAD_ENABLE_APPLICATION_COAP
-noinst_HEADERS += cli_coap.hpp
-endif
if OPENTHREAD_BUILD_COVERAGE
CLEANFILES = $(wildcard *.gcda *.gcno)
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index eb5525463..0b3d93927 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -90,7 +90,7 @@ const struct Command Interpreter::sCommands[] =
#if OPENTHREAD_ENABLE_APPLICATION_COAP
{ "coap", &Interpreter::ProcessCoap },
#endif
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
{ "commissioner", &Interpreter::ProcessCommissioner },
#endif
{ "contextreusedelay", &Interpreter::ProcessContextIdReuseDelay },
@@ -2420,7 +2420,7 @@ void Interpreter::ProcessVersion(int argc, char *argv[])
(void)argv;
}
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
void Interpreter::ProcessCommissioner(int argc, char *argv[])
{
@@ -2704,7 +2704,7 @@ void Interpreter::HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask)
sServer->OutputFormat("Conflict: %04x, %08x\r\n", aPanId, aChannelMask);
}
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_JOINER
diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp
index ef8346427..2a8acc270 100644
--- a/src/cli/cli.hpp
+++ b/src/cli/cli.hpp
@@ -169,9 +169,9 @@ private:
#if OPENTHREAD_ENABLE_APPLICATION_COAP
void ProcessCoap(int argc, char *argv[]);
#endif //OPENTHREAD_ENABLE_APPLICATION_COAP
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
void ProcessCommissioner(int argc, char *argv[]);
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
void ProcessContextIdReuseDelay(int argc, char *argv[]);
void ProcessCounters(int argc, char *argv[]);
void ProcessDataset(int argc, char *argv[]);
diff --git a/src/cli/cli_coap.cpp b/src/cli/cli_coap.cpp
index a721acbb7..1b0ca925c 100644
--- a/src/cli/cli_coap.cpp
+++ b/src/cli/cli_coap.cpp
@@ -33,6 +33,9 @@
#include
#include
+
+#if OPENTHREAD_ENABLE_APPLICATION_COAP
+
#include
#include
@@ -390,3 +393,5 @@ void Coap::HandleClientResponse(otCoapHeader *aHeader, otMessage *aMessage, otMe
} // namespace Cli
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index a5cff11bf..227fe5f6f 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -29,6 +29,8 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = \
+ libopenthread-ftd.a \
+ libopenthread-mtd.a \
$(NULL)
CPPFLAGS_COMMON = \
@@ -39,13 +41,70 @@ CPPFLAGS_COMMON = \
$(OPENTHREAD_TARGET_DEFINES) \
$(NULL)
+
+libopenthread_ftd_a_CPPFLAGS = \
+ $(CPPFLAGS_COMMON) \
+ -DOPENTHREAD_FTD=1 \
+ $(NULL)
+
+libopenthread_mtd_a_CPPFLAGS = \
+ $(CPPFLAGS_COMMON) \
+ -DOPENTHREAD_MTD=1 \
+ $(NULL)
+
+#----------------------------------------
+# Note to maintainer/developers about "SOURCES_COMMON"
+#
+# The traditional method for GNU style Makefile.am files
+# is to have IF statements within the Makefile
+#
+# These IF statements would add (or not add) certain
+# source files from the build/library being built.
+#
+# In general, IDEs do not easily support this.
+# Some do, some do not, those that do support it
+# often do so in a very different or complex way.
+# Bottom line: It is a very mixed bag of results.
+#
+# Thus we bend to the IDEs, and impose these rules:
+#
+# Rule #1
+# All code(files) should be compiled
+# Even if it is not used or required
+#
+# For example: In the MTD build, some features
+# are disabled and thus in the traditional scheme
+# source files could be excluded SOURCES_COMMON
+# via makefile IF/ELSE/ENDIF constructs.
+#
+# This makes it impossibly hard for IDEs.
+# Thus we compile everything.
+#
+# And then rely upon Rule #2.
+#
+# Rule #2
+# Files that are not required, in certain
+# configurations require appropriate wrappers
+# Such as #if/#else/#endif
+#
+# The net result is sort of an "empty translation unit"
+#
+
SOURCES_COMMON = \
+ api/coap_api.cpp \
+ api/commissioner_api.cpp \
api/crypto_api.cpp \
api/dataset_api.cpp \
+ api/dhcp6_api.cpp \
+ api/dhcp6_api.cpp \
+ api/dns_api.cpp \
api/icmp6_api.cpp \
api/instance_api.cpp \
api/ip6_api.cpp \
+ api/jam_detection_api.cpp \
+ api/joiner_api.cpp \
api/link_api.cpp \
+ api/link_raw_api.cpp \
api/message_api.cpp \
api/netdata_api.cpp \
api/tasklet_api.cpp \
@@ -55,6 +114,8 @@ SOURCES_COMMON = \
coap/coap_client.cpp \
coap/coap_header.cpp \
coap/coap_server.cpp \
+ coap/secure_coap_client.cpp \
+ coap/secure_coap_server.cpp \
common/crc16.cpp \
common/logging.cpp \
common/message.cpp \
@@ -66,12 +127,27 @@ SOURCES_COMMON = \
crypto/aes_ecb.cpp \
crypto/hmac_sha256.cpp \
crypto/mbedtls.cpp \
+ crypto/pbkdf2_cmac.cpp \
crypto/sha256.cpp \
mac/mac.cpp \
+ mac/mac_blacklist.cpp \
mac/mac_frame.cpp \
+ mac/mac_whitelist.cpp \
+ meshcop/announce_begin_client.cpp \
+ meshcop/commissioner.cpp \
meshcop/dataset.cpp \
meshcop/dataset_manager.cpp \
+ meshcop/dataset_manager_ftd.cpp \
+ meshcop/dtls.cpp \
+ meshcop/energy_scan_client.cpp \
+ meshcop/joiner.cpp \
+ meshcop/joiner_router.cpp \
+ meshcop/leader.cpp \
+ meshcop/panid_query_client.cpp \
meshcop/timestamp.cpp \
+ net/dhcp6_client.cpp \
+ net/dhcp6_server.cpp \
+ net/dns_client.cpp \
net/icmp6.cpp \
net/ip6.cpp \
net/ip6_address.cpp \
@@ -80,6 +156,7 @@ SOURCES_COMMON = \
net/ip6_routes.cpp \
net/netif.cpp \
net/udp6.cpp \
+ thread/address_resolver.cpp \
thread/announce_begin_server.cpp \
thread/data_poll_manager.cpp \
thread/energy_scan_server.cpp \
@@ -88,24 +165,19 @@ SOURCES_COMMON = \
thread/lowpan.cpp \
thread/mesh_forwarder.cpp \
thread/mle.cpp \
+ thread/mle_router.cpp \
thread/network_data.cpp \
thread/network_data_leader.cpp \
- thread/panid_query_server.cpp \
+ thread/network_data_leader_ftd.cpp \
+ thread/network_data_local.cpp \
thread/network_diagnostic.cpp \
+ thread/panid_query_server.cpp \
thread/src_match_controller.cpp \
thread/thread_netif.cpp \
+ utils/jam_detector.cpp \
utils/slaac_address.cpp \
$(NULL)
-SOURCES_FTD = \
- meshcop/dataset_manager_ftd.cpp \
- meshcop/joiner_router.cpp \
- meshcop/leader.cpp \
- thread/address_resolver.cpp \
- thread/mle_router.cpp \
- thread/network_data_leader_ftd.cpp \
- thread/network_data_local.cpp \
- $(NULL)
SOURCES_MISSING = \
$(NULL)
@@ -144,105 +216,14 @@ CPPFLAGS_COMMON += -I$(top_srcdir)/src/missing/strlcat
SOURCES_MISSING += strlcat.c
endif
-if OPENTHREAD_ENABLE_APPLICATION_COAP
-SOURCES_COMMON += \
- api/coap_api.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_APPLICATION_COAP
-if OPENTHREAD_ENABLE_MAC_WHITELIST
-SOURCES_COMMON += \
- mac/mac_blacklist.cpp \
- mac/mac_whitelist.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_MAC_WHITELIST
-if OPENTHREAD_ENABLE_COMMISSIONER
-SOURCES_COMMON += \
- api/commissioner_api.cpp \
- coap/secure_coap_server.cpp \
- crypto/pbkdf2_cmac.cpp \
- meshcop/announce_begin_client.cpp \
- meshcop/commissioner.cpp \
- meshcop/energy_scan_client.cpp \
- meshcop/panid_query_client.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_COMMISSIONER
-
-if OPENTHREAD_ENABLE_JOINER
-SOURCES_COMMON += \
- api/joiner_api.cpp \
- coap/secure_coap_client.cpp \
- meshcop/joiner.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_JOINER
-
-if OPENTHREAD_ENABLE_DTLS
-SOURCES_COMMON += \
- meshcop/dtls.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_DTLS
-
-if OPENTHREAD_ENABLE_DHCP6_CLIENT
-SOURCES_COMMON += \
- api/dhcp6_api.cpp \
- net/dhcp6_client.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_DHCP6_CLIENT
-
-if OPENTHREAD_ENABLE_DHCP6_SERVER
-SOURCES_COMMON += \
- api/dhcp6_api.cpp \
- net/dhcp6_server.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_DHCP6_SERVER
-
-if OPENTHREAD_ENABLE_DNS_CLIENT
-SOURCES_COMMON += \
- api/dns_api.cpp \
- net/dns_client.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_DNS_CLIENT
-
-if OPENTHREAD_ENABLE_JAM_DETECTION
-SOURCES_COMMON += \
- api/jam_detection_api.cpp \
- utils/jam_detector.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_JAM_DETECTION
-
-if OPENTHREAD_ENABLE_RAW_LINK_API
-SOURCES_COMMON += \
- api/link_raw_api.cpp \
- $(NULL)
-endif # OPENTHREAD_ENABLE_RAW_LINK_API
-
-if OPENTHREAD_ENABLE_FTD
-lib_LIBRARIES += \
- libopenthread-ftd.a \
- $(NULL)
-
-libopenthread_ftd_a_CPPFLAGS = \
- $(CPPFLAGS_COMMON) \
+libopenthread_mtd_a_SOURCES = \
+ $(SOURCES_COMMON) \
+ $(SOURCES_MISSING) \
$(NULL)
libopenthread_ftd_a_SOURCES = \
- $(SOURCES_COMMON) \
- $(SOURCES_FTD) \
- $(SOURCES_MISSING) \
- $(NULL)
-endif # OPENTHREAD_ENABLE_FTD
-
-lib_LIBRARIES += \
- libopenthread-mtd.a \
- $(NULL)
-
-libopenthread_mtd_a_CPPFLAGS = \
- $(CPPFLAGS_COMMON) \
- -DOPENTHREAD_MTD \
- $(NULL)
-
-libopenthread_mtd_a_SOURCES = \
$(SOURCES_COMMON) \
$(SOURCES_MISSING) \
$(NULL)
diff --git a/src/core/api/coap_api.cpp b/src/core/api/coap_api.cpp
index 2ea2dff84..998c8cdba 100644
--- a/src/core/api/coap_api.cpp
+++ b/src/core/api/coap_api.cpp
@@ -36,6 +36,8 @@
#include "openthread-instance.h"
#include "coap/coap_header.hpp"
+#if OPENTHREAD_ENABLE_APPLICATION_COAP
+
using namespace Thread;
void otCoapHeaderInit(otCoapHeader *aHeader, otCoapType aType, otCoapCode aCode)
@@ -172,3 +174,5 @@ ThreadError otCoapSendResponse(otInstance *aInstance, otMessage *aMessage, const
return aInstance->mApplicationCoapServer.SendMessage(
*static_cast(aMessage), *static_cast(aMessageInfo));
}
+
+#endif // OPENTHREAD_ENABLE_APPLICATION_COAP
diff --git a/src/core/api/commissioner_api.cpp b/src/core/api/commissioner_api.cpp
index 978ac3d53..8bbe7c32d 100644
--- a/src/core/api/commissioner_api.cpp
+++ b/src/core/api/commissioner_api.cpp
@@ -37,7 +37,7 @@
using namespace Thread;
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
ThreadError otCommissionerStart(otInstance *aInstance)
{
@@ -117,4 +117,4 @@ ThreadError otCommissionerGeneratePSKc(otInstance *aInstance, const char *aPassP
return aInstance->mThreadNetif.GetCommissioner().GeneratePSKc(aPassPhrase, aNetworkName, aExtPanId, aPSKc);
}
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp
index 50718cfcc..f76d6281f 100644
--- a/src/core/api/link_raw_api.cpp
+++ b/src/core/api/link_raw_api.cpp
@@ -37,6 +37,8 @@
#include "openthread/platform/usec-alarm.h"
#include "openthread-instance.h"
+#if OPENTHREAD_ENABLE_RAW_LINK_API
+
ThreadError otLinkRawSetEnable(otInstance *aInstance, bool aEnabled)
{
ThreadError error = kThreadError_None;
@@ -604,3 +606,5 @@ void LinkRaw::HandleEnergyScanTask(void)
#endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_RAW_LINK_API
diff --git a/src/core/coap/secure_coap_client.cpp b/src/core/coap/secure_coap_client.cpp
index 9f68dac9a..58b8acc0e 100644
--- a/src/core/coap/secure_coap_client.cpp
+++ b/src/core/coap/secure_coap_client.cpp
@@ -33,6 +33,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_JOINER
+
/**
* @file
* This file implements the secure CoAP client.
@@ -243,3 +245,5 @@ exit:
} // namespace Coap
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_JOINER
diff --git a/src/core/coap/secure_coap_server.cpp b/src/core/coap/secure_coap_server.cpp
index a76bd3c85..f44849ceb 100644
--- a/src/core/coap/secure_coap_server.cpp
+++ b/src/core/coap/secure_coap_server.cpp
@@ -33,6 +33,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
/**
* @file
* This file implements the secure CoAP server.
@@ -264,3 +266,5 @@ exit:
} // namespace Coap
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
diff --git a/src/core/crypto/pbkdf2_cmac.cpp b/src/core/crypto/pbkdf2_cmac.cpp
index fe95f3179..25b718c97 100644
--- a/src/core/crypto/pbkdf2_cmac.cpp
+++ b/src/core/crypto/pbkdf2_cmac.cpp
@@ -31,10 +31,18 @@
* This file implements PBKDF2 using AES-CMAC-PRF-128
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
#include
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
void otPbkdf2Cmac(
const uint8_t *aPassword, uint16_t aPasswordLen,
const uint8_t *aSalt, uint16_t aSaltLen,
@@ -84,3 +92,5 @@ void otPbkdf2Cmac(
keyLen -= useLen;
}
}
+
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
diff --git a/src/core/mac/mac_blacklist.cpp b/src/core/mac/mac_blacklist.cpp
index eafc375d0..5802422e4 100644
--- a/src/core/mac/mac_blacklist.cpp
+++ b/src/core/mac/mac_blacklist.cpp
@@ -36,6 +36,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_MAC_WHITELIST
+
namespace Thread {
namespace Mac {
@@ -126,3 +128,5 @@ exit:
} // namespace Mac
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_MAC_WHITELIST
diff --git a/src/core/mac/mac_whitelist.cpp b/src/core/mac/mac_whitelist.cpp
index b4f139eb9..4c48d24af 100644
--- a/src/core/mac/mac_whitelist.cpp
+++ b/src/core/mac/mac_whitelist.cpp
@@ -36,6 +36,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_MAC_WHITELIST
+
namespace Thread {
namespace Mac {
@@ -151,3 +153,5 @@ void Whitelist::SetFixedRssi(Entry &aEntry, int8_t aRssi)
} // namespace Mac
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_MAC_WHITELIST
diff --git a/src/core/meshcop/announce_begin_client.cpp b/src/core/meshcop/announce_begin_client.cpp
index f1c8c33e7..a89502b46 100644
--- a/src/core/meshcop/announce_begin_client.cpp
+++ b/src/core/meshcop/announce_begin_client.cpp
@@ -51,6 +51,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
namespace Thread {
AnnounceBeginClient::AnnounceBeginClient(ThreadNetif &aThreadNetif) :
@@ -120,3 +122,6 @@ exit:
}
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp
index 861ad4d39..b3db0b53e 100644
--- a/src/core/meshcop/commissioner.cpp
+++ b/src/core/meshcop/commissioner.cpp
@@ -58,6 +58,8 @@
#include
#include
+#if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
+
using Thread::Encoding::BigEndian::HostSwap64;
namespace Thread {
@@ -1084,3 +1086,5 @@ exit:
} // namespace MeshCoP
} // namespace Thread
+
+#endif // OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER
diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp
index 6b3099e33..1b383bfff 100644
--- a/src/core/meshcop/dataset_manager.cpp
+++ b/src/core/meshcop/dataset_manager.cpp
@@ -585,7 +585,7 @@ ThreadError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset,
VerifyOrExit((message = NewMeshCoPMessage(mNetif.GetCoapClient(), header)) != NULL,
error = kThreadError_NoBufs);
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
bool isCommissioner;
isCommissioner = mNetif.GetCommissioner().GetState() != kCommissionerStateDisabled ? true : false;
@@ -618,7 +618,7 @@ ThreadError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset,
}
}
-#endif
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
if (aDataset.mIsActiveTimestampSet)
{
diff --git a/src/core/meshcop/dataset_manager.hpp b/src/core/meshcop/dataset_manager.hpp
index 7c2ef2e2b..465b92f18 100644
--- a/src/core/meshcop/dataset_manager.hpp
+++ b/src/core/meshcop/dataset_manager.hpp
@@ -183,10 +183,12 @@ private:
} // namespace MeshCoP
} // namespace Thread
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "dataset_manager_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "dataset_manager_ftd.hpp"
+#else
+#error Must define OPENTHREAD_MTD or OPENTHREAD_FTD
#endif
#endif // MESHCOP_DATASET_MANAGER_HPP_
diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp
index 973c0ab9e..7513352bc 100644
--- a/src/core/meshcop/dataset_manager_ftd.cpp
+++ b/src/core/meshcop/dataset_manager_ftd.cpp
@@ -34,6 +34,12 @@
#define WPP_NAME "dataset_manager.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include "openthread/platform/random.h"
@@ -54,6 +60,8 @@
#include
#include
+#if OPENTHREAD_FTD
+
namespace Thread {
namespace MeshCoP {
@@ -246,3 +254,5 @@ exit:
} // namespace MeshCoP
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp
index 63ca99f4d..910d783cd 100644
--- a/src/core/meshcop/dtls.cpp
+++ b/src/core/meshcop/dtls.cpp
@@ -31,6 +31,12 @@
* This file implements the necessary hooks for mbedTLS.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#define WPP_NAME "dtls.tmh"
#include
@@ -44,6 +50,8 @@
#include
+#if OPENTHREAD_ENABLE_DTLS
+
namespace Thread {
namespace MeshCoP {
@@ -510,3 +518,5 @@ void Dtls::HandleMbedtlsDebug(void *ctx, int level, const char *, int, const cha
} // namespace MeshCoP
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_DTLS
diff --git a/src/core/meshcop/energy_scan_client.cpp b/src/core/meshcop/energy_scan_client.cpp
index 8a76aadc1..29b9a5630 100644
--- a/src/core/meshcop/energy_scan_client.cpp
+++ b/src/core/meshcop/energy_scan_client.cpp
@@ -31,6 +31,12 @@
* This file implements the Energy Scan Client.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#define WPP_NAME "energy_scan_client.tmh"
#include "openthread/platform/random.h"
@@ -46,6 +52,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
using Thread::Encoding::BigEndian::HostSwap16;
using Thread::Encoding::BigEndian::HostSwap32;
@@ -174,3 +182,6 @@ exit:
}
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp
index e4897a15b..9d32f140d 100644
--- a/src/core/meshcop/joiner.cpp
+++ b/src/core/meshcop/joiner.cpp
@@ -55,6 +55,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_JOINER
+
using Thread::Encoding::BigEndian::HostSwap16;
using Thread::Encoding::BigEndian::HostSwap64;
@@ -519,3 +521,5 @@ void Joiner::HandleTimer(void)
} // namespace MeshCoP
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_JOINER
diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp
index 01dcb3297..68a2f324f 100644
--- a/src/core/meshcop/joiner_router.cpp
+++ b/src/core/meshcop/joiner_router.cpp
@@ -39,6 +39,8 @@
#include
#endif
+#if OPENTHREAD_FTD
+
#include
#include
@@ -533,3 +535,6 @@ exit:
} // namespace Dtls
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
+
diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp
index 50aceab51..9653ade39 100644
--- a/src/core/meshcop/joiner_router.hpp
+++ b/src/core/meshcop/joiner_router.hpp
@@ -26,8 +26,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "joiner_router_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "joiner_router_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1, or OPENTHREAD_FTD=1"
#endif
diff --git a/src/core/meshcop/leader.cpp b/src/core/meshcop/leader.cpp
index 4c8cb1a95..4a3c064bb 100644
--- a/src/core/meshcop/leader.cpp
+++ b/src/core/meshcop/leader.cpp
@@ -33,6 +33,14 @@
#define WPP_NAME "leader.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
+#if OPENTHREAD_FTD
+
#include
#include "openthread/platform/random.h"
@@ -309,3 +317,6 @@ void Leader::ResignCommissioner(void)
} // namespace MeshCoP
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
+
diff --git a/src/core/meshcop/leader.hpp b/src/core/meshcop/leader.hpp
index d724d0a5a..f2e90667b 100644
--- a/src/core/meshcop/leader.hpp
+++ b/src/core/meshcop/leader.hpp
@@ -26,8 +26,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "leader_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "leader_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
+
diff --git a/src/core/meshcop/panid_query_client.cpp b/src/core/meshcop/panid_query_client.cpp
index 1b0c770ca..3a884a3a7 100644
--- a/src/core/meshcop/panid_query_client.cpp
+++ b/src/core/meshcop/panid_query_client.cpp
@@ -31,6 +31,13 @@
* This file implements the PAN ID Query Client.
*/
+
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#define WPP_NAME "panid_query_client.tmh"
#include "openthread/platform/random.h"
@@ -45,6 +52,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
namespace Thread {
PanIdQueryClient::PanIdQueryClient(ThreadNetif &aThreadNetif) :
@@ -153,3 +162,6 @@ exit:
}
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
+
diff --git a/src/core/net/dhcp6_server.cpp b/src/core/net/dhcp6_server.cpp
index 33823f445..1233201ef 100644
--- a/src/core/net/dhcp6_server.cpp
+++ b/src/core/net/dhcp6_server.cpp
@@ -33,6 +33,12 @@
#define WPP_NAME "dhcp6_server.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include "openthread/types.h"
#include
@@ -42,6 +48,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_DHCP6_SERVER
+
using Thread::Encoding::BigEndian::HostSwap16;
using Thread::Encoding::BigEndian::HostSwap32;
@@ -569,3 +577,5 @@ ThreadError Dhcp6Server::AppendRapidCommit(Message &aMessage)
} // namespace Dhcp6
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_DHCP6_SERVER
diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp
index 7cfb22912..5154f7c7f 100644
--- a/src/core/net/dns_client.cpp
+++ b/src/core/net/dns_client.cpp
@@ -26,6 +26,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
@@ -33,6 +39,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_DNS_CLIENT
+
/**
* @file
* This file implements the DNS client.
@@ -515,3 +523,5 @@ exit:
} // namespace Coap
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_DNS_CLIENT
diff --git a/src/core/net/icmp6.cpp b/src/core/net/icmp6.cpp
index 1ed7b5d11..f4fa58ee1 100644
--- a/src/core/net/icmp6.cpp
+++ b/src/core/net/icmp6.cpp
@@ -33,6 +33,12 @@
#define WPP_NAME "icmp6.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp
index 87e5d2b8a..2629c0768 100644
--- a/src/core/thread/address_resolver.cpp
+++ b/src/core/thread/address_resolver.cpp
@@ -31,8 +31,16 @@
* This file implements Thread's EID-to-RLOC mapping and caching.
*/
+#if OPENTHREAD_FTD
+
#define WPP_NAME "address_resolver.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include "openthread/platform/random.h"
#include
@@ -684,3 +692,5 @@ exit:
}
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
diff --git a/src/core/thread/address_resolver.hpp b/src/core/thread/address_resolver.hpp
index 2a0e7d913..e48648ac0 100644
--- a/src/core/thread/address_resolver.hpp
+++ b/src/core/thread/address_resolver.hpp
@@ -26,8 +26,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "address_resolver_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "address_resolver_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
+
+
diff --git a/src/core/thread/key_manager.cpp b/src/core/thread/key_manager.cpp
index dc2249a24..6eff30a8f 100644
--- a/src/core/thread/key_manager.cpp
+++ b/src/core/thread/key_manager.cpp
@@ -31,6 +31,13 @@
* This file implements Thread security material generation.
*/
+
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
#include
diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp
index a9a60a242..f47ff3e39 100644
--- a/src/core/thread/mle_router.cpp
+++ b/src/core/thread/mle_router.cpp
@@ -30,8 +30,16 @@
* This file implements MLE functionality required for the Thread Router and Leader roles.
*/
+#if OPENTHREAD_FTD
+
#define WPP_NAME "mle_router.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include "openthread/platform/random.h"
#include "openthread/platform/settings.h"
@@ -4502,3 +4510,6 @@ uint8_t MleRouter::GetMinDowngradeNeighborRouters(void)
} // namespace Mle
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
+
diff --git a/src/core/thread/mle_router.hpp b/src/core/thread/mle_router.hpp
index a3744e0bd..18b8bef46 100644
--- a/src/core/thread/mle_router.hpp
+++ b/src/core/thread/mle_router.hpp
@@ -26,8 +26,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "mle_router_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "mle_router_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
+
diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp
index 31644e26e..2a9670b61 100644
--- a/src/core/thread/network_data_leader.cpp
+++ b/src/core/thread/network_data_leader.cpp
@@ -33,6 +33,12 @@
#define WPP_NAME "network_data_leader.tmh"
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include "openthread/platform/random.h"
#include
diff --git a/src/core/thread/network_data_leader.hpp b/src/core/thread/network_data_leader.hpp
index 90e46590c..2ace05973 100644
--- a/src/core/thread/network_data_leader.hpp
+++ b/src/core/thread/network_data_leader.hpp
@@ -232,10 +232,12 @@ private:
} // namespace NetworkData
} // namespace Thread
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "network_data_leader_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "network_data_leader_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
#endif // NETWORK_DATA_LEADER_HPP_
diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp
index 77934f45e..93e8b75d0 100644
--- a/src/core/thread/network_data_leader_ftd.cpp
+++ b/src/core/thread/network_data_leader_ftd.cpp
@@ -31,6 +31,14 @@
* This file implements the Thread Network Data managed by the Thread Leader.
*/
+#if OPENTHREAD_FTD
+
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#define WPP_NAME "network_data_leader_ftd.tmh"
#include "openthread/platform/random.h"
@@ -1072,3 +1080,6 @@ void Leader::HandleTimer(void)
} // namespace NetworkData
} // namespace Thread
+
+#endif // OPENTHREAD_FTD
+
diff --git a/src/core/thread/network_data_local.cpp b/src/core/thread/network_data_local.cpp
index 4fc6ca906..11b23bf2e 100644
--- a/src/core/thread/network_data_local.cpp
+++ b/src/core/thread/network_data_local.cpp
@@ -31,6 +31,12 @@
* This file implements the local Thread Network Data.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
#include
@@ -38,6 +44,8 @@
#include
#include
+#if OPENTHREAD_FTD
+
namespace Thread {
namespace NetworkData {
@@ -245,3 +253,4 @@ exit:
} // namespace NetworkData
} // namespace Thread
+#endif // OPENTHREAD_FTD
diff --git a/src/core/thread/network_data_local.hpp b/src/core/thread/network_data_local.hpp
index 75aeb3cd9..2363ec5d4 100644
--- a/src/core/thread/network_data_local.hpp
+++ b/src/core/thread/network_data_local.hpp
@@ -26,8 +26,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef OPENTHREAD_MTD
+#if OPENTHREAD_MTD
#include "network_data_local_mtd.hpp"
-#else
+#elif OPENTHREAD_FTD
#include "network_data_local_ftd.hpp"
+#else
+#error "Please define OPENTHREAD_MTD=1 or OPENTHREAD_FTD=1"
#endif
+
diff --git a/src/core/thread/thread_netif.cpp b/src/core/thread/thread_netif.cpp
index 4d510407d..9e7a15eae 100644
--- a/src/core/thread/thread_netif.cpp
+++ b/src/core/thread/thread_netif.cpp
@@ -78,10 +78,10 @@ ThreadNetif::ThreadNetif(Ip6::Ip6 &aIp6):
mNetworkDataLocal(*this),
mNetworkDataLeader(*this),
mNetworkDiagnostic(*this),
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
mSecureCoapServer(*this, OPENTHREAD_CONFIG_JOINER_UDP_PORT),
mCommissioner(*this),
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_DTLS
mDtls(*this),
#endif
diff --git a/src/core/thread/thread_netif.hpp b/src/core/thread/thread_netif.hpp
index b7590b9a6..698f6714a 100644
--- a/src/core/thread/thread_netif.hpp
+++ b/src/core/thread/thread_netif.hpp
@@ -71,9 +71,9 @@
#include
#endif // OPENTHREAD_ENABLE_JAM_DETECTION
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#include
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_DTLS
#include
@@ -293,11 +293,11 @@ public:
AnnounceBeginServer &GetAnnounceBeginServer(void) { return mAnnounceBegin; }
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
MeshCoP::Commissioner &GetCommissioner(void) { return mCommissioner; }
Coap::SecureServer &GetSecureCoapServer(void) { return mSecureCoapServer; }
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#if OPENTHREAD_ENABLE_DTLS
MeshCoP::Dtls &GetDtls(void) { return mDtls; }
@@ -353,7 +353,7 @@ private:
NetworkDiagnostic::NetworkDiagnostic mNetworkDiagnostic;
bool mIsUp;
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
Coap::SecureServer mSecureCoapServer;
MeshCoP::Commissioner mCommissioner;
#endif // OPENTHREAD_ENABLE_COMMISSIONER
diff --git a/src/core/utils/jam_detector.cpp b/src/core/utils/jam_detector.cpp
index 1b79536ee..aa9c4d9a6 100644
--- a/src/core/utils/jam_detector.cpp
+++ b/src/core/utils/jam_detector.cpp
@@ -44,6 +44,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_JAM_DETECTION
+
namespace Thread {
namespace Utils {
@@ -241,3 +243,5 @@ void JamDetector::UpdateJamState(void)
} // namespace Utils
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_JAM_DETECTION
diff --git a/src/ncp/Makefile.am b/src/ncp/Makefile.am
index 1d902d3f8..c3350de9f 100644
--- a/src/ncp/Makefile.am
+++ b/src/ncp/Makefile.am
@@ -34,50 +34,65 @@ EXTRA_DIST = \
# Pull in the sources that comprise the OpenThread NCP library.
-lib_LIBRARIES = libopenthread-ncp.a
+lib_LIBRARIES = \
+ libopenthread-ncp-mtd.a \
+ libopenthread-ncp-ftd.a \
+ $(NULL)
-libopenthread_ncp_a_CPPFLAGS = \
+
+COMMON_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/core \
+ -I$(top_srcdir)/third_party \
+ -D_GNU_SOURCE \
+ $(OPENTHREAD_TARGET_DEFINES) \
+ $(MISSING_CPPFLAGS) \
+ $(NULL)
+
+
+COMMON_CXXFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/third_party \
-D_GNU_SOURCE \
- $(OPENTHREAD_TARGET_DEFINES) \
$(MISSING_CPPFLAGS) \
- $(NULL)
-
-libopenthread_ncp_a_CXXFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/src \
- -I$(top_srcdir)/src/core \
- -I$(top_srcdir)/third_party \
$(OPENTHREAD_TARGET_DEFINES) \
$(NULL)
-libopenthread_ncp_a_SOURCES = \
+libopenthread_ncp_mtd_a_CPPFLAGS = \
+ -DOPENTHREAD_MTD=1 \
+ $(COMMON_CXXFLAGS) \
+ $(NULL)
+
+libopenthread_ncp_ftd_a_CPPFLAGS = \
+ -DOPENTHREAD_FTD=1 \
+ $(COMMON_CXXFLAGS) \
+ $(NULL)
+
+COMMON_SOURCES = \
ncp_base.cpp \
ncp_base.hpp \
ncp_buffer.cpp \
ncp_buffer.hpp \
spinel.c \
spinel.h \
- $(NULL)
-
-if OPENTHREAD_ENABLE_NCP_SPI
-libopenthread_ncp_a_SOURCES += \
ncp_spi.cpp \
ncp_spi.hpp \
- $(NULL)
-endif
-
-if OPENTHREAD_ENABLE_NCP_UART
-libopenthread_ncp_a_SOURCES += \
hdlc.cpp \
hdlc.hpp \
ncp_uart.cpp \
ncp_uart.hpp \
$(NULL)
-endif
+
+libopenthread_ncp_mtd_a_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(NULL)
+
+libopenthread_ncp_ftd_a_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(NULL)
include_HEADERS = \
$(NULL)
diff --git a/src/ncp/hdlc.cpp b/src/ncp/hdlc.cpp
index af959e1ee..b90563b5f 100644
--- a/src/ncp/hdlc.cpp
+++ b/src/ncp/hdlc.cpp
@@ -30,10 +30,18 @@
* This file implements an HDLC-lite encoder and decoder.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
#include
+#if OPENTHREAD_ENABLE_NCP_UART
+
namespace Thread {
namespace Hdlc {
@@ -330,3 +338,5 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
} // namespace Hdlc
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_NCP_UART
diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp
index 7e7ccb9bb..a7c4fe350 100644
--- a/src/ncp/ncp_base.cpp
+++ b/src/ncp/ncp_base.cpp
@@ -47,7 +47,7 @@
#include "openthread/jam_detection.h"
#endif
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
#include "meshcop/commissioner.hpp"
#endif
@@ -156,7 +156,7 @@ const NcpBase::GetPropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
{ SPINEL_PROP_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE, &NcpBase::GetPropertyHandler_THREAD_ALLOW_LOCAL_NET_DATA_CHANGE },
{ SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED, &NcpBase::GetPropertyHandler_THREAD_ROUTER_ROLE_ENABLED },
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
{ SPINEL_PROP_THREAD_COMMISSIONER_ENABLED, &NcpBase::GetPropertyHandler_THREAD_COMMISSIONER_ENABLED },
#endif
@@ -319,7 +319,7 @@ const NcpBase::SetPropertyHandlerEntry NcpBase::mSetPropertyHandlerTable[] =
{ SPINEL_PROP_NEST_LEGACY_ULA_PREFIX, &NcpBase::SetPropertyHandler_NEST_LEGACY_ULA_PREFIX },
#endif
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
{ SPINEL_PROP_THREAD_COMMISSIONER_ENABLED, &NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED },
#endif
};
@@ -335,7 +335,7 @@ const NcpBase::InsertPropertyHandlerEntry NcpBase::mInsertPropertyHandlerTable[]
{ SPINEL_PROP_THREAD_ON_MESH_NETS, &NcpBase::InsertPropertyHandler_THREAD_ON_MESH_NETS },
{ SPINEL_PROP_THREAD_ASSISTING_PORTS, &NcpBase::InsertPropertyHandler_THREAD_ASSISTING_PORTS },
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
{ SPINEL_PROP_THREAD_JOINERS, &NcpBase::NcpBase::InsertPropertyHandler_THREAD_JOINERS },
#endif
@@ -3381,7 +3381,7 @@ ThreadError NcpBase::GetPropertyHandler_THREAD_NETWORK_ID_TIMEOUT(uint8_t header
);
}
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
ThreadError NcpBase::GetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t header, spinel_prop_key_t key)
{
bool isEnabled = false;
@@ -4836,7 +4836,7 @@ ThreadError NcpBase::SetPropertyHandler_CNTR_RESET(uint8_t header, spinel_prop_k
return SendLastStatus(header, ThreadErrorToSpinelStatus(errorCode));
}
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
ThreadError NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr,
uint16_t value_len)
{
@@ -4870,7 +4870,7 @@ ThreadError NcpBase::SetPropertyHandler_THREAD_COMMISSIONER_ENABLED(uint8_t head
return SendLastStatus(header, ThreadErrorToSpinelStatus(errorCode));
}
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
ThreadError NcpBase::SetPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_prop_key_t key, const uint8_t *value_ptr,
uint16_t value_len)
@@ -6118,7 +6118,7 @@ ThreadError NcpBase::InsertPropertyHandler_MAC_WHITELIST(uint8_t header, spinel_
return errorCode;
}
-#if OPENTHREAD_ENABLE_COMMISSIONER
+#if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
ThreadError NcpBase::InsertPropertyHandler_THREAD_JOINERS(uint8_t header, spinel_prop_key_t key,
const uint8_t *value_ptr, uint16_t value_len)
{
@@ -6182,7 +6182,7 @@ ThreadError NcpBase::InsertPropertyHandler_THREAD_JOINERS(uint8_t header, spinel
exit:
return errorCode;
}
-#endif // OPENTHREAD_ENABLE_COMMISSIONER
+#endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD
// ----------------------------------------------------------------------------
// MARK: Individual Property Removers
diff --git a/src/ncp/ncp_buffer.cpp b/src/ncp/ncp_buffer.cpp
index 677e0ea2e..ca27ca3f0 100644
--- a/src/ncp/ncp_buffer.cpp
+++ b/src/ncp/ncp_buffer.cpp
@@ -30,6 +30,12 @@
* This file implements NCP frame buffer class.
*/
+#ifdef OPENTHREAD_CONFIG_FILE
+#include OPENTHREAD_CONFIG_FILE
+#else
+#include
+#endif
+
#include
#include
#include
diff --git a/src/ncp/ncp_spi.cpp b/src/ncp/ncp_spi.cpp
index 5d42e264b..5f1a3f3c5 100644
--- a/src/ncp/ncp_spi.cpp
+++ b/src/ncp/ncp_spi.cpp
@@ -46,6 +46,8 @@
#define SPI_PATTERN_VALUE 0x02
#define SPI_PATTERN_MASK 0x03
+#if OPENTHREAD_ENABLE_NCP_SPI
+
namespace Thread {
static otDEFINE_ALIGNED_VAR(sNcpRaw, sizeof(NcpSpi), uint64_t);
@@ -348,3 +350,4 @@ void NcpSpi::HandleRxFrame(void)
} // namespace Thread
+#endif // OPENTHREAD_ENABLE_NCP_SPI
diff --git a/src/ncp/ncp_uart.cpp b/src/ncp/ncp_uart.cpp
index 75b44854b..9b2671cec 100644
--- a/src/ncp/ncp_uart.cpp
+++ b/src/ncp/ncp_uart.cpp
@@ -49,6 +49,8 @@
#include
#include
+#if OPENTHREAD_ENABLE_NCP_UART
+
namespace Thread {
static otDEFINE_ALIGNED_VAR(sNcpRaw, sizeof(NcpUart), uint64_t);
@@ -294,3 +296,5 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
} // namespace Thread
+
+#endif // OPENTHREAD_ENABLE_NCP_UART
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index e33c74429..d6f948b56 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -50,6 +50,7 @@ if OPENTHREAD_BUILD_TESTS
# makefile.
AM_CPPFLAGS = \
+ -DOPENTHREAD_FTD=1 \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
@@ -58,7 +59,7 @@ AM_CPPFLAGS = \
if OPENTHREAD_ENABLE_NCP
COMMON_LDADD = \
- $(top_builddir)/src/ncp/libopenthread-ncp.a \
+ $(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
-lpthread \
$(NULL)