33#ifndef CORE_SNTP_SERIALIZER_H_
34#define CORE_SNTP_SERIALIZER_H_
54#define SNTP_PACKET_BASE_SIZE ( 48U )
68#define SNTP_FRACTION_VALUE_PER_MICROSECOND ( 4295U )
85#define SNTP_TIME_AT_UNIX_EPOCH_SECS ( 2208988800U )
99#define SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS ( 61505151U )
112#define UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME ( 2085978496U )
122#define SNTP_KISS_OF_DEATH_CODE_LENGTH ( 4U )
132#define SNTP_KISS_OF_DEATH_CODE_NONE ( 0U )
139typedef enum SntpStatus
264typedef enum SntpLeapSecondInfo
283typedef struct SntpTimestamp
295typedef struct SntpResponse
383 uint32_t randomNumber,
450 const void * pResponseBuffer,
490 uint16_t desiredAccuracy,
491 uint32_t * pPollInterval );
525 uint32_t * pUnixTimeSecs,
526 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:673
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:748
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:812
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:605
SntpLeapSecondInfo_t
Enumeration for leap second information that an SNTP server can send its response to a time request....
Definition: core_sntp_serializer.h:265
SntpStatus_t
Enumeration of status codes that can be returned by the coreSNTP Library API.
Definition: core_sntp_serializer.h:140
@ LastMinuteHas59Seconds
A leap second should be inserted in the last minute before midnight.
Definition: core_sntp_serializer.h:268
@ LastMinuteHas61Seconds
There is no upcoming leap second adjustment.
Definition: core_sntp_serializer.h:267
@ AlarmServerNotSynchronized
A leap second should be deleted from the last minute before midnight.
Definition: core_sntp_serializer.h:269
@ SntpErrorSendTimeout
A timeout occurred in sending time request packet over the network to a server through the Sntp_SendT...
Definition: core_sntp_serializer.h:230
@ SntpErrorBadParameter
Invalid parameter passed to an API function.
Definition: core_sntp_serializer.h:149
@ SntpErrorBufferTooSmall
Application provided insufficient buffer space for serializing or de-serializing an SNTP packet....
Definition: core_sntp_serializer.h:179
@ SntpZeroPollInterval
Poll interval value is under 1 second which cannot be calculated by Sntp_CalculatePollInterval.
Definition: core_sntp_serializer.h:190
@ SntpErrorResponseTimeout
A timeout has occurred in receiving server response with the Sntp_ReceiveTimeResponse API.
Definition: core_sntp_serializer.h:236
@ SntpNoResponseReceived
No SNTP packet for server response is received from the network by the Sntp_ReceiveTimeResponse API.
Definition: core_sntp_serializer.h:242
@ SntpInvalidResponse
Server response failed validation checks for expected data in SNTP packet.
Definition: core_sntp_serializer.h:184
@ SntpErrorAuthFailure
Failure from the user-supplied authentication interface, SntpAuthenticationInterface_t,...
Definition: core_sntp_serializer.h:224
@ SntpErrorNetworkFailure
Networking operation of sending or receiving SNTP packet through the user-defined UDP transport inter...
Definition: core_sntp_serializer.h:210
@ SntpErrorDnsFailure
The user-defined DNS resolution interface, SntpResolveDns_t, failed to resolve address for a time ser...
Definition: core_sntp_serializer.h:202
@ SntpRejectedResponseChangeServer
Server sent a Kiss-o'-Death message with non-retryable code (i.e. DENY or RSTR).
Definition: core_sntp_serializer.h:160
@ 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:166
@ SntpSuccess
Successful operation of an SNTP API.
Definition: core_sntp_serializer.h:144
@ 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:155
@ SntpServerNotAuthenticated
Time server is not authenticated from the authentication data in its response. This status can be ret...
Definition: core_sntp_serializer.h:217
@ SntpRejectedResponseOtherCode
Server sent a Kiss-o'-Death message with a code, specific to the server. Application can inspect the ...
Definition: core_sntp_serializer.h:172
@ 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:196
@ SntpErrorContextNotInitialized
The SNTP context passed to Sntp_SendTimeRequest or Sntp_ReceiveTimeResponse APIs is is uninitialized.
Definition: core_sntp_serializer.h:248
Structure representing data parsed from an SNTP response from server as well as data of arithmetic ca...
Definition: core_sntp_serializer.h:296
SntpTimestamp_t serverTime
The timestamp sent by the server.
Definition: core_sntp_serializer.h:300
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:319
SntpLeapSecondInfo_t leapSecondType
The information of an upcoming leap second in the server response.
Definition: core_sntp_serializer.h:306
int64_t clockOffsetMs
The offset (in milliseconds) of the system clock relative to the server time calculated from timestam...
Definition: core_sntp_serializer.h:345
Structure representing an SNTP timestamp.
Definition: core_sntp_serializer.h:284
uint32_t fractions
The fractions part of the SNTP timestamp with resolution of 2^(-32) ~ 232 picoseconds.
Definition: core_sntp_serializer.h:286
uint32_t seconds
Number of seconds since epoch time.
Definition: core_sntp_serializer.h:285