[time-sync] correct the time sync base to radio time (#10825)

The network time offset is computed based on the coprocessor time
instead of the host time.
This commit is contained in:
Yakun Xu
2024-10-15 09:17:11 -07:00
committed by GitHub
parent 328e247341
commit 944a25a5be
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -528,7 +528,8 @@ public:
Error ResetCsl(void);
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE || \
OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
/**
* Get the current radio time in microseconds referenced to a continuous monotonic local radio clock (64 bits
* width).
@@ -940,7 +941,8 @@ inline Error Radio::EnableCsl(uint32_t aCslPeriod, otShortAddress aShortAddr, co
inline Error Radio::ResetCsl(void) { return otPlatRadioResetCsl(GetInstancePtr()); }
#endif
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE || \
OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
inline uint64_t Radio::GetNow(void) { return otPlatRadioGetNow(GetInstancePtr()); }
inline uint8_t Radio::GetCslAccuracy(void) { return otPlatRadioGetCslAccuracy(GetInstancePtr()); }
@@ -1050,7 +1052,8 @@ inline Error Radio::EnableCsl(uint32_t, otShortAddress aShortAddr, const otExtAd
inline Error Radio::ResetCsl(void) { return kErrorNotImplemented; }
#endif
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE || \
OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
inline uint64_t Radio::GetNow(void) { return NumericLimits<uint64_t>::kMax; }
inline uint8_t Radio::GetCslAccuracy(void) { return NumericLimits<uint8_t>::kMax; }
+1 -1
View File
@@ -64,7 +64,7 @@ TimeSync::TimeSync(Instance &aInstance)
TimeSync::Status TimeSync::GetTime(uint64_t &aNetworkTime) const
{
aNetworkTime = static_cast<uint64_t>(static_cast<int64_t>(otPlatTimeGet()) + mNetworkTimeOffset);
aNetworkTime = static_cast<uint64_t>(static_cast<int64_t>(Get<Radio>().GetNow()) + mNetworkTimeOffset);
return mCurrentStatus;
}