The Library of SNTP Client for W5500 SNTP is short for Simple Network Time Protocol.

Dependents:   SNTP_Ethernet_W5500 SNTP_Ethernet_W5500 SNTP_SHT15_WIZwizki-W7500 Nucleo_SNTP_Ethernet_W5500 ... more

Embed: (wiki syntax)

« Back to documentation index

SNTPClient Class Reference

SNTPClient Class Reference

SNTPClient client Class. More...

#include <SNTPClient.h>

Public Member Functions

 SNTPClient (char *url, uint8_t time_zone)
bool connect ()
 Connect to the SNTPClient url.
bool getTime (datetime *time)
 Read a SNTPClient message.
bool close ()
 Close the SNTPClient connection.

Detailed Description

SNTPClient client Class.

Example (ethernet network):

 #include "mbed.h"
 #include "EthernetInterface.h"
 #include "SNTPClient.h"

 int main() {
    EthernetInterface eth;
    eth.init(); //Use DHCP
    printf("IP Address is %s\n\r", eth.getIPAddress());
    SNTPClient ws("ws://");
    while (1) {
        int res = ws.send("SNTPClient Hello World!");

        if ( {
            printf("rcv: %s\r\n", recv);


Definition at line 113 of file SNTPClient.h.

Constructor & Destructor Documentation

SNTPClient ( char *  url,
uint8_t  time_zone 


urlThe SNTPClient host

Definition at line 19 of file SNTPClient.cpp.

Member Function Documentation

bool close (  )

Close the SNTPClient connection.

true if the connection has been closed, false otherwise

Definition at line 85 of file SNTPClient.cpp.

bool connect (  )

Connect to the SNTPClient url.

true if the connection is established, false otherwise

Definition at line 28 of file SNTPClient.cpp.

bool getTime ( datetime *  time )

Read a SNTPClient message.

messagepointer to the string to be read (null if drop frame)
true if a SNTPClient frame has been read

Definition at line 62 of file SNTPClient.cpp.