31#ifndef CORE_SNTP_SERIALIZER_H_
32#define CORE_SNTP_SERIALIZER_H_
52#define SNTP_PACKET_BASE_SIZE ( 48U )
66#define SNTP_FRACTION_VALUE_PER_MICROSECOND ( 4295U )
83#define SNTP_TIME_AT_UNIX_EPOCH_SECS ( 2208988800U )
97#define SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS ( 61505151U )
110#define UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME ( 2085978496U )
120#define SNTP_KISS_OF_DEATH_CODE_LENGTH ( 4U )
130#define SNTP_KISS_OF_DEATH_CODE_NONE ( 0U )
137typedef enum SntpStatus
262typedef enum SntpLeapSecondInfo
281typedef struct SntpTimestamp
293typedef struct SntpResponse
381 uint32_t randomNumber,
448 const void * pResponseBuffer,
488 uint16_t desiredAccuracy,
489 uint32_t * pPollInterval );
523 uint32_t * pUnixTimeSecs,
524 uint32_t * pUnixTimeMicrosecs );
SntpStatus_t Sntp_DeserializeResponse(const SntpTimestamp_t *pRequestTime, const SntpTimestamp_t *pResponseRxTime, const void *pResponseBuffer, size_t bufferSize, SntpResponseData_t *pParsedResponse)
De-serializes an SNTP packet received from a server as a response to a SNTP request.
Definition: core_sntp_serializer.c:666
SntpStatus_t Sntp_CalculatePollInterval(uint16_t clockFreqTolerance, uint16_t desiredAccuracy, uint32_t *pPollInterval)
Utility to calculate the poll interval of sending periodic time queries to servers to achieve a desir...
Definition: core_sntp_serializer.c:738
SntpStatus_t Sntp_ConvertToUnixTime(const SntpTimestamp_t *pSntpTime, uint32_t *pUnixTimeSecs, uint32_t *pUnixTimeMicrosecs)
Utility to convert SNTP timestamp (that uses 1st Jan 1900 as the epoch) to UNIX timestamp (that uses ...
Definition: core_sntp_serializer.c:802
SntpStatus_t Sntp_SerializeRequest(SntpTimestamp_t *pRequestTime, uint32_t randomNumber, void *pBuffer, size_t bufferSize)
Serializes an SNTP request packet to use for querying a time server.
Definition: core_sntp_serializer.c:601
SntpLeapSecondInfo_t
Enumeration for leap second information that an SNTP server can send its response to a time request....
Definition: core_sntp_serializer.h:263
SntpStatus_t
Enumeration of status codes that can be returned by the coreSNTP Library API.
Definition: core_sntp_serializer.h:138
@ LastMinuteHas59Seconds
A leap second should be inserted in the last minute before midnight.
Definition: core_sntp_serializer.h:266
@ LastMinuteHas61Seconds
There is no upcoming leap second adjustment.
Definition: core_sntp_serializer.h:265
@ AlarmServerNotSynchronized
A leap second should be deleted from the last minute before midnight.
Definition: core_sntp_serializer.h:267
@ SntpErrorSendTimeout
A timeout occurred in sending time request packet over the network to a server through the Sntp_SendT...
Definition: core_sntp_serializer.h:228
@ SntpErrorBadParameter
Invalid parameter passed to an API function.
Definition: core_sntp_serializer.h:147
@ SntpErrorBufferTooSmall
Application provided insufficient buffer space for serializing or de-serializing an SNTP packet....
Definition: core_sntp_serializer.h:177
@ SntpZeroPollInterval
Poll interval value is under 1 second which cannot be calculated by Sntp_CalculatePollInterval.
Definition: core_sntp_serializer.h:188
@ SntpErrorResponseTimeout
A timeout has occurred in receiving server response with the Sntp_ReceiveTimeResponse API.
Definition: core_sntp_serializer.h:234
@ SntpNoResponseReceived
No SNTP packet for server response is received from the network by the Sntp_ReceiveTimeResponse API.
Definition: core_sntp_serializer.h:240
@ SntpInvalidResponse
Server response failed validation checks for expected data in SNTP packet.
Definition: core_sntp_serializer.h:182
@ SntpErrorAuthFailure
Failure from the user-supplied authentication interface, SntpAuthenticationInterface_t,...
Definition: core_sntp_serializer.h:222
@ SntpErrorNetworkFailure
Networking operation of sending or receiving SNTP packet through the user-defined UDP transport inter...
Definition: core_sntp_serializer.h:208
@ SntpErrorDnsFailure
The user-defined DNS resolution interface, SntpResolveDns_t, failed to resolve address for a time ser...
Definition: core_sntp_serializer.h:200
@ SntpRejectedResponseChangeServer
Server sent a Kiss-o'-Death message with non-retryable code (i.e. DENY or RSTR).
Definition: core_sntp_serializer.h:158
@ SntpRejectedResponseRetryWithBackoff
Server sent a Kiss-o'-Death message with a RATE code, which means that client should back-off before ...
Definition: core_sntp_serializer.h:164
@ SntpSuccess
Successful operation of an SNTP API.
Definition: core_sntp_serializer.h:142
@ SntpRejectedResponse
Server sent a Kiss-o'-Death message to reject the request for time. This status can be returned by th...
Definition: core_sntp_serializer.h:153
@ SntpServerNotAuthenticated
Time server is not authenticated from the authentication data in its response. This status can be ret...
Definition: core_sntp_serializer.h:215
@ SntpRejectedResponseOtherCode
Server sent a Kiss-o'-Death message with a code, specific to the server. Application can inspect the ...
Definition: core_sntp_serializer.h:170
@ SntpErrorTimeNotSupported
SNTP timestamp cannot be converted to UNIX time as time does not lie in time range supported by Sntp_...
Definition: core_sntp_serializer.h:194
@ SntpErrorContextNotInitialized
The SNTP context passed to Sntp_SendTimeRequest or Sntp_ReceiveTimeResponse APIs is is uninitialized.
Definition: core_sntp_serializer.h:246
Structure representing data parsed from an SNTP response from server as well as data of arithmetic ca...
Definition: core_sntp_serializer.h:294
SntpTimestamp_t serverTime
The timestamp sent by the server.
Definition: core_sntp_serializer.h:298
uint32_t rejectedResponseCode
If a server responded with Kiss-o'-Death message to reject time request, this is the fixed length ASC...
Definition: core_sntp_serializer.h:317
SntpLeapSecondInfo_t leapSecondType
The information of an upcoming leap second in the server response.
Definition: core_sntp_serializer.h:304
int64_t clockOffsetMs
The offset (in milliseconds) of the system clock relative to the server time calculated from timestam...
Definition: core_sntp_serializer.h:343
Structure representing an SNTP timestamp.
Definition: core_sntp_serializer.h:282
uint32_t fractions
The fractions part of the SNTP timestamp with resolution of 2^(-32) ~ 232 picoseconds.
Definition: core_sntp_serializer.h:284
uint32_t seconds
Number of seconds since epoch time.
Definition: core_sntp_serializer.h:283