Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetNetIf mbed
HTTPClientExample.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPClient.h" 00004 #include "I2CTextLCD.h" 00005 00006 // EthernetNetIf eth; // use this line if DHCP needed, or - 00007 // /* 00008 EthernetNetIf eth( 00009 IpAddr(192,168,100,55), //IP Address 00010 IpAddr(255,255,255,0), //Network Mask 00011 IpAddr(192,168,100,1), //Gateway 00012 IpAddr(192,168,1,254) //DNS 00013 ); 00014 // */ 00015 HTTPClient client; 00016 I2CTextLCD lcd(p9, p10, 0x70); // sda scl, address 00017 00018 Serial pc(USBTX, USBRX); 00019 DigitalOut led1(LED1); 00020 DigitalOut ConnectLED (LED2); 00021 DigitalOut GetLED (LED4); 00022 static const int ClientTimeoutMs = 28000; 00023 00024 int main() { 00025 pc.baud (115400); 00026 lcd.cls(); 00027 wait(0.1); 00028 lcd.locate(0,0); 00029 lcd.printf("Setting up..."); 00030 EthernetErr ethErr = eth.setup(); 00031 if(ethErr) 00032 { 00033 lcd.printf("Error %d in setup.\n", ethErr); 00034 return -1; 00035 } 00036 lcd.locate(0,0); 00037 lcd.printf("\r\nSetup OK\r\n"); 00038 HTTPText txt("text/html", 4096); 00039 client.setTimeout(ClientTimeoutMs); 00040 for (int x = 10; x>0; x--) 00041 { 00042 HTTPResult r = client.get("http://192.168.100.1/install/?page=installStatusData", &txt); 00043 GetLED = 1; 00044 lcd.printf("R:\"%s\"\n", txt.gets()); 00045 lcd.printf("Error %d %4d\n", r, client.getHTTPResponseCode()); 00046 wait (3); 00047 } 00048 }
Generated on Sun Jul 24 2022 00:20:09 by
1.7.2