NTP client class.
More...
#include <NtpClient.h>
|
| void | onReceive (pbuf *buf, IPAddress remoteIP, uint16_t remotePort) override |
| | Handle UDP message reception. More...
|
| |
| void | internalRequestTime (IPAddress serverIp) |
| | Send time request to NTP server. More...
|
| |
| void | startTimer (uint32_t milliseconds) |
| | Start the timer running. More...
|
| |
|
void | stopTimer () |
| |
|
virtual bool | listen (int port) |
| |
|
virtual bool | connect (IPAddress ip, uint16_t port) |
| |
|
virtual void | close () |
| |
|
virtual bool | send (const char *data, int length) |
| |
|
bool | sendString (const char *data) |
| |
|
bool | sendString (const String &data) |
| |
|
virtual bool | sendTo (IPAddress remoteIP, uint16_t remotePort, const char *data, int length) |
| |
|
bool | sendStringTo (IPAddress remoteIP, uint16_t remotePort, const char *data) |
| |
|
bool | sendStringTo (IPAddress remoteIP, uint16_t remotePort, const String &data) |
| |
|
bool | initialize (udp_pcb *pcb=nullptr) |
| |
|
|
static void | staticOnReceive (void *arg, struct udp_pcb *pcb, struct pbuf *p, LWIP_IP_ADDR_T *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 |
|
) |
| |
|
overrideprotectedvirtual |
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 |
( |
unsigned |
seconds | ) |
|
Set query period.
- Parameters
-
| seconds | Period in seconds between periodic queries |
| void NtpClient::setAutoUpdateSystemClock |
( |
bool |
autoUpdateClock | ) |
|
|
inline |
Enable / disable update of system clock.
- Parameters
-
| autoUpdateClock | True to update system clock with NTP result. |
| void NtpClient::setNtpServer |
( |
const String & |
server | ) |
|
|
inline |
Set the NTP server.
- Parameters
-
| server | IP address or hostname of NTP server |
| void NtpClient::startTimer |
( |
uint32_t |
milliseconds | ) |
|
|
inlineprotected |
Start the timer running.
- Parameters
-
| time | to run in milliseconds |
| bool NtpClient::autoUpdateSystemClock = false |
|
protected |
True to update system clock with NTP time.
NTP result handler delegate.
IP address or Hostname of NTP server.
Deals with timeouts, retries and autoquery updates.