Lee Kai Xuan / mbed-os

Fork of mbed-os by erkin yucel

Embed: (wiki syntax)

« Back to documentation index

NTPClient.h File Reference

NTPClient.h File Reference

NTP Client header file. More...

Go to the source code of this file.

Data Structures

class  NTPClient
 NTP Client to update the mbed's RTC using a remote time server. More...

Enumerations

enum  NTPResult {
  NTP_DNS, NTP_PRTCL, NTP_TIMEOUT, NTP_CONN,
  NTP_OK = 0
}
 

NTP client results.

More...

Functions

 NTPClient ()
 Instantiate the NTP client.
NTPResult setTime (const char *host, uint16_t port=NTP_DEFAULT_PORT, uint32_t timeout=NTP_DEFAULT_TIMEOUT)
 Get current time (blocking) Update the time using the server host Blocks until completion.

Detailed Description

NTP Client header file.

Definition in file NTPClient.h.


Enumeration Type Documentation

enum NTPResult

NTP client results.

Enumerator:
NTP_DNS 

Could not resolve name.

NTP_PRTCL 

Protocol error.

NTP_TIMEOUT 

Connection timeout.

NTP_CONN 

Connection error.

NTP_OK 

Success.

Definition at line 33 of file NTPClient.h.


Function Documentation

__attribute__::NTPClient (  )

Instantiate the NTP client.

NTPResult __attribute__::setTime ( const char *  host,
uint16_t  port = NTP_DEFAULT_PORT,
uint32_t  timeout = NTP_DEFAULT_TIMEOUT 
)

Get current time (blocking) Update the time using the server host Blocks until completion.

Parameters:
hostNTP server IPv4 address or hostname (will be resolved via DNS)
portport to use; defaults to 123
timeoutwaiting timeout in ms (osWaitForever for blocking function, not recommended)
Returns:
0 on success, NTP error code (<0) on failure