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.
HTTPClientExample.cpp
- Committer:
- dadaista
- Date:
- 2010-07-26
- Revision:
- 0:663dd0dc4636
File content as of revision 0:663dd0dc4636:
#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
//EthernetNetIf eth;
HTTPClient http;
DigitalOut led1(LED1);
DigitalOut led2(LED4);
int main() {
printf("Setting up...\n");
EthernetNetIf eth(
IpAddr(10,0,0,20), //IP Address
IpAddr(255,0,0,0), //Network Mask
IpAddr(10,0,0,1), //Gateway
IpAddr(10,0,0,1) //DNS
);
EthernetErr ethErr = eth.setup();
if(ethErr)
{
printf("Error %d in setup.\n", ethErr);
return -1;
}
printf("Setup OK\n");
HTTPText txt;
HTTPResult r = http.get("http://10.0.0.1/", &txt);
if(r==HTTP_OK)
{
printf("GET Result :\"%s\"\n", txt.gets());
led1=1;
led2=1;
}
else
{
printf("Error %d\n", r);
led1=0;
led2=1;
}
while(1)
{
//printf("ciao");
}
return 0;
}