Code snipet

Dependencies:   NySDFileSystem libMiMic mbed-rtos mbed

Fork of AsyncHttpdSample by Ryo Iizuka

Revision:
10:8a9023e05971
Parent:
9:c6427be12f0d
diff -r c6427be12f0d -r 8a9023e05971 main.cpp
--- a/main.cpp	Sat Nov 16 01:25:37 2013 +0000
+++ b/main.cpp	Sat Nov 16 04:31:21 2013 +0000
@@ -1,66 +1,24 @@
 #include "mimic.h"
 #include "rtos.h"
-/**
- * @file
- * This program is a sample which starts httpd by a subtask.
- * The value counted up by a main thread is returned by Httpd of a subtask.
- */
- 
- 
-static unsigned int counter=0;
-
-
-LocalFileSystem2 lf("local");
-class AsyncHttpd:public MiMic::Httpd
+DigitalOut led1(LED1);
+int taskHandler(void* i_param)
 {
-private:
-    ModUrl modurl; //basic URL parser
-public:
-    AsyncHttpd(NetConfig& i_cfg):Httpd(i_cfg.getHttpPort())
-    {
+    int i=0;
+    for(;;){
+        //LEDBLINK
+        led1=(i++)%2;
+        Thread::wait(1000);
     }
-    virtual void onRequest(HttpdConnection& i_connection)
-    {
-        char url[32];
-        int method;
-        unsigned int v;
-        i_connection.lockHttpd();
-        v=counter;
-        i_connection.unlockHttpd();
-        
-
-        //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);
-            //show current counter value.
-            i_connection.sendBodyF(
-                "<html><body><h1>Asynchronous test</h1><div>Counter: %u</body></html>",v);
-            return;
-        }
-        
-        return;
-    }
-};
-
-
-NetConfig cfg; //create network configulation
+//    return 0;
+}
 int main()
 {
-    Net net;  //create a net instance.
-
-    //try to override setting by local file.
-    cfg.loadFromFile("/local/mimic.cfg");
-    
-    AsyncHttpd httpd(cfg); //create a httpd instance.
-    net.start(cfg);
-    httpd.loopTask();  //start httpd loop with new task
+    NyLPC_TcThread_t* th=(NyLPC_TcThread_t*)malloc(sizeof(NyLPC_TcThread_t));
+    NyLPC_cThread_initialize(th,256,NyLPC_TcThread_PRIORITY_IDLE);
+    NyLPC_cThread_start(th,taskHandler,NULL);
     for(;;){
-        httpd.lock();//prepare to access shared resource
-        counter++;
-        httpd.unlock();//release a lock.
         Thread::wait(1000);
     }
-    return 0;
+ //   return 0;
 }
  
\ No newline at end of file