USB file system over internet
Dependencies: EthernetNetIfamr FatFileSystemCpp HTTPServer mbed
Fork of MSCUsbHost by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPServer.h" 00004 #include "MSCFileSystem.h" 00005 00006 #define FSNAME "msc" 00007 MSCFileSystem msc(FSNAME); 00008 00009 DigitalOut led1(LED1, "led1"); 00010 EthernetNetIf eth; 00011 HTTPServer svr; 00012 00013 int main() { 00014 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 FSHandler::mount("/msc", "/files"); //Mount /webfs path on /files web path 00026 // FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path 00027 FSHandler::mount("/msc", "/"); //Mount /webfs path on web root path 00028 FSHandler::mount("/msc", "/"); //Mount /webfs path on web root path 00029 00030 svr.addHandler<SimpleHandler>("/hello"); 00031 svr.addHandler<RPCHandler>("/rpc"); 00032 svr.addHandler<FSHandler>("/files"); 00033 svr.addHandler<FSHandler>("/"); //Default handler 00034 //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm 00035 00036 svr.bind(80); 00037 00038 printf("Listening...\n"); 00039 00040 Timer tm; 00041 tm.start(); 00042 //Listen indefinitely 00043 while(true) 00044 { 00045 Net::poll(); 00046 if(tm.read()>.5) 00047 { 00048 led1=!led1; //Show that we are alive 00049 tm.start(); 00050 } 00051 } 00052 00053 return 0; 00054 00055 } 00056 00057 00058 00059 00060 00061 00062 00063 00064
Generated on Wed Jul 13 2022 01:38:34 by 1.7.2