Dependencies:   EthernetNetIf mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTPClientExample.cpp Source File

HTTPClientExample.cpp

00001 #include "mbed.h"
00002 #include "EthernetNetIf.h"
00003 #include "HTTPClient.h"
00004 
00005 EthernetNetIf eth;
00006 HTTPClient http;
00007   
00008 int main() {
00009 
00010   printf("Setting up...\n");
00011   EthernetErr ethErr = eth.setup();
00012   if(ethErr)
00013   {
00014     printf("Error %d in setup.\n", ethErr);
00015     return -1;
00016   }
00017   printf("Setup OK\n");
00018   
00019   HTTPText txt;
00020   
00021   HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt);
00022   if(r==HTTP_OK)
00023   {
00024     printf("Result :\"%s\"\n", txt.gets()); 
00025   }
00026   else
00027   {
00028     printf("Error %d\n", r);
00029   }
00030   
00031   while(1)
00032   {
00033   
00034   }
00035   
00036   return 0;
00037   
00038 }