MiMic WebServer port to LPC1768-Mini-DK2 (Alpha ver.) *On uVision4(MDK-STD), -O2 option is required to run.
Dependencies: NySDFileSystem libMiMic mbed-rtos mbed
Fork of MbedFileServer by
Revision 11:5c1608e46104, committed 2013-05-12
- Comitter:
- mio
- Date:
- Sun May 12 03:24:59 2013 +0000
- Parent:
- 10:80c05810f911
- Child:
- 12:e642e14ecb21
- Commit message:
- Alpha ver
Changed in this revision
--- a/main.cpp Sun May 05 03:32:31 2013 +0000 +++ b/main.cpp Sun May 12 03:24:59 2013 +0000 @@ -1,65 +1,72 @@ /** - * @file * This is ModLocalFileSystem sample program. + * MbedFilrServer , LPC1768-MiniDK2 Port + * + * https://mbed.org/users/nyatla/code/libMiMic/ * - * <pre> - * 1. Compile this program and write to your mbed. - * 2. Write files for testing to mbed disk. - * 2. Access via web browser to http://192.168.0.39/local/<filename> - * 3. You can see <filename> file on browser. - * </pre> + * *On CodeRed(LPCXpresso) to build, + * Must Add -DTOOLCHAIN_CR_ARM project setting of C++ Compiler for "WORDS_STACK_SIZE" in cmsis_os.h + * Must create your own mbed-rtos/rtx/LPC1768/HAL_CM3.c routine on RTX */ + #include "mbed.h" #include "SDFileSystem.h" #include "mimic.h" #include "utils/PlatformInfo.h" -DigitalOut mbedled(LED1); -DigitalOut lpcxled(P0_22); + +#define URL_HANDLE 1 /* if you use TEST URL HANDLER */ + +DigitalOut LED_1(P3_25),LED_2(P3_26); +Serial pc(P0_2,P0_3) ; /** - * local filesystem support. + * sd filesystem support. */ -LocalFileSystem2 lf("local"); -SDFileSystem sd(p5, p6, p7, p8,"sd"); -unsigned int p; +SDFileSystem sd(P1_24, P1_23, P1_20, P1_21,"sd"); +unsigned int p = 0; // LED TOGGLE COUNTER + /** * MiMic RemoteMCU httpd.<br/> * Number of simultaneous connections:4 * <p>Service list</p> * <pre> - * /local/ - mbed LocalFileSystem + * /sd/ - mbed LocalFileSystem + * /**** - URL Handler for test * </pre> */ class FsHttpd:public MiMic::Httpd { private: - ModLocalFileSystem modlocal; + ModUrl modurl; //basic URL parser ModLocalFileSystem modsd; public: FsHttpd():Httpd(80) { //bind local file system path to /local/* - modlocal.setParam("local"); modsd.setParam("sd"); } virtual void onRequest(HttpdConnection& i_connection) { p++; - switch(PlatformInfo::getPlatformType()){ - case PlatformInfo::PF_MBED: - mbedled = p%2; - break; - case PlatformInfo::PF_LPCXPRESSO: - lpcxled = p%2; - break; - } - //try to ModLocalFileSystem - if(this->modlocal.execute(i_connection)){ - return; - } + LED_1 = p%2; + //try to ModLocalFileSystem(SD) if(this->modsd.execute(i_connection)){ return; } + +#ifdef URL_HANDLE + // URL + char url[32]; + int method; + if(this->modurl.execute(i_connection,url,32,&method)){ + //send 200 OK and requested URL + i_connection.sendHeader(200,"text/html",NULL); + i_connection.sendBodyF("Your Request No is [%d] , path is %s.",p,url); + pc.printf("%s\r\n",url) ; + return; + } +#endif + //Otherwise, Send simple top index page. i_connection.sendHeader(200,"text/html",NULL); if(i_connection.isMethodType(Http::MT_GET)){ @@ -68,10 +75,9 @@ "<html lang=\"ja\">" "<head></head>" "<body>" - "<h1>This is MiMic Server!</h1>" + "<h1>This is MiMic Server : Mini1768DK2 Port.</h1>" "<hr/>" "<ul>" - "<li><a href=\"/local/\">mbed Local Filesystem</a></li>" "<li><a href=\"/sd/\">SDCard</a></li>" "</ul></body>"); } @@ -82,11 +88,18 @@ { NetConfig cfg; //create network configulation Net net(cfg); //create a net instance. - //try to override setting by local file. - if(!cfg.loadFromFile("/local/mimic.cfg")){ - wait_ms(1000); - cfg.loadFromFile("/sd/mimic.cfg"); - } + pc.baud(9600) ; // serial port for debug + + //try to override setting by SD file. + if (cfg.loadFromFile("/sd/mimic.cfg")) { + pc.printf("Setting is Overridden by /sd/mimic.cfg\r\n") ; + } else { + pc.printf("MY ADDR is 192.168.1.240\r\n") ; + cfg.setIpAddr(192,168,1,240) ; + cfg.setGateway(192,168,1,255) ; + cfg.setNetMask(255,255,255,0) ; + } + FsHttpd httpd; //create a httpd instance. httpd.loop(); //start httpd loop. return 0;
--- a/mbed-rtos.lib Sun May 05 03:32:31 2013 +0000 +++ b/mbed-rtos.lib Sun May 12 03:24:59 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782 +http://mbed.org/users/mbed_official/code/mbed-rtos/#db1fc233faa9
--- a/mbed.bld Sun May 05 03:32:31 2013 +0000 +++ b/mbed.bld Sun May 12 03:24:59 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file