#include <SimpleNTP.h>
|
| typedef void(* | SyncTimeCallback) (time_t epoch) |
| | Callback function type for time synchronization events.
|
| |
|
| static constexpr const char * | servers [] = {"time.google.com", "time.nist.gov", "pool.ntp.org"} |
| | Array of NTP server hostnames to try connecting to.
|
| |
◆ SyncTimeCallback
| typedef void(* uniot::SimpleNTP::SyncTimeCallback) (time_t epoch) |
Callback function type for time synchronization events.
This callback is triggered when time is successfully synchronized with an NTP server.
- Parameters
-
| epoch | The current time as Unix timestamp (seconds since Jan 1, 1970) |
◆ SimpleNTP()
| uniot::SimpleNTP::SimpleNTP |
( |
| ) |
|
|
inline |
Default constructor.
Initializes a SimpleNTP instance with no callback
◆ getNtpTime()
| time_t uniot::SimpleNTP::getNtpTime |
( |
| ) |
|
|
inline |
Requests and retrieves current time from NTP server.
Connects to a randomly selected NTP server, sends a request packet, waits for and processes the response to extract the current time.
- Return values
-
| time_t | Current time in seconds since Jan 1, 1970 |
| 0 | if time synchronization failed |
◆ setSyncTimeCallback()
Sets the callback function for time synchronization events.
- Parameters
-
| callback | Function to be called when time is successfully synchronized |
◆ servers
| const char* uniot::SimpleNTP::servers[] = {"time.google.com", "time.nist.gov", "pool.ntp.org"} |
|
staticconstexpr |
Array of NTP server hostnames to try connecting to.
One server is randomly selected during each sync attempt
The documentation for this class was generated from the following file: