Donatien Garnier / Mbed 2 deprecated HTTPClientSDCardTest

Dependencies:   EthernetNetIf mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "EthernetNetIf.h"
00004 
00005 #include "SDHCFileSystem.h"
00006 
00007 #include "HTTPClient.h"
00008 
00009 SDFileSystem sd(p5, p6, p7, p8, "sd"); //p9: SD present; p8: CS
00010 
00011 EthernetNetIf eth;
00012 HTTPClient http;
00013 
00014 int main() {
00015 
00016   printf("Setting up...\n");
00017   EthernetErr ethErr = eth.setup();
00018   if(ethErr)
00019   {
00020     printf("Error %d in setup.\n", ethErr);
00021     return -1;
00022   }
00023   printf("Setup OK\n");
00024   
00025   {
00026 
00027     HTTPFile f("/sd/m.pdf");
00028   
00029     HTTPResult r = http.get("http://mbed.org/media/press/mbed_whitepaper.pdf", &f);
00030 
00031     if(r==HTTP_OK)
00032     {
00033       printf("Result OK\n"); 
00034     }
00035     else
00036     {
00037       printf("Error %d\n", r);
00038     }
00039   }  
00040   while(1)
00041   {
00042   
00043   }
00044   
00045   return 0;
00046   
00047 }