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)
 Constructor.
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
    eth.connect();
    printf("IP Address is %s\n\r", eth.getIPAddress());
   
    SNTPClient ws("ws://sockets.mbed.org:443/ws/demo/rw");
    ws.connect();
   
    while (1) {
        int res = ws.send("SNTPClient Hello World!");

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

        wait(0.1);
    }
 }

Definition at line 113 of file SNTPClient.h.


Constructor & Destructor Documentation

SNTPClient ( char *  url,
uint8_t  time_zone 
)

Constructor.

Parameters:
urlThe SNTPClient host

Definition at line 19 of file SNTPClient.cpp.


Member Function Documentation

bool close (  )

Close the SNTPClient connection.

Returns:
true if the connection has been closed, false otherwise

Definition at line 85 of file SNTPClient.cpp.

bool connect (  )

Connect to the SNTPClient url.

Returns:
true if the connection is established, false otherwise

Definition at line 28 of file SNTPClient.cpp.

bool getTime ( datetime *  time )

Read a SNTPClient message.

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

Definition at line 62 of file SNTPClient.cpp.