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 Donatien Garnier

main.cpp

Committer:
donatien
Date:
2012-08-05
Revision:
1:d263603373ac
Parent:
0:0e0debc29569
Child:
2:bf7dc5f5bca9

File content as of revision 1:d263603373ac:

#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"

EthernetInterface eth;
HTTPClient http;
char str[512];

int main() 
{
    eth.init(); //Use DHCP

    eth.connect();
    
    //GET data
    printf("Trying to fetch page...\n");
    int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
    if (!ret)
    {
      printf("Page fetched successfully - read %d characters\n", strlen(str));
      printf("Result: %s\n", str);
    }
    else
    {
      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
    }
    
    //POST data
    HTTPMap map;
    HTTPText text(str, 512);
    map.put("Hello", "World");
    map.put("test", "1234");
    printf("Trying to post data...\n");
    ret = http.post("http://httpbin.org/post", map, &text);
    if (!ret)
    {
      printf("Executed POST successfully - read %d characters\n", strlen(str));
      printf("Result: %s\n", str);
    }
    else
    {
      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
    }
    
    eth.disconnect();  

    while(1) {
    }
}