by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

main.cpp

Committer:
robt
Date:
2013-06-16
Revision:
0:6dbcb68a18e4

File content as of revision 0:6dbcb68a18e4:

/* Program Example 12.9: mbed HTTP client test
                                                   */
#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
EthernetNetIf eth(
  IpAddr(192,168,0,101),    //IP Address
  IpAddr(255,255,255,0),    //Network Mask
  IpAddr(192,168,0,1),      //Gateway
  IpAddr(192,168,0,1)       //DNS
);
HTTPClient http;
HTTPText txt;
Serial pc (USBTX,USBRX) ;   
int main() {
  pc.printf("\r\nSetting up network connection...\n\r");
  eth.setup();
  pc.printf("\r\nSetup OK. Queerying data...\r\n"); 
  // attempt to access file ‘mbedclienttest.txt’ through the internet...
  HTTPResult r=http.get("http://www.rt60.co.uk/mbed/mbedclienttest.txt", &txt);
  pc.printf("Result :\n\r\"%s\"\n\r", txt.gets());    
}