#include "mbed.h" #include "EthernetNetIf.h" #include "HTTPClient.h" EthernetNetIf eth(IpAddr(160,48,199,80),IpAddr(255,255,255,128),IpAddr(0,0,0,0),IpAddr(0,0,0,0)); HTTPClient http; void HTTPGetResult(HTTPResult result) { int iRetValue = http.getHTTPResponseCode(); printf("Result: %d \r\n", iRetValue); if(result==HTTP_OK) { printf("Result: HTTP_OK\r\n"); } else { printf("Error: %d\r\n", result); } } int main() { printf("Setting up...\r\n"); EthernetErr ethErr = eth.setup(); if(ethErr) { printf("Error %d in setup.\r\n", ethErr); return -1; } printf("Setup OK\r\n"); HTTPText txt; http.setRequestHeader("Connection", "Keep-Alive"); HTTPResult r = http.get("http://160.48.199.50/r?b=1&r=0&s=1", &txt, HTTPGetResult); //non-blocking // HTTPResult r = http.get("http://160.48.199.50/r?b=1&r=0&s=1", &txt); //blocking /* if(r==HTTP_OK) { printf("Result :\"%s\"\r\n", txt.gets()); } else { printf("Error %d\r\n", r); } */ while(1) { //printf("alive\r\n"); } return 0; }