Wiznet W5500 lightweight SNTPClient example, tested on Maxim MAX32630FTHR board
Dependencies: mbed W5500-Interface max32630fthr W5500-SNTPClient
Diff: main.cpp
- Revision:
- 0:31500befb6ca
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 02 20:57:14 2019 +0000 @@ -0,0 +1,32 @@ + +// Wiznet WIZ550io bytsize SNTPClient Example +// Tested using MAX32630FTHR board + +#include "mbed.h" +#include "EthernetInterface.h" +#include "SNTPClient.h" + +#include "max32630fthr.h" + //Init board and set GPIO to 3.3V logic +MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); + +EthernetInterface eth(P5_1, P5_2, P5_0, P3_0, P3_1); // MOSI, MISO, SCK, CS, RESET +SNTPClient sntp; + +int main() { + + printf("Initialise! \n\n"); + eth.init(); //Use DHCP + printf("Connecting.. \n"); + eth.connect(); + printf("IP Address is: %s\n\n", eth.getIPAddress()); + printf("Get NTP... \n\n"); + + // example NTPpool = "1.nl.pool.ntp.org" + // get seconds UTC + 1hour, enable DST and set MCU RTC + printf("Seconds since 1970 = %d\n\n", sntp.getNTP("1.nl.pool.ntp.org",1,1,1)); + time_t ctTime; + ctTime = time(NULL); + printf("RTC is set to: %s\n", ctime(&ctTime)); +} + \ No newline at end of file