mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 14:27:47 +00:00
[sntp-clinet] simplify uint64 constants
This commit is contained in:
committed by
Jonathan Hui
parent
d52aa05b54
commit
2a5403d94a
+2
-2
@@ -2994,8 +2994,8 @@ void Interpreter::HandleSntpResponse(uint64_t aTime, otError aResult)
|
||||
{
|
||||
// Some Embedded C libraries do not support printing of 64-bit unsigned integers.
|
||||
// To simplify, unix epoch time and era number are printed separately.
|
||||
mServer->OutputFormat("SNTP response - Unix time: %ld (era: %ld)\r\n",
|
||||
static_cast<uint32_t>(aTime & UINT32_MAX), static_cast<uint32_t>(aTime >> 32));
|
||||
mServer->OutputFormat("SNTP response - Unix time: %ld (era: %ld)\r\n", static_cast<uint32_t>(aTime),
|
||||
static_cast<uint32_t>(aTime >> 32));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -374,7 +374,7 @@ void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
|
||||
// Due to NTP protocol limitation, this module stops working correctly after around year 2106, if
|
||||
// unix era is not updated. This seems to be a reasonable limitation for now. Era number cannot be
|
||||
// obtained using NTP protocol, and client of this module is responsible to set it properly.
|
||||
unixTime = GetUnixEra() * (UINT32_MAX + 1ULL);
|
||||
unixTime = GetUnixEra() * (1ULL << 32);
|
||||
|
||||
if (responseHeader.GetTransmitTimestampSeconds() > kTimeAt1970)
|
||||
{
|
||||
@@ -382,8 +382,7 @@ void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag
|
||||
}
|
||||
else
|
||||
{
|
||||
unixTime +=
|
||||
static_cast<uint64_t>(responseHeader.GetTransmitTimestampSeconds()) + (UINT32_MAX + 1ULL) - kTimeAt1970;
|
||||
unixTime += static_cast<uint64_t>(responseHeader.GetTransmitTimestampSeconds()) + (1ULL << 32) - kTimeAt1970;
|
||||
}
|
||||
|
||||
// Return the time since 1970.
|
||||
|
||||
Reference in New Issue
Block a user