6 #ifndef APP_NTPCLIENT_H_ 7 #define APP_NTPCLIENT_H_ 9 #include "UdpConnection.h" 10 #include "../Platform/System.h" 12 #include "../SystemClock.h" 13 #include "../Platform/Station.h" 14 #include "../Delegate.h" 17 #define NTP_PACKET_SIZE 48 19 #define NTP_MODE_CLIENT 3 20 #define NTP_MODE_SERVER 4 22 #define NTP_DEFAULT_SERVER "pool.ntp.org" 23 #define NTP_DEFAULT_QUERY_INTERVAL_SECONDS 600 // 10 minutes 24 #define NTP_RESPONSE_TIMEOUT_MS 20000 // 20 seconds static void staticDnsResponse(const char *name, struct ip_addr *ip, void *arg)
Handle DNS response.
void setAutoUpdateSystemClock(bool autoUpdateClock)
Enable / disable update of system clock.
Definition: UdpConnection.h:20
Timer connectionTimer
Wait for WiFi connection timer.
Definition: NtpClient.h:100
void onReceive(pbuf *buf, IPAddress remoteIP, uint16_t remotePort)
Handle UDP message reception.
String server
IP address or Hostname of NTP server.
Definition: NtpClient.h:93
Timer autoUpdateTimer
Periodic query timer.
Definition: NtpClient.h:98
NtpClient()
Instantiates NTP client object.
void setAutoQueryInterval(int seconds)
Set query period.
void setAutoQuery(bool autoQuery)
Enable / disable periodic query.
Timer timeoutTimer
NTP message timeout timer.
Definition: NtpClient.h:99
void internalRequestTime(IPAddress serverIp)
Send time request to NTP server.
void setNtpServer(String server)
Set the NTP server.
bool autoUpdateSystemClock
True to update system clock with NTP time.
Definition: NtpClient.h:96
NTP client class.
Definition: NtpClient.h:33
Definition: IPAddress.h:30
void requestTime()
Request time from NTP server.
NtpTimeResultDelegate delegateCompleted
NTP result handler delegate.
Definition: NtpClient.h:95