[time-sync] fix incorrect status after boot (#3291)

This commit is contained in:
Joseph Newman
2018-11-12 18:22:51 -08:00
committed by Jonathan Hui
parent 9f7bc3a6ec
commit 7d36e8d913
+6 -1
View File
@@ -195,7 +195,12 @@ void TimeSync::CheckAndHandleChanges(bool aTimeUpdated)
case OT_DEVICE_ROLE_CHILD:
case OT_DEVICE_ROLE_ROUTER:
if (timeSyncLastSyncMs > resyncNeededThresholdMs)
if (mLastTimeSyncReceived == 0)
{
// Haven't yet received any time sync
networkTimeStatus = OT_NETWORK_TIME_UNSYNCHRONIZED;
}
else if (timeSyncLastSyncMs > resyncNeededThresholdMs)
{
// The device hasnt received time sync for more than two periods time.
networkTimeStatus = OT_NETWORK_TIME_RESYNC_NEEDED;