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

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 12.9: mbed HTTP client test
00002                                                    */
00003 #include "mbed.h"
00004 #include "EthernetNetIf.h"
00005 #include "HTTPClient.h"
00006 EthernetNetIf eth(
00007   IpAddr(192,168,0,101),    //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 HTTPClient http;
00013 HTTPText txt;
00014 Serial pc (USBTX,USBRX) ;   
00015 int main() {
00016   pc.printf("\r\nSetting up network connection...\n\r");
00017   eth.setup();
00018   pc.printf("\r\nSetup OK. Queerying data...\r\n"); 
00019   // attempt to access file ‘mbedclienttest.txt’ through the internet...
00020   HTTPResult r=http.get("http://www.rt60.co.uk/mbed/mbedclienttest.txt", &txt);
00021   pc.printf("Result :\n\r\"%s\"\n\r", txt.gets());    
00022 }