From c33c8a27c4c6b7aa925280baadf200694f6499a4 Mon Sep 17 00:00:00 2001 From: Michael Wei Date: Sun, 23 Jun 2024 17:12:52 -0700 Subject: [PATCH 1/2] fix(openthread): fix RCP build to pass time sync and CSL options Closes https://github.com/espressif/esp-idf/pull/14060 --- components/openthread/CMakeLists.txt | 2 + .../openthread-core-esp32x-radio-config.h | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index a457955602..06e0b5e19d 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -84,6 +84,7 @@ if(CONFIG_OPENTHREAD_ENABLED) "openthread/src/core/api/nat64_api.cpp" "openthread/src/core/api/netdata_api.cpp" "openthread/src/core/api/netdiag_api.cpp" + "openthread/src/core/api/network_time_api.cpp" "openthread/src/core/api/random_crypto_api.cpp" "openthread/src/core/api/tcp_api.cpp" "openthread/src/core/api/udp_api.cpp" @@ -123,6 +124,7 @@ if(CONFIG_OPENTHREAD_ENABLED) "openthread/src/core/thread/network_diagnostic.cpp" "openthread/src/core/thread/panid_query_server.cpp" "openthread/src/core/thread/thread_netif.cpp" + "openthread/src/core/thread/time_sync_service.cpp" "openthread/src/core/thread/tmf.cpp" "openthread/src/core/thread/topology.cpp" "openthread/src/core/utils/child_supervision.cpp") diff --git a/components/openthread/private_include/openthread-core-esp32x-radio-config.h b/components/openthread/private_include/openthread-core-esp32x-radio-config.h index 8a954c86d3..9512d26eee 100644 --- a/components/openthread/private_include/openthread-core-esp32x-radio-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-radio-config.h @@ -242,3 +242,71 @@ #ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT #define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT #endif + +/** + * @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE + * + * Define as 1 to enable the time synchronization service feature. + * + */ +#if CONFIG_OPENTHREAD_TIME_SYNC +#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 1 +#endif + + +#if CONFIG_OPENTHREAD_CSL_ENABLE + +/** + * @def OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE + * + * Define as 1 to support Thread 1.2 CSL feature. + * + */ +#ifndef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 +#endif + +/** + * @def OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE + * + * Define as 1 to enable support Thread 1.2 CSL debug. + * + */ +#ifndef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE +#define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE CONFIG_OPENTHREAD_CSL_DEBUG_ENABLE +#endif + +#endif // CONFIG_OPENTHREAD_CSL_ENABLE + +/** + * @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + * + * Define as 1 to set the ahead time for CSL transmit timing. + * + */ +#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US +#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 20000 +#endif + +#if CONFIG_OPENTHREAD_LINK_METRICS + +/** + * @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE + * + * Define as 1 to support Thread 1.2 Link Metrics Subject feature. + * + */ +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 +#endif + +/** + * @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE + * + * Define as 1 to support Thread 1.2 Link Metrics feature. + * + */ +#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1 +#endif +#endif //CONFIG_OPENTHREAD_LINK_METRICS From 4025f1fc61acbb6eafaeb51072dae5d3b4f3d066 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Tue, 23 Jul 2024 19:22:13 +0800 Subject: [PATCH 2/2] feat(openthread): support time sync feature on border router --- .../openthread-core-esp32x-radio-config.h | 58 ------------------- .../src/port/esp_openthread_radio_spinel.cpp | 6 ++ 2 files changed, 6 insertions(+), 58 deletions(-) diff --git a/components/openthread/private_include/openthread-core-esp32x-radio-config.h b/components/openthread/private_include/openthread-core-esp32x-radio-config.h index 9512d26eee..c06dcf526a 100644 --- a/components/openthread/private_include/openthread-core-esp32x-radio-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-radio-config.h @@ -252,61 +252,3 @@ #if CONFIG_OPENTHREAD_TIME_SYNC #define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 1 #endif - - -#if CONFIG_OPENTHREAD_CSL_ENABLE - -/** - * @def OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE - * - * Define as 1 to support Thread 1.2 CSL feature. - * - */ -#ifndef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE -#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 -#endif - -/** - * @def OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE - * - * Define as 1 to enable support Thread 1.2 CSL debug. - * - */ -#ifndef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE -#define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE CONFIG_OPENTHREAD_CSL_DEBUG_ENABLE -#endif - -#endif // CONFIG_OPENTHREAD_CSL_ENABLE - -/** - * @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US - * - * Define as 1 to set the ahead time for CSL transmit timing. - * - */ -#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US -#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 20000 -#endif - -#if CONFIG_OPENTHREAD_LINK_METRICS - -/** - * @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE - * - * Define as 1 to support Thread 1.2 Link Metrics Subject feature. - * - */ -#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE -#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 -#endif - -/** - * @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE - * - * Define as 1 to support Thread 1.2 Link Metrics feature. - * - */ -#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE -#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1 -#endif -#endif //CONFIG_OPENTHREAD_LINK_METRICS diff --git a/components/openthread/src/port/esp_openthread_radio_spinel.cpp b/components/openthread/src/port/esp_openthread_radio_spinel.cpp index 34eccebc8a..3d566b05e9 100644 --- a/components/openthread/src/port/esp_openthread_radio_spinel.cpp +++ b/components/openthread/src/port/esp_openthread_radio_spinel.cpp @@ -23,6 +23,7 @@ #include "lib/spinel/spinel.h" #include "openthread/platform/diag.h" #include "openthread/platform/radio.h" +#include "openthread/platform/time.h" #include "platform/exit_code.h" #include "spinel_driver.hpp" @@ -443,3 +444,8 @@ void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable) s_radio.SetRxOnWhenIdle(aEnable); } #endif + +uint16_t otPlatTimeGetXtalAccuracy(void) +{ + return CONFIG_OPENTHREAD_XTAL_ACCURACY; +}