sntp_client_misc.h File Reference
#include "core/net.h"
#include "sntp/sntp_client.h"

Go to the source code of this file.

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...
 

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]contextPointer to the SNTP client context
[in]ipAddrRemote IP address
[in]portRemote port number
[in]messagePointer to the NTP message
[in]lengthLength of the NTP message, in bytes
Returns
Error code

Definition at line 242 of file sntp_client_misc.c.

◆ sntpClientCheckTimeout()

error_t sntpClientCheckTimeout ( SntpClientContext context)

Determine whether a timeout error has occurred.

Parameters
[in]contextPointer to the SNTP client context
Returns
Error code

Definition at line 339 of file sntp_client_misc.c.

◆ sntpClientCloseConnection()

void sntpClientCloseConnection ( SntpClientContext context)

Close UDP connection.

Parameters
[in]contextPointer to the SNTP client context
Returns
Error code

Definition at line 86 of file sntp_client_misc.c.

◆ sntpClientDumpMessage()

void sntpClientDumpMessage ( const uint8_t *  message,
size_t  length 
)

Dump NTP message for debugging purpose.

Parameters
[in]messagePointer to the NTP message
[in]lengthLength of the NTP message

Definition at line 387 of file sntp_client_misc.c.

◆ sntpClientDumpTimestamp()

void sntpClientDumpTimestamp ( const NtpTimestamp timestamp)

Dump NTP timestamp.

Parameters
[in]timestampPointer to the NTP timestamp

Definition at line 471 of file sntp_client_misc.c.

◆ sntpClientOpenConnection()

error_t sntpClientOpenConnection ( SntpClientContext context)

Open UDP connection.

Parameters
[in]contextPointer 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]contextPointer to the SNTP client context
[out]timestampPointer to the NTP timestamp
Returns
Error code

Definition at line 297 of file sntp_client_misc.c.

◆ sntpClientReceiveResponse()

error_t sntpClientReceiveResponse ( SntpClientContext context)

Wait for NTP server's response.

Parameters
[in]contextPointer to the SNTP client context
Returns
Error code

Definition at line 163 of file sntp_client_misc.c.

◆ sntpClientSendRequest()

error_t sntpClientSendRequest ( SntpClientContext context)

Send request to the NTP server.

Parameters
[in]contextPointer to the SNTP client context
Returns
Error code

Definition at line 104 of file sntp_client_misc.c.