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.

Dependencies:   WIZnetInterface mbed

Fork of NTPClient_HelloWorld by Donatien Garnier

main.cpp

Committer:
embeddist
Date:
2015-06-15
Revision:
4:b7cbb0d0410c
Parent:
3:1914de305164

File content as of revision 4:b7cbb0d0410c:

#include "mbed.h"
#include "EthernetInterface.h"
#include "NTPClient.h"

EthernetInterface eth;
NTPClient ntp;

int main() 
{
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
    
    //eth.init(); //Use DHCP
    eth.init(mac_addr); //Use DHCP

    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());
    
    printf("Trying to update time...\r\n");
    if (ntp.setTime("jp.pool.ntp.org") == 0)
    {
      printf("Set time successfully\r\n");
      time_t ctTime;
      ctTime = time(NULL);
      printf("Time is set to (UTC): %s\r\n", ctime(&ctTime));
    }
    else
    {
      printf("Error\r\n");
    } 
   
    eth.disconnect();  

    while(1) {
    }
}