From 287ff433fb20279d444ffdb1b5a49678d6c847f6 Mon Sep 17 00:00:00 2001 From: Li Cao Date: Wed, 11 Jan 2023 07:10:54 +0800 Subject: [PATCH] [posix] rename and move the configuration of host-rcp time sync interval (#8630) This commit renames the configuration `RCP_TIME_OFFSET_CHECK_INTERVAL` to `OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL` and moves it to posix configuration file because this configuration may need to be configured on different platforms. --- src/lib/spinel/radio_spinel_impl.hpp | 9 +-------- src/posix/platform/openthread-posix-config.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib/spinel/radio_spinel_impl.hpp b/src/lib/spinel/radio_spinel_impl.hpp index 179bdbd60..22793081d 100644 --- a/src/lib/spinel/radio_spinel_impl.hpp +++ b/src/lib/spinel/radio_spinel_impl.hpp @@ -64,18 +64,11 @@ #ifndef US_PER_S #define US_PER_S (MS_PER_S * US_PER_MS) #endif -#ifndef NS_PER_US -#define NS_PER_US 1000 -#endif #ifndef TX_WAIT_US #define TX_WAIT_US (5 * US_PER_S) #endif -#ifndef RCP_TIME_OFFSET_CHECK_INTERVAL -#define RCP_TIME_OFFSET_CHECK_INTERVAL (60 * US_PER_S) -#endif - using ot::Spinel::Decoder; namespace ot { @@ -2234,7 +2227,7 @@ void RadioSpinel::CalcRcpTimeOffset(void) mRadioTimeOffset = (remoteTimestamp - ((localRxTimestamp / 2) + (localTxTimestamp / 2))); mIsTimeSynced = true; - mRadioTimeRecalcStart = localRxTimestamp + RCP_TIME_OFFSET_CHECK_INTERVAL; + mRadioTimeRecalcStart = localRxTimestamp + OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL; exit: LogIfFail("Error calculating RCP time offset: %s", error); diff --git a/src/posix/platform/openthread-posix-config.h b/src/posix/platform/openthread-posix-config.h index ce5ed3c27..170f24f85 100644 --- a/src/posix/platform/openthread-posix-config.h +++ b/src/posix/platform/openthread-posix-config.h @@ -362,4 +362,15 @@ #define OPENTHREAD_POSIX_CONFIG_PRODUCT_CONFIG_FILE "src/posix/platform/openthread.conf.example" #endif +/** + * @def OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL + * + * This setting configures the interval (in units of microseconds) for host-rcp + * time sync. The host will recalculate the time offset between host and RCP + * every interval. + * + */ +#ifndef OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL +#define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000) +#endif #endif // OPENTHREAD_PLATFORM_CONFIG_H_