Go to the documentation of this file.
31 #ifndef _SNTP_CLIENT_H
32 #define _SNTP_CLIENT_H
39 #ifndef SNTP_CLIENT_SUPPORT
40 #define SNTP_CLIENT_SUPPORT ENABLED
41 #elif (SNTP_CLIENT_SUPPORT != ENABLED && SNTP_CLIENT_SUPPORT != DISABLED)
42 #error SNTP_CLIENT_SUPPORT parameter is not valid
46 #ifndef SNTP_CLIENT_DEFAULT_TIMEOUT
47 #define SNTP_CLIENT_DEFAULT_TIMEOUT 30000
48 #elif (SNTP_CLIENT_DEFAULT_TIMEOUT < 1000)
49 #error SNTP_CLIENT_DEFAULT_TIMEOUT parameter is not valid
53 #ifndef SNTP_CLIENT_INIT_RETRANSMIT_TIMEOUT
54 #define SNTP_CLIENT_INIT_RETRANSMIT_TIMEOUT 2000
55 #elif (SNTP_CLIENT_INIT_RETRANSMIT_TIMEOUT < 1000)
56 #error SNTP_CLIENT_INIT_RETRANSMIT_TIMEOUT parameter is not valid
60 #ifndef SNTP_CLIENT_MAX_RETRANSMIT_TIMEOUT
61 #define SNTP_CLIENT_MAX_RETRANSMIT_TIMEOUT 15000
62 #elif (SNTP_CLIENT_MAX_RETRANSMIT_TIMEOUT < 1000)
63 #error SNTP_CLIENT_MAX_RETRANSMIT_TIMEOUT parameter is not valid
67 #ifndef SNTP_CLIENT_PRIVATE_CONTEXT
68 #define SNTP_CLIENT_PRIVATE_CONTEXT
121 const IpAddr *serverIpAddr, uint16_t serverPort);
size_t messageLen
Length of the NTP message, in bytes.
error_t sntpClientSetTimeout(SntpClientContext *context, systime_t timeout)
Set communication timeout.
@ SNTP_CLIENT_STATE_COMPLETE
systime_t retransmitStartTime
Time at which the last request was sent.
error_t sntpClientInit(SntpClientContext *context)
Initialize SNTP client context.
Socket * socket
Underlying socket.
IpAddr serverIpAddr
NTP server address.
systime_t startTime
Request start time.
uint32_t sntpClientGetKissCode(SntpClientContext *context)
Retrieve the kiss code from a Kiss-of-Death message.
SntpClientState state
SNTP client state.
error_t sntpClientBindToInterface(SntpClientContext *context, NetInterface *interface)
Bind the SNTP client to a particular network interface.
@ SNTP_CLIENT_STATE_RECEIVING
error_t sntpClientSetServerAddr(SntpClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
Specify the IP address of the NTP server.
systime_t timeout
Timeout value.
uint32_t systime_t
System time.
error_t sntpClientGetTimestamp(SntpClientContext *context, NtpTimestamp *timestamp)
Retrieve current time from NTP server.
uint32_t kissCode
Kiss code.
@ SNTP_CLIENT_STATE_SENDING
SntpClientState
SNTP client states.
#define SNTP_CLIENT_PRIVATE_CONTEXT
Definitions common to NTP client and server.
systime_t retransmitTimeout
Retransmission timeout.
NetInterface * interface
Underlying network interface.
void sntpClientDeinit(SntpClientContext *context)
Release SNTP client context.
uint16_t serverPort
NTP server port.