[time-sync] fix build issue with time sync enabled (#3167)

Also enable time sync in a travis check.
This commit is contained in:
Shu Chen
2018-10-16 19:58:34 -07:00
committed by Jonathan Hui
parent 0b18d8ffad
commit 71b90a6764
7 changed files with 16 additions and 9 deletions
+2
View File
@@ -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
+1 -1
View File
@@ -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;
+1
View File
@@ -36,6 +36,7 @@
#define OPENTHREAD_NETWORK_TIME_H_
#include <openthread/error.h>
#include <openthread/instance.h>
#ifdef __cplusplus
extern "C" {
+1 -1
View File
@@ -2389,7 +2389,7 @@ uint8_t Mac::GetTimeIeOffset(Frame &aFrame)
VerifyOrExit(cur != NULL);
cur += sizeof(VendorIeHeader);
offset = cur - base;
offset = static_cast<uint8_t>(cur - base);
exit:
return offset;
+1 -1
View File
@@ -1000,7 +1000,7 @@ otError Frame::AppendHeaderIe(HeaderIe *aIeList, uint8_t aIeCount)
cur += aIeList[i].GetLength();
}
SetPsduLength(GetPsduLength() + cur - base);
SetPsduLength(GetPsduLength() + static_cast<uint8_t>(cur - base));
exit:
return error;
+3 -1
View File
@@ -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<uint64_t>(static_cast<int64_t>(otPlatTimeGet()) + mNetworkTimeOffset);
return networkTimeStatus;
}
+7 -5
View File
@@ -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
};