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-src
Fork of GR-peach-HTTPSClient by
Diff: main.cpp
- Revision:
- 1:2744673f6256
- Parent:
- 0:83075160de0e
--- a/main.cpp Wed Dec 03 06:10:26 2014 +0000
+++ b/main.cpp Fri Dec 05 11:42:02 2014 +0000
@@ -2,7 +2,9 @@
#include "EthernetInterface.h"
#include "HTTPClient.h"
-#define SERVER_URL "https://192.168.1.12/index.html"
+#define SHARED_LINK "https://www.dropbox.com/s/m856g2irwzb68uv/test.txt?dl=0"
+
+extern HTTPResult dropbox_get(const char *url, char *buff, int size) ;
EthernetInterface eth;
HTTPClient http;
@@ -10,29 +12,25 @@
int main()
{
- int ret ;
+ HTTPResult ret ;
- printf("HTTP Client, Starting,...\n") ;
+ printf("Dropbox Shared Link, Starting,...\n") ;
eth.init(); //Use DHCP
while(1) {
printf("Trying\n") ;
- ret = eth.connect();
- if(ret == 0)break ;
+ if(eth.connect() == 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) ;
+ 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());
}
eth.disconnect();
