diff --git a/.travis/script.sh b/.travis/script.sh index 5cee330a0..1b2236251 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -65,13 +65,13 @@ python --version || die -DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1 \ -DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1 \ -DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1 \ - -DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1" + -DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1 \ + -DOPENTHREAD_CONFIG_DIAG_ENABLE=1" scan-build ./configure \ --enable-builtin-mbedtls=no \ --enable-cert-log \ --enable-cli \ - --enable-diag \ --enable-dns-client \ --enable-ecdsa \ --enable-executable=no \ @@ -98,7 +98,6 @@ python --version || die --enable-builtin-mbedtls=no \ --enable-cert-log \ --enable-cli \ - --enable-diag \ --enable-dns-client \ --enable-ecdsa \ --enable-executable=no \ @@ -358,7 +357,8 @@ build_samr21() { -DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1 \ -DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1 \ -DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1 \ - -DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1" + -DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \ + -DOPENTHREAD_CONFIG_DIAG_ENABLE=1" git checkout -- . || die git clean -xfd || die @@ -369,7 +369,6 @@ build_samr21() { --enable-mtd \ --with-ncp-bus=spi \ --with-examples=posix \ - --enable-diag \ --enable-jam-detection \ --enable-legacy \ --enable-mac-filter \ diff --git a/Android.mk b/Android.mk index f067e0e2e..a1b5adea8 100644 --- a/Android.mk +++ b/Android.mk @@ -46,7 +46,7 @@ OPENTHREAD_COMMON_FLAGS := \ # Enable required features for on-device tests. ifeq ($(TARGET_BUILD_VARIANT),eng) OPENTHREAD_COMMON_FLAGS += \ - -DOPENTHREAD_ENABLE_DIAG=1 \ + -DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \ $(NULL) endif diff --git a/Makefile.am b/Makefile.am index 789773a6f..3d58c80a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,7 +34,6 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-address-sanitizer \ --enable-cert-log \ --enable-cli \ - --enable-diag \ --enable-dns-client \ --enable-ftd \ --enable-joiner \ diff --git a/configure.ac b/configure.ac index 5ed9afb22..10c39d981 100644 --- a/configure.ac +++ b/configure.ac @@ -993,38 +993,6 @@ AC_SUBST(OPENTHREAD_ENABLE_MAC_FILTER) AM_CONDITIONAL([OPENTHREAD_ENABLE_MAC_FILTER], [test "${enable_mac_filter}" = "yes"]) AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_MAC_FILTER],[${OPENTHREAD_ENABLE_MAC_FILTER}],[Define to 1 if you want to use MAC filter feature]) -# -# Factory Diagnostics -# - -AC_ARG_ENABLE(diag, - [AS_HELP_STRING([--enable-diag],[Enable diagnostics support @<:@default=no@:>@.])], - [ - case "${enableval}" in - - no|yes) - enable_diag=${enableval} - ;; - - *) - AC_MSG_ERROR([Invalid value ${enable_diag} for --enable-diag]) - ;; - esac - ], - [enable_diag=no]) - -if test "$enable_diag" = "yes"; then - OPENTHREAD_ENABLE_DIAG=1 -else - OPENTHREAD_ENABLE_DIAG=0 -fi - -AC_MSG_CHECKING([whether to enable diag]) -AC_MSG_RESULT(${enable_diag}) -AC_SUBST(OPENTHREAD_ENABLE_DIAG) -AM_CONDITIONAL([OPENTHREAD_ENABLE_DIAG], [test "${enable_diag}" = "yes"]) -AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_DIAG],[${OPENTHREAD_ENABLE_DIAG}],[Define to 1 if you want to enable factory diagnostics feature]) - # # Vendor Extension - Specify a C++ source file which will be built as part of OpenThread core library. # @@ -1725,7 +1693,6 @@ AC_MSG_NOTICE([ OpenThread Joiner support : ${enable_joiner} OpenThread Jam Detection support : ${enable_jam_detection} OpenThread MAC Filter support : ${enable_mac_filter} - OpenThread Factory Diagnostics support : ${enable_diag} OpenThread Legacy network support : ${enable_legacy} OpenThread DNS Client support : ${enable_dns_client} OpenThread SNTP Client support : ${enable_sntp_client} diff --git a/examples/Makefile-cc1352 b/examples/Makefile-cc1352 index c9396e6c7..ff712010d 100644 --- a/examples/Makefile-cc1352 +++ b/examples/Makefile-cc1352 @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-cc2538 b/examples/Makefile-cc2538 index 006fe7ffa..007d7ed5b 100644 --- a/examples/Makefile-cc2538 +++ b/examples/Makefile-cc2538 @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-cc2652 b/examples/Makefile-cc2652 index 56a1753ef..0f57b1881 100644 --- a/examples/Makefile-cc2652 +++ b/examples/Makefile-cc2652 @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-efr32mg12 b/examples/Makefile-efr32mg12 index dea4010a1..7bcbe9839 100644 --- a/examples/Makefile-efr32mg12 +++ b/examples/Makefile-efr32mg12 @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-efr32mg21 b/examples/Makefile-efr32mg21 index 8c7e14c46..cb929ea92 100644 --- a/examples/Makefile-efr32mg21 +++ b/examples/Makefile-efr32mg21 @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-gp712 b/examples/Makefile-gp712 index c1e285898..f111e5a1c 100644 --- a/examples/Makefile-gp712 +++ b/examples/Makefile-gp712 @@ -47,7 +47,6 @@ BuildJobs ?= 9 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --with-examples=$(PPREFIX) \ diff --git a/examples/Makefile-kw41z b/examples/Makefile-kw41z index 60b17df58..1861e8f49 100644 --- a/examples/Makefile-kw41z +++ b/examples/Makefile-kw41z @@ -43,7 +43,6 @@ BuildJobs ?= 10 configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-nrf52811 b/examples/Makefile-nrf52811 index 2862b4e07..0c1f1b053 100644 --- a/examples/Makefile-nrf52811 +++ b/examples/Makefile-nrf52811 @@ -44,7 +44,6 @@ GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d. configure_OPTIONS = \ --enable-mtd \ - --enable-diag \ --enable-linker-map \ --with-examples=nrf52811 \ MBEDTLS_CPPFLAGS="$(NRF52811_MBEDTLS_CPPFLAGS)" \ diff --git a/examples/Makefile-nrf52840 b/examples/Makefile-nrf52840 index e624f6b31..9518c0144 100644 --- a/examples/Makefile-nrf52840 +++ b/examples/Makefile-nrf52840 @@ -45,7 +45,6 @@ GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d. configure_OPTIONS = \ --enable-ftd \ --enable-mtd \ - --enable-diag \ --enable-linker-map \ --with-examples=nrf52840 \ $(NULL) diff --git a/examples/Makefile-qpg6095 b/examples/Makefile-qpg6095 index 059c5202a..4fe24e0ae 100644 --- a/examples/Makefile-qpg6095 +++ b/examples/Makefile-qpg6095 @@ -44,7 +44,6 @@ GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d. configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/Makefile-samr21 b/examples/Makefile-samr21 index 58b298b76..ce2fccbbd 100644 --- a/examples/Makefile-samr21 +++ b/examples/Makefile-samr21 @@ -58,7 +58,6 @@ endif configure_OPTIONS = \ --enable-cli \ - --enable-diag \ --enable-ftd \ --enable-mtd \ --enable-ncp \ diff --git a/examples/common-switches.mk b/examples/common-switches.mk index 03e952f64..b5b8ba80e 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -115,7 +115,7 @@ COMMONCFLAGS += -DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1 endif ifeq ($(DIAGNOSTIC),1) -configure_OPTIONS += --enable-diag +COMMONCFLAGS += -DOPENTHREAD_CONFIG_DIAG_ENABLE=1 endif ifeq ($(DISABLE_DOC),1) diff --git a/examples/platforms/cc1352/alarm.c b/examples/platforms/cc1352/alarm.c index 950c1794d..d26dfcd06 100644 --- a/examples/platforms/cc1352/alarm.c +++ b/examples/platforms/cc1352/alarm.c @@ -114,14 +114,14 @@ void cc1352AlarmProcess(otInstance *aInstance) if (sAlarmTime <= offsetTime) { sIsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagAlarmFired(aInstance); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatAlarmMilliFired(aInstance); } diff --git a/examples/platforms/cc1352/diag.c b/examples/platforms/cc1352/diag.c index 21e6d77aa..520b409e6 100644 --- a/examples/platforms/cc1352/diag.c +++ b/examples/platforms/cc1352/diag.c @@ -38,7 +38,7 @@ #include "platform-cc1352.h" -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -89,4 +89,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/cc1352/radio.c b/examples/platforms/cc1352/radio.c index 305125b0e..e4f55631e 100644 --- a/examples/platforms/cc1352/radio.c +++ b/examples/platforms/cc1352/radio.c @@ -1835,14 +1835,14 @@ static void cc1352RadioProcessTransmitDone(otInstance * aInstance, otRadioFrame *aAckFrame, otError aTransmitError) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, aTransmitFrame, aTransmitError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioTxDone(aInstance, aTransmitFrame, aAckFrame, aTransmitError); } @@ -1853,14 +1853,14 @@ static void cc1352RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *a // TODO Set this flag only when the packet is really acknowledged with frame pending set. // See https://github.com/openthread/openthread/pull/3785 aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } diff --git a/examples/platforms/cc2538/alarm.c b/examples/platforms/cc2538/alarm.c index 4821792f8..dd6cc206b 100644 --- a/examples/platforms/cc2538/alarm.c +++ b/examples/platforms/cc2538/alarm.c @@ -107,7 +107,7 @@ void cc2538AlarmProcess(otInstance *aInstance) { sIsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/cc2538/diag.c b/examples/platforms/cc2538/diag.c index 4b62a2c09..d99158842 100644 --- a/examples/platforms/cc2538/diag.c +++ b/examples/platforms/cc2538/diag.c @@ -37,7 +37,7 @@ #include "platform-cc2538.h" -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/cc2538/radio.c b/examples/platforms/cc2538/radio.c index 5da1e63d4..3a6a43314 100644 --- a/examples/platforms/cc2538/radio.c +++ b/examples/platforms/cc2538/radio.c @@ -718,7 +718,7 @@ void cc2538RadioProcess(otInstance *aInstance) // TODO Set this flag only when the packet is really acknowledged with frame pending set. // See https://github.com/openthread/openthread/pull/3785 sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -749,7 +749,7 @@ void cc2538RadioProcess(otInstance *aInstance) sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/cc2650/alarm.c b/examples/platforms/cc2650/alarm.c index e7798276c..d1ae1bf49 100644 --- a/examples/platforms/cc2650/alarm.c +++ b/examples/platforms/cc2650/alarm.c @@ -104,14 +104,14 @@ void cc2650AlarmProcess(otInstance *aInstance) if (sAlarmTime <= offsetTime) { sIsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagAlarmFired(aInstance); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatAlarmMilliFired(aInstance); } diff --git a/examples/platforms/cc2650/diag.c b/examples/platforms/cc2650/diag.c index 9a1d84901..7d0a7294c 100644 --- a/examples/platforms/cc2650/diag.c +++ b/examples/platforms/cc2650/diag.c @@ -34,7 +34,7 @@ #include -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE #include "platform-cc2650.h" /** @@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/cc2650/radio.c b/examples/platforms/cc2650/radio.c index de2fa1e9a..871df18e2 100644 --- a/examples/platforms/cc2650/radio.c +++ b/examples/platforms/cc2650/radio.c @@ -1784,14 +1784,14 @@ static void cc2650RadioProcessTransmitDone(otInstance * aInstance, otRadioFrame *aAckFrame, otError aTransmitError) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, aTransmitFrame, aTransmitError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioTxDone(aInstance, aTransmitFrame, aAckFrame, aTransmitError); } @@ -1802,14 +1802,14 @@ static void cc2650RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *a // TODO Set this flag only when the packet is really acknowledged with frame pending set. // See https://github.com/openthread/openthread/pull/3785 aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } diff --git a/examples/platforms/cc2652/alarm.c b/examples/platforms/cc2652/alarm.c index 08e375525..0c8f16cc6 100644 --- a/examples/platforms/cc2652/alarm.c +++ b/examples/platforms/cc2652/alarm.c @@ -114,14 +114,14 @@ void cc2652AlarmProcess(otInstance *aInstance) if (sAlarmTime <= offsetTime) { sIsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagAlarmFired(aInstance); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatAlarmMilliFired(aInstance); } diff --git a/examples/platforms/cc2652/diag.c b/examples/platforms/cc2652/diag.c index 8fdbd9c78..c530964a1 100644 --- a/examples/platforms/cc2652/diag.c +++ b/examples/platforms/cc2652/diag.c @@ -38,7 +38,7 @@ #include "platform-cc2652.h" -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -89,4 +89,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/cc2652/radio.c b/examples/platforms/cc2652/radio.c index dab3d19e8..ff5ad38de 100644 --- a/examples/platforms/cc2652/radio.c +++ b/examples/platforms/cc2652/radio.c @@ -1816,14 +1816,14 @@ static void cc2652RadioProcessTransmitDone(otInstance * aInstance, otRadioFrame *aAckFrame, otError aTransmitError) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, aTransmitFrame, aTransmitError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioTxDone(aInstance, aTransmitFrame, aAckFrame, aTransmitError); } @@ -1834,14 +1834,14 @@ static void cc2652RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *a // TODO Set this flag only when the packet is really acknowledged with frame pending set. // See https://github.com/openthread/openthread/pull/3785 aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } else -#endif /* OPENTHREAD_ENABLE_DIAG */ +#endif /* OPENTHREAD_CONFIG_DIAG_ENABLE */ { otPlatRadioReceiveDone(aInstance, aReceiveFrame, aReceiveError); } diff --git a/examples/platforms/efr32mg12/alarm.c b/examples/platforms/efr32mg12/alarm.c index d031fbeee..30cbdaf56 100644 --- a/examples/platforms/efr32mg12/alarm.c +++ b/examples/platforms/efr32mg12/alarm.c @@ -202,7 +202,7 @@ void efr32AlarmProcess(otInstance *aInstance) } } -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagAlarmFired(aInstance); diff --git a/examples/platforms/efr32mg12/diag.c b/examples/platforms/efr32mg12/diag.c index 97277be48..9da4bdfa6 100644 --- a/examples/platforms/efr32mg12/diag.c +++ b/examples/platforms/efr32mg12/diag.c @@ -43,7 +43,7 @@ #include "platform-efr32.h" -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -92,4 +92,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // #if OPENTHREAD_ENABLE_DIAG +#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/efr32mg12/radio.c b/examples/platforms/efr32mg12/radio.c index f31992344..0b61c64d6 100644 --- a/examples/platforms/efr32mg12/radio.c +++ b/examples/platforms/efr32mg12/radio.c @@ -685,7 +685,7 @@ static void processNextRxPacket(otInstance *aInstance) // See https://github.com/openthread/openthread/pull/3785 sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -824,7 +824,7 @@ void efr32RadioProcess(otInstance *aInstance) } sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError); diff --git a/examples/platforms/efr32mg21/alarm.c b/examples/platforms/efr32mg21/alarm.c index e888a599d..36b265fec 100644 --- a/examples/platforms/efr32mg21/alarm.c +++ b/examples/platforms/efr32mg21/alarm.c @@ -130,7 +130,7 @@ void efr32AlarmProcess(otInstance *aInstance) { sIsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/efr32mg21/diag.c b/examples/platforms/efr32mg21/diag.c index 0b9be6dd5..1d87bc3f8 100644 --- a/examples/platforms/efr32mg21/diag.c +++ b/examples/platforms/efr32mg21/diag.c @@ -43,7 +43,7 @@ #include "platform-efr32.h" -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -92,4 +92,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // #if OPENTHREAD_ENABLE_DIAG +#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/efr32mg21/radio.c b/examples/platforms/efr32mg21/radio.c index c89acaf2c..e9511afbf 100644 --- a/examples/platforms/efr32mg21/radio.c +++ b/examples/platforms/efr32mg21/radio.c @@ -663,7 +663,7 @@ static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle sReceiveError = OT_ERROR_NONE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -810,7 +810,7 @@ void efr32RadioProcess(otInstance *aInstance) sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError); diff --git a/examples/platforms/gp712/diag.c b/examples/platforms/gp712/diag.c index a3fa9ae1f..75132c15c 100644 --- a/examples/platforms/gp712/diag.c +++ b/examples/platforms/gp712/diag.c @@ -35,7 +35,7 @@ #include #include -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -84,4 +84,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/kw41z/alarm.c b/examples/platforms/kw41z/alarm.c index ef0f63774..91d349ea2 100644 --- a/examples/platforms/kw41z/alarm.c +++ b/examples/platforms/kw41z/alarm.c @@ -63,7 +63,7 @@ void kw41zAlarmProcess(otInstance *aInstance) if ((sAlarmTime != 0) && (sTime >= sAlarmTime)) { sAlarmTime = 0; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/kw41z/diag.c b/examples/platforms/kw41z/diag.c index a5d6e3824..f0fcc8774 100644 --- a/examples/platforms/kw41z/diag.c +++ b/examples/platforms/kw41z/diag.c @@ -41,7 +41,7 @@ #include #include -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -90,4 +90,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/kw41z/radio.c b/examples/platforms/kw41z/radio.c index 6d539ef8f..a91d4a8a8 100644 --- a/examples/platforms/kw41z/radio.c +++ b/examples/platforms/kw41z/radio.c @@ -994,7 +994,7 @@ void kw41zRadioProcess(otInstance *aInstance) // See https://github.com/openthread/openthread/pull/3785 sRxFrame.mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/nrf52811/alarm.c b/examples/platforms/nrf52811/alarm.c index 0920f5d4a..cef1c1d01 100644 --- a/examples/platforms/nrf52811/alarm.c +++ b/examples/platforms/nrf52811/alarm.c @@ -496,7 +496,7 @@ void nrf5AlarmProcess(otInstance *aInstance) { sTimerData[kMsTimer].mFireAlarm = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/nrf52811/radio.c b/examples/platforms/nrf52811/radio.c index 01c47b70f..7be966745 100644 --- a/examples/platforms/nrf52811/radio.c +++ b/examples/platforms/nrf52811/radio.c @@ -564,7 +564,7 @@ void nrf5RadioProcess(otInstance *aInstance) { if (sReceivedFrames[i].mPsdu != NULL) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -586,7 +586,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventFrameTransmitted); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -610,7 +610,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventChannelAccessFailure); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -627,7 +627,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventInvalidOrNoAck); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -644,7 +644,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventReceiveFailed); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/nrf52840/alarm.c b/examples/platforms/nrf52840/alarm.c index 37d41cf66..8fdf50f83 100644 --- a/examples/platforms/nrf52840/alarm.c +++ b/examples/platforms/nrf52840/alarm.c @@ -496,7 +496,7 @@ void nrf5AlarmProcess(otInstance *aInstance) { sTimerData[kMsTimer].mFireAlarm = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 0f3d5f0f2..9dd39ff9f 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -564,7 +564,7 @@ void nrf5RadioProcess(otInstance *aInstance) { if (sReceivedFrames[i].mPsdu != NULL) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -586,7 +586,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventFrameTransmitted); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -610,7 +610,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventChannelAccessFailure); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -627,7 +627,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventInvalidOrNoAck); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -644,7 +644,7 @@ void nrf5RadioProcess(otInstance *aInstance) { resetPendingEvent(kPendingEventReceiveFailed); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/posix/alarm.c b/examples/platforms/posix/alarm.c index 0a5f2a349..db613238e 100644 --- a/examples/platforms/posix/alarm.c +++ b/examples/platforms/posix/alarm.c @@ -269,7 +269,7 @@ void platformAlarmProcess(otInstance *aInstance) { sIsMsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/posix/diag.c b/examples/platforms/posix/diag.c index 6e305dbc4..a93c0176c 100644 --- a/examples/platforms/posix/diag.c +++ b/examples/platforms/posix/diag.c @@ -37,7 +37,7 @@ #include #include -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/posix/radio.c b/examples/platforms/posix/radio.c index 11e63e8db..d74e0976d 100644 --- a/examples/platforms/posix/radio.c +++ b/examples/platforms/posix/radio.c @@ -661,7 +661,7 @@ static void radioReceive(otInstance *aInstance) sState = OT_RADIO_STATE_RECEIVE; sTxWait = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -739,7 +739,7 @@ void radioSendMessage(otInstance *aInstance) { sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -940,7 +940,7 @@ exit: if (error != OT_ERROR_ABORT) { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, error == OT_ERROR_NONE ? &sReceiveFrame : NULL, error); diff --git a/examples/platforms/posix/sim/alarm-sim.c b/examples/platforms/posix/sim/alarm-sim.c index cbe179afa..dc4780dc9 100644 --- a/examples/platforms/posix/sim/alarm-sim.c +++ b/examples/platforms/posix/sim/alarm-sim.c @@ -150,7 +150,7 @@ void platformAlarmProcess(otInstance *aInstance) { sIsMsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/samr21/alarm.c b/examples/platforms/samr21/alarm.c index c200573cd..71856e26b 100644 --- a/examples/platforms/samr21/alarm.c +++ b/examples/platforms/samr21/alarm.c @@ -77,7 +77,7 @@ void samr21AlarmProcess(otInstance *aInstance) { sDeltaTime = 0; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/examples/platforms/samr21/diag.c b/examples/platforms/samr21/diag.c index 9b0acd3ec..67f9806ee 100644 --- a/examples/platforms/samr21/diag.c +++ b/examples/platforms/samr21/diag.c @@ -37,7 +37,7 @@ #include #include -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * Diagnostics mode variables. @@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/examples/platforms/samr21/radio.c b/examples/platforms/samr21/radio.c index dc09f27f6..a035fb254 100644 --- a/examples/platforms/samr21/radio.c +++ b/examples/platforms/samr21/radio.c @@ -232,7 +232,7 @@ static void handleRx(void) // See https://github.com/openthread/openthread/pull/3785 sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -300,7 +300,7 @@ static void handleTx(void) sState = OT_RADIO_STATE_RECEIVE; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(sInstance, &sTransmitFrame, otStatus); diff --git a/src/cli/README.md b/src/cli/README.md index bf67225b7..03f4d8c4f 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -1500,7 +1500,7 @@ Done ### diag -Factory Diagnostics module is enabled only when building OpenThread with --enable-diag option. +Factory Diagnostics module is enabled only when building OpenThread with `OPENTHREAD_CONFIG_DIAG_ENABLE=1` option. Go [diagnostics module][1] for more information. ### service diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 85b4fde8d..26d3d57b5 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -117,7 +117,7 @@ const struct Command Interpreter::sCommands[] = { #if OPENTHREAD_FTD {"delaytimermin", &Interpreter::ProcessDelayTimerMin}, #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE {"diag", &Interpreter::ProcessDiag}, #endif {"discover", &Interpreter::ProcessDiscover}, @@ -3406,7 +3406,7 @@ exit: #endif // OPENTHREAD_ENABLE_MAC_FILTER -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE void Interpreter::ProcessDiag(int argc, char *argv[]) { char output[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE]; @@ -3434,7 +3434,7 @@ void Interpreter::ProcessLine(char *aBuf, uint16_t aBufLength, Server &aServer) cmd = argv[0]; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE VerifyOrExit( (!otDiagIsEnabled(mInstance) || (strcmp(cmd, "diag") == 0)), mServer->OutputFormat("under diagnostics mode, execute 'diag stop' before running any other commands.\r\n")); diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index f1a1e4b2c..bfaa9334e 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -218,9 +218,9 @@ private: #if OPENTHREAD_FTD void ProcessDelayTimerMin(int argc, char *argv[]); #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE void ProcessDiag(int argc, char *argv[]); -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE void ProcessDiscover(int argc, char *argv[]); #if OPENTHREAD_ENABLE_DNS_CLIENT void ProcessDns(int argc, char *argv[]); diff --git a/src/cli/cli_uart.cpp b/src/cli/cli_uart.cpp index 097561a6e..1366aa193 100644 --- a/src/cli/cli_uart.cpp +++ b/src/cli/cli_uart.cpp @@ -86,7 +86,7 @@ #endif // OT_CLI_UART_LOCK_HDR_FILE -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE, "diag output buffer should be smaller than CLI UART tx buffer"); OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE, diff --git a/src/core/Makefile.am b/src/core/Makefile.am index a0eee88e4..b37afaa4b 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -327,6 +327,7 @@ HEADERS_COMMON = \ config/commissioner.h \ config/dhcp6_client.h \ config/dhcp6_server.h \ + config/diag.h \ config/openthread-core-config-check.h \ config/openthread-core-default-config.h \ crypto/aes_ccm.hpp \ diff --git a/src/core/api/diags_api.cpp b/src/core/api/diags_api.cpp index 280762eca..4b3501282 100644 --- a/src/core/api/diags_api.cpp +++ b/src/core/api/diags_api.cpp @@ -40,7 +40,7 @@ using namespace ot; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE void otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen) { @@ -63,4 +63,4 @@ bool otDiagIsEnabled(otInstance *aInstance) return instance.Get().IsEnabled(); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE diff --git a/src/core/common/instance.cpp b/src/core/common/instance.cpp index b7bc35be5..8a2c900fc 100644 --- a/src/core/common/instance.cpp +++ b/src/core/common/instance.cpp @@ -96,7 +96,7 @@ Instance::Instance(void) #if OPENTHREAD_ENABLE_VENDOR_EXTENSION , mExtension(Extension::ExtensionBase::Init(*this)) #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE , mDiags(*this) #endif , mIsInitialized(false) diff --git a/src/core/common/instance.hpp b/src/core/common/instance.hpp index 0ad13a9ec..5b1979ed0 100644 --- a/src/core/common/instance.hpp +++ b/src/core/common/instance.hpp @@ -370,7 +370,7 @@ private: #if OPENTHREAD_ENABLE_VENDOR_EXTENSION Extension::ExtensionBase &mExtension; #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE FactoryDiags::Diags mDiags; #endif bool mIsInitialized; @@ -717,7 +717,7 @@ template <> inline Extension::ExtensionBase &Instance::Get(void) } #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE template <> inline FactoryDiags::Diags &Instance::Get(void) { return mDiags; diff --git a/src/core/config/diag.h b/src/core/config/diag.h new file mode 100644 index 000000000..a38d547d2 --- /dev/null +++ b/src/core/config/diag.h @@ -0,0 +1,78 @@ +/* + * 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 DIAG service. + * + */ + +#ifndef CONFIG_DIAG_H_ +#define CONFIG_DIAG_H_ + +/** + * @def OPENTHREAD_CONFIG_DIAG_ENABLE + * + * Define to 1 to enable Factory Diagnostics support. + * + */ +#ifndef OPENTHREAD_CONFIG_DIAG_ENABLE +#define OPENTHREAD_CONFIG_DIAG_ENABLE 0 +#endif + +/** + * @def OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE + * + * Define OpenThread diagnostic mode output buffer size in bytes + * + */ +#ifndef OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE +#define OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE 256 +#endif + +/** + * @def OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX + * + * Define OpenThread diagnostic mode max command line arguments. + * + */ +#ifndef OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX +#define OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX 32 +#endif + +/** + * @def OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE + * + * Define OpenThread diagnostic mode command line buffer size in bytes. + * + */ +#ifndef OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE +#define OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE 256 +#endif + +#endif // CONFIG_DIAG_H_ diff --git a/src/core/config/openthread-core-default-config.h b/src/core/config/openthread-core-default-config.h index df5a4760d..92b858451 100644 --- a/src/core/config/openthread-core-default-config.h +++ b/src/core/config/openthread-core-default-config.h @@ -1389,36 +1389,6 @@ #define OPENTHREAD_CONFIG_DISABLE_CSMA_CA_ON_LAST_ATTEMPT 0 #endif -/** - * @def OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE - * - * Define OpenThread diagnostic mode output buffer size in bytes - * - */ -#ifndef OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE -#define OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE 256 -#endif - -/** - * @def OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX - * - * Define OpenThread diagnostic mode max command line arguments. - * - */ -#ifndef OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX -#define OPENTHREAD_CONFIG_DIAG_CMD_LINE_ARGS_MAX 32 -#endif - -/** - * @def OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE - * - * Define OpenThread diagnostic mode command line buffer size in bytes. - * - */ -#ifndef OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE -#define OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE 256 -#endif - /** * @def OPENTHREAD_CONFIG_ENABLE_TIME_SYNC * diff --git a/src/core/diags/factory_diags.cpp b/src/core/diags/factory_diags.cpp index b7e8edcc5..23342683a 100644 --- a/src/core/diags/factory_diags.cpp +++ b/src/core/diags/factory_diags.cpp @@ -48,7 +48,7 @@ namespace ot { namespace FactoryDiags { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE #if OPENTHREAD_RADIO const struct Diags::Command Diags::sCommands[] = { @@ -557,7 +557,7 @@ bool Diags::IsEnabled(void) return otPlatDiagModeGet(); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE } // namespace FactoryDiags } // namespace ot diff --git a/src/core/diags/factory_diags.hpp b/src/core/diags/factory_diags.hpp index 6fe0b9d48..833724a02 100644 --- a/src/core/diags/factory_diags.hpp +++ b/src/core/diags/factory_diags.hpp @@ -45,7 +45,7 @@ namespace ot { namespace FactoryDiags { -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE class Diags { @@ -162,7 +162,7 @@ private: bool mRepeatActive; }; -#endif // #if OPENTHREAD_ENABLE_DIAG +#endif // #if OPENTHREAD_CONFIG_DIAG_ENABLE } // namespace FactoryDiags } // namespace ot diff --git a/src/core/openthread-core-config.h b/src/core/openthread-core-config.h index 2301d79a0..eee0c85ca 100644 --- a/src/core/openthread-core-config.h +++ b/src/core/openthread-core-config.h @@ -53,6 +53,7 @@ #include "config/commissioner.h" #include "config/dhcp6_client.h" #include "config/dhcp6_server.h" +#include "config/diag.h" #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \ OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_ENABLE_JOINER diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 6127ffa4c..9f4cc9e0a 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -917,7 +917,7 @@ bool NcpBase::HandlePropertySetForSpecialProperties(uint8_t aHeader, spinel_prop case SPINEL_PROP_HOST_POWER_STATE: ExitNow(aError = HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(aHeader)); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE case SPINEL_PROP_NEST_STREAM_MFG: ExitNow(aError = HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(aHeader)); #endif @@ -1273,7 +1273,7 @@ exit: // MARK: Individual Property Getters and Setters // ---------------------------------------------------------------------------- -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE otError NcpBase::HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(uint8_t aHeader) { @@ -1297,7 +1297,7 @@ exit: return error; } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE template <> otError NcpBase::HandlePropertyGet(void) { diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index 258fbd6c4..0bea320d0 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -405,7 +405,7 @@ protected: otError HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(uint8_t aHeader); -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE - kSpinelCmdHeaderSize - kSpinelPropIdSize, "diag output buffer should be smaller than NCP UART tx buffer"); diff --git a/src/ncp/ncp_spi.cpp b/src/ncp/ncp_spi.cpp index 931f7a9fa..202b1ad3f 100644 --- a/src/ncp/ncp_spi.cpp +++ b/src/ncp/ncp_spi.cpp @@ -46,7 +46,7 @@ #if OPENTHREAD_ENABLE_NCP_SPI -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE - ot::Ncp::NcpBase::kSpinelCmdHeaderSize - ot::Ncp::NcpBase::kSpinelPropIdSize - ot::Ncp::SpiFrame::kHeaderSize, diff --git a/src/ncp/ncp_uart.cpp b/src/ncp/ncp_uart.cpp index 8eb16ae50..e707c042d 100644 --- a/src/ncp/ncp_uart.cpp +++ b/src/ncp/ncp_uart.cpp @@ -49,7 +49,7 @@ #if OPENTHREAD_ENABLE_NCP_UART -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE - ot::Ncp::NcpBase::kSpinelCmdHeaderSize - ot::Ncp::NcpBase::kSpinelPropIdSize, diff --git a/src/posix/platform/alarm.c b/src/posix/platform/alarm.c index 16d9e131c..22a400ddb 100644 --- a/src/posix/platform/alarm.c +++ b/src/posix/platform/alarm.c @@ -177,7 +177,7 @@ void platformAlarmProcess(otInstance *aInstance) { sIsMsRunning = false; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index b11fe2460..97cc4d2b5 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -175,7 +175,7 @@ RadioSpinel::RadioSpinel(void) , mIsPromiscuous(false) , mIsReady(false) , mSupportsLogStream(false) -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE , mDiagMode(false) , mDiagOutput(NULL) , mDiagOutputMaxLen(0) @@ -466,7 +466,7 @@ void RadioSpinel::HandleWaitingResponse(uint32_t aCommand, VerifyOrExit(unpacked > 0, mError = OT_ERROR_PARSE); mError = SpinelStatusToOtError(status); } -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE else if (aKey == SPINEL_PROP_NEST_STREAM_MFG) { spinel_ssize_t unpacked; @@ -685,7 +685,7 @@ void RadioSpinel::RadioReceive(void) } } -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(mInstance, &mRxRadioFrame, OT_ERROR_NONE); @@ -762,7 +762,7 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet) mState = kStateReceive; mTxRadioEndUs = UINT64_MAX; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(mInstance, mTransmitFrame, mTxError); @@ -1114,7 +1114,7 @@ void RadioSpinel::RadioTransmit(void) { mState = kStateReceive; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { @@ -1377,7 +1377,7 @@ exit: return error; } -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE otError RadioSpinel::PlatDiagProcess(const char *aString, char *aOutput, size_t aOutputMaxLen) { otError error; @@ -1650,7 +1650,7 @@ void ot::PosixApp::RadioSpinel::Process(const Event &aEvent) { mState = kStateReceive; -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(mInstance, mTransmitFrame, mTxError); @@ -1691,7 +1691,7 @@ void otSimRadioSpinelProcess(otInstance *aInstance, const struct Event *aEvent) } #endif // OPENTHREAD_POSIX_VIRTUAL_TIME -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE void otPlatDiagProcess(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen) { // deliver the platform specific diags commands to radio only ncp. @@ -1755,7 +1755,7 @@ void otPlatDiagAlarmCallback(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); } -#endif // OPENTHREAD_ENABLE_DIAG +#endif // OPENTHREAD_CONFIG_DIAG_ENABLE uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance) { diff --git a/src/posix/platform/radio_spinel.hpp b/src/posix/platform/radio_spinel.hpp index 567547858..cf344f371 100644 --- a/src/posix/platform/radio_spinel.hpp +++ b/src/posix/platform/radio_spinel.hpp @@ -408,7 +408,7 @@ public: void Update(struct timeval &aTimeout); #endif -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE /** * This method enables/disables the factory diagnostics mode. * @@ -618,7 +618,7 @@ private: bool mIsReady : 1; ///< NCP ready. bool mSupportsLogStream : 1; ///< RCP supports `LOG_STREAM` property with OpenThread log meta-data format. -#if OPENTHREAD_ENABLE_DIAG +#if OPENTHREAD_CONFIG_DIAG_ENABLE bool mDiagMode; char * mDiagOutput; size_t mDiagOutputMaxLen; diff --git a/tests/toranj/build.sh b/tests/toranj/build.sh index d130cd9f4..714b9064f 100755 --- a/tests/toranj/build.sh +++ b/tests/toranj/build.sh @@ -78,7 +78,6 @@ configure_options=" \ --disable-docs \ --disable-tests \ --enable-coverage=$coverage \ - --enable-diag \ --enable-ftd \ --enable-jam-detection \ --enable-joiner \ diff --git a/tests/toranj/openthread-core-toranj-config.h b/tests/toranj/openthread-core-toranj-config.h index eb740c11a..967c1e16f 100644 --- a/tests/toranj/openthread-core-toranj-config.h +++ b/tests/toranj/openthread-core-toranj-config.h @@ -64,6 +64,14 @@ */ #define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 1 +/** + * @def OPENTHREAD_CONFIG_DIAG_ENABLE + * + * Define to 1 to enable Factory Diagnostics support. + * + */ +#define OPENTHREAD_CONFIG_DIAG_ENABLE 1 + /** * @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS *