#include <ctype.h>
#include "core/net.h"
#include "sntp/sntp_client.h"
#include "sntp/sntp_client_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SNTP_TRACE_LEVEL |
Functions | |
error_t | sntpClientOpenConnection (SntpClientContext *context) |
Open UDP connection. More... | |
void | sntpClientCloseConnection (SntpClientContext *context) |
Close UDP connection. More... | |
error_t | sntpClientSendRequest (SntpClientContext *context) |
Send request to the NTP server. More... | |
error_t | sntpClientReceiveResponse (SntpClientContext *context) |
Wait for NTP server's response. More... | |
error_t | sntpClientCheckResponse (SntpClientContext *context, const IpAddr *ipAddr, uint16_t port, const uint8_t *message, size_t length) |
Check whether the NTP response is valid. More... | |
error_t | sntpClientParseResponse (SntpClientContext *context, NtpTimestamp *timestamp) |
Parse NTP server's response. More... | |
error_t | sntpClientCheckTimeout (SntpClientContext *context) |
Determine whether a timeout error has occurred. More... | |
void | sntpClientDumpMessage (const uint8_t *message, size_t length) |
Dump NTP message for debugging purpose. More... | |
void | sntpClientDumpTimestamp (const NtpTimestamp *timestamp) |
Dump NTP timestamp. More... | |
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SNTP_TRACE_LEVEL |
Definition at line 37 of file sntp_client_misc.c.
Function Documentation
◆ sntpClientCheckResponse()
error_t sntpClientCheckResponse | ( | SntpClientContext * | context, |
const IpAddr * | ipAddr, | ||
uint16_t | port, | ||
const uint8_t * | message, | ||
size_t | length | ||
) |
Check whether the NTP response is valid.
- Parameters
-
[in] context Pointer to the SNTP client context [in] ipAddr Remote IP address [in] port Remote port number [in] message Pointer to the NTP message [in] length Length of the NTP message, in bytes
- Returns
- Error code
Definition at line 249 of file sntp_client_misc.c.
◆ sntpClientCheckTimeout()
error_t sntpClientCheckTimeout | ( | SntpClientContext * | context | ) |
Determine whether a timeout error has occurred.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Error code
Definition at line 346 of file sntp_client_misc.c.
◆ sntpClientCloseConnection()
void sntpClientCloseConnection | ( | SntpClientContext * | context | ) |
Close UDP connection.
- Parameters
-
[in] context Pointer to the SNTP client context
Definition at line 85 of file sntp_client_misc.c.
◆ sntpClientDumpMessage()
void sntpClientDumpMessage | ( | const uint8_t * | message, |
size_t | length | ||
) |
Dump NTP message for debugging purpose.
- Parameters
-
[in] message Pointer to the NTP message [in] length Length of the NTP message
Definition at line 394 of file sntp_client_misc.c.
◆ sntpClientDumpTimestamp()
void sntpClientDumpTimestamp | ( | const NtpTimestamp * | timestamp | ) |
Dump NTP timestamp.
- Parameters
-
[in] timestamp Pointer to the NTP timestamp
Definition at line 478 of file sntp_client_misc.c.
◆ sntpClientOpenConnection()
error_t sntpClientOpenConnection | ( | SntpClientContext * | context | ) |
Open UDP connection.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Error code
Definition at line 56 of file sntp_client_misc.c.
◆ sntpClientParseResponse()
error_t sntpClientParseResponse | ( | SntpClientContext * | context, |
NtpTimestamp * | timestamp | ||
) |
Parse NTP server's response.
- Parameters
-
[in] context Pointer to the SNTP client context [out] timestamp Pointer to the NTP timestamp
- Returns
- Error code
Definition at line 304 of file sntp_client_misc.c.
◆ sntpClientReceiveResponse()
error_t sntpClientReceiveResponse | ( | SntpClientContext * | context | ) |
Wait for NTP server's response.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Error code
Definition at line 162 of file sntp_client_misc.c.
◆ sntpClientSendRequest()
error_t sntpClientSendRequest | ( | SntpClientContext * | context | ) |
Send request to the NTP server.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Error code
Definition at line 103 of file sntp_client_misc.c.