Midnight Sun Firmware
|
Network time protocol helper library. More...
Classes | |
struct | NTPTime |
Structure representing NTP time format with seconds and fractional seconds. More... | |
struct | NTPPacket |
Structure representing an NTP packet. More... | |
Macros | |
#define | NTP_VERSION 4U |
NTP version being used. | |
#define | NTP_LEAP_INDICATOR_OFFSET 6U |
Offset for the Leap Indicator in the flags field of the NTP packet. | |
#define | NTP_VERSION_OFFSET 3U |
Offset for the NTP version in the flags field of the NTP packet. | |
#define | NTP_MODE_OFFSET 0U |
Offset for the NTP mode in the flags field of the NTP packet. | |
#define | NTP_POLL_TO_SECONDS(poll) (1U << poll) |
Macro to convert NTP poll interval to seconds. More... | |
Enumerations | |
enum | NTPMode { NTP_RESERVED_MODE , NTP_ACTIVE_MODE , NTP_PASSIVE_MODE , NTP_CLIENT_MODE , NTP_SERVER_MODE , NTP_BROADCAST_MODE , NTP_CONTROL_MODE , NUM_NTP_MODES } |
Enumeration for the NTP modes. More... | |
enum | NTPLeapIndicator { NTP_LI_NONE , NTP_LI_LAST_MINUTE_OF_THE_DAY_61_S , NTP_LI_LAST_MINUTE_OF_THE_DAY_59_S , NTP_LI_NOSYNC } |
Enumeration for the Leap Indicator values. More... | |
Functions | |
time_t | ntpToUnixTime (NTPTime ntpTime) |
Converts an NTP time to Unix time. More... | |
uint32_t | unixToNTPTime (time_t unixTime) |
Converts a Unix time to NTP time. More... | |
void | convertNTPTimestamp (NTPTime ×tamp) |
Converts an NTP timestamp to its human-readable representation. More... | |
void | dumpNTPPacketData (const NTPPacket packet) |
Dumps the data of an NTP packet for debugging purposes. More... | |
Variables | |
static constexpr uint32_t | NTP_UNIX_EPOCH_DIFF = 2208988800UL |
Difference between the NTP epoch (1900-01-01) and the Unix epoch (1970-01-01) in seconds. | |
Network time protocol helper library.
#define NTP_POLL_TO_SECONDS | ( | poll | ) | (1U << poll) |
Macro to convert NTP poll interval to seconds.
poll | The poll interval exponent |
enum NTPLeapIndicator |
enum NTPMode |
Enumeration for the NTP modes.
Enumerator | |
---|---|
NTP_RESERVED_MODE | Reserved mode (not used) |
NTP_ACTIVE_MODE | Symmetric active mode |
NTP_PASSIVE_MODE | Symmetric passive mode |
NTP_CLIENT_MODE | Client mode |
NTP_SERVER_MODE | Server mode |
NTP_BROADCAST_MODE | Broadcast mode |
NTP_CONTROL_MODE | Control mode |
NUM_NTP_MODES | Number of modes |
void convertNTPTimestamp | ( | NTPTime & | timestamp | ) |
Converts an NTP timestamp to its human-readable representation.
timestamp | The NTP timestamp to be converted |
void dumpNTPPacketData | ( | const NTPPacket | packet | ) |
Dumps the data of an NTP packet for debugging purposes.
packet | The NTP packet to be dumped |
time_t ntpToUnixTime | ( | NTPTime | ntpTime | ) |
Converts an NTP time to Unix time.
ntpTime | The NTP time to be converted |
uint32_t unixToNTPTime | ( | time_t | unixTime | ) |
Converts a Unix time to NTP time.
unixTime | The Unix time to be converted |