To Be Determined. Not yet support RTC of HAL for W7500. Programs using NTPClient as like SMTP have some bug. We will update RTC APIs for HAL. UDP, Network Time Protocol, UDP Clinet
Dependencies: NTPClient WIZnetInterface mbed
Fork of NTPClient_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "NTPClient.h" 00004 00005 EthernetInterface eth; 00006 NTPClient ntp; 00007 00008 int main() 00009 { 00010 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03}; 00011 00012 //eth.init(); //Use DHCP 00013 eth.init(mac_addr); //Use DHCP 00014 00015 eth.connect(); 00016 00017 printf("Trying to update time...\r\n"); 00018 //if (ntp.setTime("0.pool.ntp.org") == 0) 00019 if (ntp.setTime("jp.pool.ntp.org") == 0) 00020 { 00021 printf("Set time successfully\r\n"); 00022 time_t ctTime; 00023 ctTime = time(NULL); 00024 printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); 00025 } 00026 else 00027 { 00028 printf("Error\r\n"); 00029 } 00030 00031 eth.disconnect(); 00032 00033 while(1) { 00034 } 00035 }
Generated on Wed Jul 20 2022 04:05:15 by 1.7.2