dropbox access

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of SimpleDropbox by wolf SSL

Committer:
thursday1024
Date:
Wed Jul 22 08:30:52 2015 +0000
Revision:
2:3b43fb225342
Parent:
0:b20eee676480
dropbox access

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thursday1024 2:3b43fb225342 1 // dropbox_access main.cpp
wolfSSL 0:b20eee676480 2 #include "mbed.h"
wolfSSL 0:b20eee676480 3 #include "EthernetInterface.h"
wolfSSL 0:b20eee676480 4 #include "HTTPClient.h"
wolfSSL 0:b20eee676480 5
thursday1024 2:3b43fb225342 6
thursday1024 2:3b43fb225342 7 //#define SHARED_LINK "https://www.dropbox.com/s/m856g2irwzb68uv/test.txt?dl=0"
thursday1024 2:3b43fb225342 8 #define SHARED_LINK "https://www.dropbox.com/s/gtard2k48f2y8yy/test.txt?dl=0"
thursday1024 2:3b43fb225342 9
wolfSSL 0:b20eee676480 10
wolfSSL 0:b20eee676480 11 extern HTTPResult dropbox_get(const char *url, char *buff, int size) ;
wolfSSL 0:b20eee676480 12
wolfSSL 0:b20eee676480 13 EthernetInterface eth;
wolfSSL 0:b20eee676480 14 HTTPClient http;
wolfSSL 0:b20eee676480 15 char recvBuff[1024*20];
wolfSSL 0:b20eee676480 16
thursday1024 2:3b43fb225342 17 int main(){
thursday1024 2:3b43fb225342 18
wolfSSL 0:b20eee676480 19 HTTPResult ret ;
thursday1024 2:3b43fb225342 20
wolfSSL 0:b20eee676480 21 eth.init(); //Use DHCP
thursday1024 2:3b43fb225342 22 printf( "Dropbox Shared Link, Starting,...\n" ) ;
wolfSSL 0:b20eee676480 23 while(1) {
wolfSSL 0:b20eee676480 24 if(eth.connect() == 0)break ;
wolfSSL 0:b20eee676480 25 printf("Retry\n") ;
wolfSSL 0:b20eee676480 26 }
thursday1024 2:3b43fb225342 27 printf("HTTP Client, IP Address is %s\n", eth.getIPAddress() );
wolfSSL 0:b20eee676480 28 printf("Shared Link: %s\n", SHARED_LINK);
thursday1024 2:3b43fb225342 29
thursday1024 2:3b43fb225342 30 memset( recvBuff, '\0', sizeof(recvBuff) );
thursday1024 2:3b43fb225342 31 ret = dropbox_get( SHARED_LINK, recvBuff, sizeof(recvBuff) );
wolfSSL 0:b20eee676480 32 if (ret == HTTP_OK) {
thursday1024 2:3b43fb225342 33 printf( "Result: %s\n", recvBuff );
wolfSSL 0:b20eee676480 34 } else {
thursday1024 2:3b43fb225342 35 printf( "Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode() );
wolfSSL 0:b20eee676480 36 }
wolfSSL 0:b20eee676480 37 eth.disconnect();
wolfSSL 0:b20eee676480 38
wolfSSL 0:b20eee676480 39 while(1) {
wolfSSL 0:b20eee676480 40 }
wolfSSL 0:b20eee676480 41 }