shinichi satoh / Mbed 2 deprecated dropbox_access

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of SimpleDropbox by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // dropbox_access main.cpp
00002 #include "mbed.h"
00003 #include "EthernetInterface.h"
00004 #include "HTTPClient.h"
00005 
00006 
00007 //#define SHARED_LINK "https://www.dropbox.com/s/m856g2irwzb68uv/test.txt?dl=0"
00008 #define SHARED_LINK "https://www.dropbox.com/s/gtard2k48f2y8yy/test.txt?dl=0"
00009 
00010 
00011 extern HTTPResult dropbox_get(const char *url, char *buff, int size) ;
00012 
00013 EthernetInterface eth;
00014 HTTPClient http;
00015 char recvBuff[1024*20];
00016 
00017 int main(){
00018     
00019     HTTPResult ret ;
00020     
00021     eth.init(); //Use DHCP
00022     printf( "Dropbox Shared Link, Starting,...\n" ) ;
00023     while(1) {
00024         if(eth.connect() == 0)break ;
00025         printf("Retry\n") ;
00026     }
00027     printf("HTTP Client, IP Address is %s\n", eth.getIPAddress() );
00028     printf("Shared Link: %s\n", SHARED_LINK);
00029     
00030     memset( recvBuff, '\0', sizeof(recvBuff) );
00031     ret = dropbox_get( SHARED_LINK, recvBuff, sizeof(recvBuff) );
00032     if (ret == HTTP_OK) {
00033         printf( "Result: %s\n", recvBuff );
00034     } else {
00035         printf( "Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode() );
00036     }
00037     eth.disconnect();
00038 
00039     while(1) {
00040     }
00041 }