Nenad Jovicic / Mbed 2 deprecated PMK_HTTPClientExample

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 /*EthernetNetIf eth(
00007   IpAddr(192,168,0,110), //IP Address
00008   IpAddr(255,255,255,0), //Network Mask
00009   IpAddr(192,168,0,1), //Gateway
00010   IpAddr(192,168,0,1)  //DNS
00011 );*/
00012 
00013 HTTPClient http;
00014   
00015 int main() {
00016 
00017   printf("Setting up...\n");
00018   EthernetErr ethErr = eth.setup();
00019   if(ethErr)
00020   {
00021     printf("Error %d in setup.\n", ethErr);
00022     return -1;
00023   }
00024   printf("Setup OK\n");
00025   
00026   HTTPText txt;
00027   
00028   HTTPResult r = http.get("http://tnt.etf.rs/~oe4irs/pmk.txt", &txt);
00029   if(r==HTTP_OK)
00030   {
00031     printf("Result :\"%s\"\n", txt.gets()); 
00032   }
00033   else
00034   {
00035     printf("Error %d\n", r);
00036   }
00037   
00038   while(1)
00039   {
00040   
00041   }
00042   
00043   return 0;
00044   
00045 }