Midnight Sun Firmware
|
Class that represents the netowrk-time-protocol client that synchronizes with a server. More...
#include <ntp_client.h>
Public Member Functions | |
NTPClient () | |
Constructs a NTPClient object. More... | |
void | NTPClientProcedure () |
Thread procedure for handling NTP synchronization. More... | |
void | startSynchronization (const std::string &serverAddress) |
Starts NTP synchronization of the client. More... | |
Private Attributes | |
int | m_NTPSocket |
std::string | m_serverAddress |
NTPPacket | m_serverResponse |
pthread_t | m_NTPClientThreadId |
std::atomic< bool > | m_isSynchronizing |
Static Private Attributes | |
static constexpr int | NTP_PORT = 123 |
static constexpr int | NTP_SYNC_PERIOD_S = 60 |
Class that represents the netowrk-time-protocol client that synchronizes with a server.
This class is responsible for fetching stratum 2 time and synchronizing itself The client shall account for timing errors/differences every NTP_SYNC_PERIOD_S
NTPClient | ( | ) |
Constructs a NTPClient object.
Initializes the NTP client. The constructor sets up internal variables
void NTPClientProcedure | ( | ) |
Thread procedure for handling NTP synchronization.
This thread shall run at the NTP_SYNC_PERIOD_S frequency
void startSynchronization | ( | const std::string & | serverAddress | ) |
Starts NTP synchronization of the client.
This function will spawn the NTPClientProcedure thread
serverAddress | The address of the NTP server to bind to |
|
private |
Boolean flag to indicate the synchronization status of the client
|
private |
Thread Id for synchronizing the client
|
private |
The NTP servers socket FD
|
private |
The NTP servers address for fetching stratum 2 data (ie: 127.0.0.1)
|
private |
NTP Packet to store the servers timing data
|
staticconstexprprivate |
Universal port for network-time-protocol
|
staticconstexprprivate |
Client synchronization period