Test Read of modem status page only. For peer review, not functional

Dependencies:   EthernetNetIf mbed

Committer:
RodColeman
Date:
Tue Sep 06 10:39:14 2011 +0000
Revision:
0:bbcccea017f0
0.01

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RodColeman 0:bbcccea017f0 1 #include "mbed.h"
RodColeman 0:bbcccea017f0 2 #include "EthernetNetIf.h"
RodColeman 0:bbcccea017f0 3 #include "HTTPClient.h"
RodColeman 0:bbcccea017f0 4 #include "I2CTextLCD.h"
RodColeman 0:bbcccea017f0 5
RodColeman 0:bbcccea017f0 6 // EthernetNetIf eth; // use this line if DHCP needed, or -
RodColeman 0:bbcccea017f0 7 // /*
RodColeman 0:bbcccea017f0 8 EthernetNetIf eth(
RodColeman 0:bbcccea017f0 9 IpAddr(192,168,100,55), //IP Address
RodColeman 0:bbcccea017f0 10 IpAddr(255,255,255,0), //Network Mask
RodColeman 0:bbcccea017f0 11 IpAddr(192,168,100,1), //Gateway
RodColeman 0:bbcccea017f0 12 IpAddr(192,168,1,254) //DNS
RodColeman 0:bbcccea017f0 13 );
RodColeman 0:bbcccea017f0 14 // */
RodColeman 0:bbcccea017f0 15 HTTPClient client;
RodColeman 0:bbcccea017f0 16 I2CTextLCD lcd(p9, p10, 0x70); // sda scl, address
RodColeman 0:bbcccea017f0 17
RodColeman 0:bbcccea017f0 18 Serial pc(USBTX, USBRX);
RodColeman 0:bbcccea017f0 19 DigitalOut led1(LED1);
RodColeman 0:bbcccea017f0 20 DigitalOut ConnectLED (LED2);
RodColeman 0:bbcccea017f0 21 DigitalOut GetLED (LED4);
RodColeman 0:bbcccea017f0 22 static const int ClientTimeoutMs = 28000;
RodColeman 0:bbcccea017f0 23
RodColeman 0:bbcccea017f0 24 int main() {
RodColeman 0:bbcccea017f0 25 pc.baud (115400);
RodColeman 0:bbcccea017f0 26 lcd.cls();
RodColeman 0:bbcccea017f0 27 wait(0.1);
RodColeman 0:bbcccea017f0 28 lcd.locate(0,0);
RodColeman 0:bbcccea017f0 29 lcd.printf("Setting up...");
RodColeman 0:bbcccea017f0 30 EthernetErr ethErr = eth.setup();
RodColeman 0:bbcccea017f0 31 if(ethErr)
RodColeman 0:bbcccea017f0 32 {
RodColeman 0:bbcccea017f0 33 lcd.printf("Error %d in setup.\n", ethErr);
RodColeman 0:bbcccea017f0 34 return -1;
RodColeman 0:bbcccea017f0 35 }
RodColeman 0:bbcccea017f0 36 lcd.locate(0,0);
RodColeman 0:bbcccea017f0 37 lcd.printf("\r\nSetup OK\r\n");
RodColeman 0:bbcccea017f0 38 HTTPText txt("text/html", 4096);
RodColeman 0:bbcccea017f0 39 client.setTimeout(ClientTimeoutMs);
RodColeman 0:bbcccea017f0 40 for (int x = 10; x>0; x--)
RodColeman 0:bbcccea017f0 41 {
RodColeman 0:bbcccea017f0 42 HTTPResult r = client.get("http://192.168.100.1/install/?page=installStatusData", &txt);
RodColeman 0:bbcccea017f0 43 GetLED = 1;
RodColeman 0:bbcccea017f0 44 lcd.printf("R:\"%s\"\n", txt.gets());
RodColeman 0:bbcccea017f0 45 lcd.printf("Error %d %4d\n", r, client.getHTTPResponseCode());
RodColeman 0:bbcccea017f0 46 wait (3);
RodColeman 0:bbcccea017f0 47 }
RodColeman 0:bbcccea017f0 48 }