NTP client class.
More...
#include <NtpClient.h>
|
| void | onReceive (pbuf *buf, IPAddress remoteIP, uint16_t remotePort) |
| | Handle UDP message reception. More...
|
| |
| void | internalRequestTime (IPAddress serverIp) |
| | Send time request to NTP server. More...
|
| |
|
virtual bool | listen (int port) |
| |
|
virtual bool | connect (IPAddress ip, uint16_t port) |
| |
|
virtual void | close () |
| |
|
virtual void | send (const char *data, int length) |
| |
|
void | sendString (const char *data) |
| |
|
void | sendString (const String &data) |
| |
|
virtual void | sendTo (IPAddress remoteIP, uint16_t remotePort, const char *data, int length) |
| |
|
void | sendStringTo (IPAddress remoteIP, uint16_t remotePort, const char *data) |
| |
|
void | sendStringTo (IPAddress remoteIP, uint16_t remotePort, const String &data) |
| |
|
void | initialize (udp_pcb *pcb=NULL) |
| |
|
| static void | staticDnsResponse (const char *name, struct ip_addr *ip, void *arg) |
| | Handle DNS response. More...
|
| |
|
static void | staticOnReceive (void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) |
| |
Instantiates NTP client object.
Instantiates NTP client object.
- Parameters
-
| onTimeReceivedCb | Callback delegate to be called when NTP time result is received |
Instantiates NTP client object.
- Parameters
-
| reqServer | IP address or hostname of NTP server |
| reqIntervalSeconds | Quantity of seconds between NTP requests |
| onTimeReceivedCb | Callback delegate to be called when NTP time result is received (Default: None) |
| void NtpClient::internalRequestTime |
( |
IPAddress |
serverIp | ) |
|
|
protected |
Send time request to NTP server.
- Parameters
-
| serverIp | IP address of NTP server |
| void NtpClient::onReceive |
( |
pbuf * |
buf, |
|
|
IPAddress |
remoteIP, |
|
|
uint16_t |
remotePort |
|
) |
| |
|
protectedvirtual |
Handle UDP message reception.
- Parameters
-
| buf | Pointer to data buffer containing UDP payload |
| remoteIP | IP address of remote host |
| remotePort | Port number of remote host |
Reimplemented from UdpConnection.
| void NtpClient::requestTime |
( |
| ) |
|
Request time from NTP server.
- Note
- Instigates request. Result is handled by NTP result handler function if defined
| void NtpClient::setAutoQuery |
( |
bool |
autoQuery | ) |
|
Enable / disable periodic query.
- Parameters
-
| autoQuery | True to enable periodic query of NTP server |
| void NtpClient::setAutoQueryInterval |
( |
int |
seconds | ) |
|
Set query period.
- Parameters
-
| seconds | Period in seconds between periodic queries |
| void NtpClient::setAutoUpdateSystemClock |
( |
bool |
autoUpdateClock | ) |
|
Enable / disable update of system clock.
- Parameters
-
| autoUpdateClock | True to update system clock with NTP result. |
| void NtpClient::setNtpServer |
( |
String |
server | ) |
|
Set the NTP server.
- Parameters
-
| server | IP address or hostname of NTP server |
| static void NtpClient::staticDnsResponse |
( |
const char * |
name, |
|
|
struct ip_addr * |
ip, |
|
|
void * |
arg |
|
) |
| |
|
staticprotected |
Handle DNS response.
- Parameters
-
| name | Pointer to c-string containing hostname |
| ip | Ponter to IP address |
| arg | Pointer to the NTP client object that made the DNS request |
- Note
- This function is called when a DNS query is serviced
| bool NtpClient::autoUpdateSystemClock = false |
|
protected |
True to update system clock with NTP time.
| Timer NtpClient::autoUpdateTimer |
|
protected |
| Timer NtpClient::connectionTimer |
|
protected |
Wait for WiFi connection timer.
NTP result handler delegate.
| String NtpClient::server = NTP_DEFAULT_SERVER |
|
protected |
IP address or Hostname of NTP server.
| Timer NtpClient::timeoutTimer |
|
protected |
NTP message timeout timer.