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: HTTPClient mbed-rtos-initial-thread-larger-stack mbed wolfSSL
main.cpp
- Committer:
- takashikojo
- Date:
- 2014-12-05
- Revision:
- 4:6b0e7a10a395
- Parent:
- 1:2744673f6256
- Child:
- 5:6d00f26f7b59
File content as of revision 4:6b0e7a10a395:
#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"
#define SERVER_URL "https://192.168.1.12/index.html"
EthernetInterface eth;
HTTPClient http;
char recvBuff[1024*20];
int main()
{
int ret ;
printf("HTTP Client, Starting,...\n") ;
eth.init(); //Use DHCP
while(1) {
printf("Trying\n") ;
ret = eth.connect();
if(ret == 0)break ;
}
printf("HTTP Client, IP Address is %s\n", eth.getIPAddress());
while(1) {
printf("\nTrying to fetch page... %s\n", SERVER_URL);
memset(recvBuff, '\0', sizeof(recvBuff)) ;
ret = http.get(SERVER_URL, recvBuff, sizeof(recvBuff),16);
if (!ret) {
printf("Result: %s\n", recvBuff);
} else {
printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
}
wait(10.0) ;
}
eth.disconnect();
while(1) {
}
}