nRF51 IoT SDK
|
The SNTP Client SNTP client module is a Simple Network Time Protocol Version 4 (SNTPv4) client implementation. It provides a local clock in the Unix time format and can query a Network Time Protocol (NTP) server and synchronize the local clock to the server time source.
The SNTP client requires the IoT Timer module to be present.
At initialization the local clock is set to zero, which is equivalent to the Unix epoch time 00:00:00 UTC on 1 January 1970. The local clock can be synchronised with an NTP server with the sntp_client_server_query procedure. The module can be configured at initialization to provide asynchronous callbacks when a server response is received or when a query times out. The conversion between the NTP timestamp format and the Unix time format is done automatically.
The sntp_client_local_time_get procedure provides the local time without querying an NTP server. The elapsed time since the last synchronisation with an NTP server is calculated from the wall clock value of the IoT Timer module. Therefore, the accuracy of the local clock is limited by the value of IOT_TIMER_RESOLUTION_IN_MS.
The SNTP Client module can be uninitialized with the sntp_client_uninitialize procedure. This frees up the UDP socket allocated for the module.
The following configuration parameters should be defined in sdk_config.h
.
Maximum number of retransmissions of a query. Set this define to 0 to disable retransmission attempts.
Description | Value |
---|---|
Minimum value | 0 |
Maximum value | 255 |
Dependencies | None |
Interval between retransmissions in seconds.
Description | Value |
---|---|
Minimum value | 1 |
Maximum value | None |
Dependencies | None |
Disables API parameter checks in the module. Set this define to 1 to disable checks on API parameters in the module.
API parameter checks are added to ensure that the correct parameters are passed to the module. These checks are useful during development phase, but they might be redundant when the application is finalized. Disabling these checks might improve performance.
Description | Value |
---|---|
Enable API parameters check | 0 |
Disable API parameters check | 1 |
Dependencies | None |
Disables debug tracing in the module. To enable tracing, this flag must be set to 0 and ENABLE_DEBUG_LOG_SUPPORT must be set to 1.
Description | Value |
---|---|
Enable debug trace | 0 |
Disable debug trace | 1 |
Dependencies | ENABLE_DEBUG_LOG_SUPPORT |