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
Diff: main.cpp
- Revision:
- 4:6b0e7a10a395
- Parent:
- 1:2744673f6256
- Child:
- 5:6d00f26f7b59
--- a/main.cpp Fri Dec 05 11:49:51 2014 +0000 +++ b/main.cpp Fri Dec 05 11:55:42 2014 +0000 @@ -2,9 +2,7 @@ #include "EthernetInterface.h" #include "HTTPClient.h" -#define SHARED_LINK "https://www.dropbox.com/s/m856g2irwzb68uv/test.txt?dl=0" - -extern HTTPResult dropbox_get(const char *url, char *buff, int size) ; +#define SERVER_URL "https://192.168.1.12/index.html" EthernetInterface eth; HTTPClient http; @@ -12,29 +10,33 @@ int main() { - HTTPResult ret ; + int ret ; - printf("Dropbox Shared Link, Starting,...\n") ; + printf("HTTP Client, Starting,...\n") ; eth.init(); //Use DHCP while(1) { printf("Trying\n") ; - if(eth.connect() == 0)break ; + 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); - printf("Shared Link: %s\n", SHARED_LINK); - memset(recvBuff, '\0', sizeof(recvBuff)) ; - ret = dropbox_get(SHARED_LINK, recvBuff, sizeof(recvBuff)); - if (ret == HTTP_OK) { - printf("Result: %s\n", recvBuff); - } else { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + 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) { } -} +} \ No newline at end of file