Udp socket sample program. This program will send back the received packet.

Dependencies:   NyFileSystems libMiMic mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Tue Apr 09 09:39:09 2013 +0000
Parent:
2:28fd59d6be76
Child:
4:0a280ed0a848
Commit message:
initial version

Changed in this revision

libMiMic.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/libMiMic.lib	Sat Apr 06 15:37:21 2013 +0000
+++ b/libMiMic.lib	Tue Apr 09 09:39:09 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/nyatla/code/libMiMic/#9e06cb30603a
+http://mbed.org/users/nyatla/code/libMiMic/#b9ed86e156dd
--- a/main.cpp	Sat Apr 06 15:37:21 2013 +0000
+++ b/main.cpp	Tue Apr 09 09:39:09 2013 +0000
@@ -1,35 +1,35 @@
 #include "mimic.h"
 
 
+/**
+ * local filesystem support.
+ */
+LocalFileSystem lf("local");
 
 /**
  * MiMic RemoteMCU httpd.<br/>
  * <p>Service list</p>
  * <pre>
- * /rom/ - romfs
- * /setup/ - MiMic configulation REST API.
  * /local/ - mbed LocalFileSystem
- * /mvm/   - MiMicVM REST API
  * </pre>
  */
-
-class MiMicRemoteMcu:public MiMic::Httpd
+class LfsHttpd:public MiMic::Httpd
 {
 private:
-    ModUrl modurl; //basic URL parser
+    ModLocalFileSystem modurl; //basic URL parser
 public:
-    MiMicRemoteMcu():Httpd(80)
+    LfsHttpd():Httpd(80)
     {
+        //bind local file system path to /local/*
+        modurl.setParam("local");
     }
     virtual void onRequest(HttpdConnection& i_connection)
     {
-        char url[32];
-        int method;
         //call ModUrl module.
-        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("<html><body>Your Request path is %s.</body></html>",url);
+        if(!this->modurl.execute(i_connection)){
+            //send 430
+            i_connection.sendHeader(403,"text/html",NULL);
+            i_connection.sendBodyF("<html><body>403 Forbidden</body></html>");
             return;
         }
         return;
@@ -40,7 +40,7 @@
 {
     NetConfig cfg; //create network configulation
     Net net(cfg);  //create a net instance.
-    MiMicRemoteMcu httpd; //create a httpd instance.
+    LfsHttpd httpd; //create a httpd instance.
     httpd.loop();  //start httpd loop.
     return 0;
 }