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

Dependencies:   mbed

Committer:
robt
Date:
Sun Jun 16 15:32:31 2013 +0000
Revision:
0:6dbcb68a18e4
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:6dbcb68a18e4 1 /* Program Example 12.9: mbed HTTP client test
robt 0:6dbcb68a18e4 2 */
robt 0:6dbcb68a18e4 3 #include "mbed.h"
robt 0:6dbcb68a18e4 4 #include "EthernetNetIf.h"
robt 0:6dbcb68a18e4 5 #include "HTTPClient.h"
robt 0:6dbcb68a18e4 6 EthernetNetIf eth(
robt 0:6dbcb68a18e4 7 IpAddr(192,168,0,101), //IP Address
robt 0:6dbcb68a18e4 8 IpAddr(255,255,255,0), //Network Mask
robt 0:6dbcb68a18e4 9 IpAddr(192,168,0,1), //Gateway
robt 0:6dbcb68a18e4 10 IpAddr(192,168,0,1) //DNS
robt 0:6dbcb68a18e4 11 );
robt 0:6dbcb68a18e4 12 HTTPClient http;
robt 0:6dbcb68a18e4 13 HTTPText txt;
robt 0:6dbcb68a18e4 14 Serial pc (USBTX,USBRX) ;
robt 0:6dbcb68a18e4 15 int main() {
robt 0:6dbcb68a18e4 16 pc.printf("\r\nSetting up network connection...\n\r");
robt 0:6dbcb68a18e4 17 eth.setup();
robt 0:6dbcb68a18e4 18 pc.printf("\r\nSetup OK. Queerying data...\r\n");
robt 0:6dbcb68a18e4 19 // attempt to access file ‘mbedclienttest.txt’ through the internet...
robt 0:6dbcb68a18e4 20 HTTPResult r=http.get("http://www.rt60.co.uk/mbed/mbedclienttest.txt", &txt);
robt 0:6dbcb68a18e4 21 pc.printf("Result :\n\r\"%s\"\n\r", txt.gets());
robt 0:6dbcb68a18e4 22 }