diff --git a/.travis/script.sh b/.travis/script.sh index 897fca2be..404f7391b 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -458,6 +458,8 @@ python --version || die --disable-tests || die make -j 8 || die + export CPPFLAGS=-DOPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1 + git checkout -- . || die git clean -xfd || die ./bootstrap || die diff --git a/examples/platforms/posix/radio.c b/examples/platforms/posix/radio.c index 5f7494b02..2308f10d0 100644 --- a/examples/platforms/posix/radio.c +++ b/examples/platforms/posix/radio.c @@ -610,7 +610,7 @@ void radioSendMessage(otInstance *aInstance) if (sTransmitFrame.mIeInfo->mTimeIeOffset != 0) { uint8_t *timeIe = sTransmitFrame.mPsdu + sTransmitFrame.mIeInfo->mTimeIeOffset; - uint64_t time = otPlatTimeGet() + sTransmitFrame.mIeInfo->mNetworkTimeOffset; + uint64_t time = (uint64_t)((int64_t)otPlatTimeGet() + sTransmitFrame.mIeInfo->mNetworkTimeOffset); *timeIe = sTransmitFrame.mIeInfo->mTimeSyncSeq; diff --git a/include/openthread/network_time.h b/include/openthread/network_time.h index 83adaa2f5..2990c2c98 100644 --- a/include/openthread/network_time.h +++ b/include/openthread/network_time.h @@ -36,6 +36,7 @@ #define OPENTHREAD_NETWORK_TIME_H_ #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 99a31fe10..ffe8c45c6 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2389,7 +2389,7 @@ uint8_t Mac::GetTimeIeOffset(Frame &aFrame) VerifyOrExit(cur != NULL); cur += sizeof(VendorIeHeader); - offset = cur - base; + offset = static_cast(cur - base); exit: return offset; diff --git a/src/core/mac/mac_frame.cpp b/src/core/mac/mac_frame.cpp index 74635fbd1..82b11e785 100644 --- a/src/core/mac/mac_frame.cpp +++ b/src/core/mac/mac_frame.cpp @@ -1000,7 +1000,7 @@ otError Frame::AppendHeaderIe(HeaderIe *aIeList, uint8_t aIeCount) cur += aIeList[i].GetLength(); } - SetPsduLength(GetPsduLength() + cur - base); + SetPsduLength(GetPsduLength() + static_cast(cur - base)); exit: return error; diff --git a/src/core/thread/time_sync_service.cpp b/src/core/thread/time_sync_service.cpp index d9c46b3da..62faf43f6 100644 --- a/src/core/thread/time_sync_service.cpp +++ b/src/core/thread/time_sync_service.cpp @@ -52,7 +52,9 @@ TimeSync::TimeSync(Instance &aInstance) , mTimeSyncSeq(OT_TIME_SYNC_INVALID_SEQ) , mTimeSyncPeriod(OPENTHREAD_CONFIG_TIME_SYNC_PERIOD) , mXtalThreshold(OPENTHREAD_CONFIG_TIME_SYNC_XTAL_THRESHOLD) +#if OPENTHREAD_FTD , mLastTimeSyncSent(0) +#endif , mLastTimeSyncReceived(0) , mNetworkTimeOffset(0) { @@ -83,7 +85,7 @@ otNetworkTimeStatus TimeSync::GetTime(uint64_t &aNetworkTime) const break; } - aNetworkTime = otPlatTimeGet() + mNetworkTimeOffset; + aNetworkTime = static_cast(static_cast(otPlatTimeGet()) + mNetworkTimeOffset); return networkTimeStatus; } diff --git a/src/core/thread/time_sync_service.hpp b/src/core/thread/time_sync_service.hpp index 461e0bc41..6d8138297 100644 --- a/src/core/thread/time_sync_service.hpp +++ b/src/core/thread/time_sync_service.hpp @@ -144,11 +144,13 @@ private: */ void IncrementTimeSyncSeq(void); - bool mTimeSyncRequired; ///< Indicate whether or not a time synchronization message is required. - uint8_t mTimeSyncSeq; ///< The time synchronization sequence. - uint16_t mTimeSyncPeriod; ///< The time synchronization period. - uint16_t mXtalThreshold; ///< The XTAL accuracy threshold for a device to become a Router, in PPM. - uint32_t mLastTimeSyncSent; ///< The time when the last time synchronization message was sent. + bool mTimeSyncRequired; ///< Indicate whether or not a time synchronization message is required. + uint8_t mTimeSyncSeq; ///< The time synchronization sequence. + uint16_t mTimeSyncPeriod; ///< The time synchronization period. + uint16_t mXtalThreshold; ///< The XTAL accuracy threshold for a device to become a Router, in PPM. +#if OPENTHREAD_FTD + uint32_t mLastTimeSyncSent; ///< The time when the last time synchronization message was sent. +#endif uint32_t mLastTimeSyncReceived; ///< The time when the last time synchronization message was received. int64_t mNetworkTimeOffset; ///< The time offset to the Thread Network time };