From 846fffed61f98a47498f7533a6ac63c99f82407f Mon Sep 17 00:00:00 2001 From: suveshpratapa <66088488+suveshpratapa@users.noreply.github.com> Date: Wed, 24 Mar 2021 12:11:17 -0400 Subject: [PATCH] [efr32] bug fixes, UART API changes (#6329) - OPENTHREAD_CONFIG_NCP_UART_ENABLE is now OPENTHREAD_CONFIG_NCP_HDLC_ENABLE - Pull in cli_uart.cpp UART API interface for sleepy-demo apps. - Fix some erroneous ifdefs that affect 1.2 SoC builds and 1.1 builds. - Add OT_RADIO_CAPS_SLEEP_TO_TX to radio capabilities (fixes #5819). --- .../sleepy-demo/sleepy-demo-ftd/CMakeLists.txt | 1 + .../efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am | 3 +++ .../efr32/sleepy-demo/sleepy-demo-ftd/main.c | 10 +++++++++- .../sleepy-demo/sleepy-demo-mtd/CMakeLists.txt | 1 + .../efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am | 3 +++ .../efr32/sleepy-demo/sleepy-demo-mtd/main.c | 10 +++++++++- examples/platforms/efr32/src/radio.c | 13 ++++++++++--- 7 files changed, 36 insertions(+), 5 deletions(-) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt index 521f2e6f2..f8aaf63c9 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt @@ -27,6 +27,7 @@ # add_executable(sleepy-demo-ftd + ${PROJECT_SOURCE_DIR}/examples/apps/cli/cli_uart.cpp main.c ) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am index eff74bf28..f7b548d0d 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am @@ -38,11 +38,13 @@ bin_PROGRAMS = CPPFLAGS_COMMON += \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ -Wno-sign-compare \ + -I$(top_srcdir)/examples/apps/cli \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \ -I$(top_srcdir)/examples/platforms/efr32/src \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/silabs/rail_config \ $(SILABS_GSDK_CPPFLAGS) \ @@ -60,6 +62,7 @@ LIBTOOLFLAGS_COMMON += $(NULL) SOURCES_COMMON += \ + ../../../../apps/cli/cli_uart.cpp \ main.c \ $(NULL) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c index 2944a83ef..19560cb03 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/main.c @@ -71,6 +71,14 @@ void initUdp(void); void applicationTick(void); void sFtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); +/** + * This function initializes the CLI app. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +extern void otAppCliInit(otInstance *aInstance); + // Variables static otInstance * instance; static otUdpSocket sFtdSocket; @@ -93,7 +101,7 @@ int main(int argc, char *argv[]) instance = otInstanceInitSingle(); assert(instance); - otCliUartInit(instance); + otAppCliInit(instance); otCliOutputFormat("sleepy-demo-ftd started\r\n"); setNetworkConfiguration(instance); diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt index 8408e6f17..6eec209d2 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt @@ -27,6 +27,7 @@ # add_executable(sleepy-demo-mtd + ${PROJECT_SOURCE_DIR}/examples/apps/cli/cli_uart.cpp main.c ) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am index 64e9bb882..9d855bcd3 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am @@ -38,11 +38,13 @@ bin_PROGRAMS = CPPFLAGS_COMMON += \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ -Wno-sign-compare \ + -I$(top_srcdir)/examples/apps/cli \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE) \ -I$(top_srcdir)/examples/platforms/efr32/src \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/silabs/rail_config \ $(SILABS_GSDK_CPPFLAGS) \ @@ -60,6 +62,7 @@ LIBTOOLFLAGS_COMMON += $(NULL) SOURCES_COMMON += \ + ../../../../apps/cli/cli_uart.cpp \ main.c \ $(NULL) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c index 39dd23371..23318f719 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/main.c @@ -76,6 +76,14 @@ void initUdp(void); void applicationTick(void); void mtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); +/** + * This function initializes the CLI app. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +extern void otAppCliInit(otInstance *aInstance); + // Variables static otInstance * instance; static otUdpSocket sMtdSocket; @@ -97,7 +105,7 @@ int main(int argc, char *argv[]) instance = otInstanceInitSingle(); assert(instance); - otCliUartInit(instance); + otAppCliInit(instance); otLinkSetPollPeriod(instance, SLEEPY_POLL_PERIOD_MS); setNetworkConfiguration(instance); diff --git a/examples/platforms/efr32/src/radio.c b/examples/platforms/efr32/src/radio.c index b1beeb44e..a03079b12 100644 --- a/examples/platforms/efr32/src/radio.c +++ b/examples/platforms/efr32/src/radio.c @@ -944,6 +944,7 @@ void txCurrentPacket(void) frameLength = (uint8_t)sTxFrame->mLength; +#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE // Update IE data in the 802.15.4 header with the newest CSL period / phase if (sCslPeriod > 0) @@ -952,7 +953,9 @@ void txCurrentPacket(void) } #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +#if OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE bool processSecurity = false; +#endif #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE // Seek the time sync offset and update the rendezvous time @@ -970,11 +973,13 @@ void txCurrentPacket(void) *(++timeIe) = (uint8_t)(time & 0xff); } +#if OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE processSecurity = true; +#endif } #endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE -#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 +#if OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE if (otMacFrameIsSecurityEnabled(sTxFrame) && otMacFrameIsKeyIdMode1(sTxFrame) && !sTxFrame->mInfo.mTxInfo.mIsSecurityProcessed) { @@ -988,12 +993,13 @@ void txCurrentPacket(void) processSecurity = true; } -#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 if (processSecurity) { otMacFrameProcessTransmitAesCcm(sTxFrame, &sExtAddress); } +#endif // OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE +#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 RAIL_WriteTxFifo(gRailHandle, &frameLength, sizeof frameLength, true); RAIL_WriteTxFifo(gRailHandle, sTxFrame->mPsdu, frameLength - 2, false); @@ -1122,7 +1128,8 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); - otRadioCaps capabilities = (OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_ENERGY_SCAN); + otRadioCaps capabilities = (OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_ENERGY_SCAN | + OT_RADIO_CAPS_SLEEP_TO_TX); #if OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE capabilities |= OT_RADIO_CAPS_TRANSMIT_SEC;