This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Fork of libMiMic by Ryo Iizuka

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Tue Jun 24 14:34:39 2014 +0000
Parent:
80:b94c3dec9848
Child:
82:03c645af0bb1
Commit message:
???????????????JsonRPC??????????; LPC4088/LPC1768??????????;

Changed in this revision

core/include/NyLPC_config.h Show annotated file Show diff for this revision Revisions of this file
mbed/HttpdConnection.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/HttpdConnection.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModJsonRpc.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModJsonRpc.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModWebSocket.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModWebSocket.h Show annotated file Show diff for this revision Revisions of this file
--- a/core/include/NyLPC_config.h	Tue Jun 24 09:42:07 2014 +0000
+++ b/core/include/NyLPC_config.h	Tue Jun 24 14:34:39 2014 +0000
@@ -120,7 +120,9 @@
 //デバック情報
 ////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define NyLPC_cHttpdThread_SIZE_OF_THREAD_STACK 2048
+#define NyLPC_cHttpdThread_SIZE_OF_THREAD_STACK (1024+256)
+# define NyLPC_cHttpd_MAX_PERSISTENT_CONNECTION 1
+
 /*固有プラットフォーム設定はここに記述します。*/
 #undef NyLPC_ARCH
 #define NyLPC_ARCH NyLPC_ARCH_MBEDRTOS
--- a/mbed/HttpdConnection.cpp	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/HttpdConnection.cpp	Tue Jun 24 14:34:39 2014 +0000
@@ -61,4 +61,8 @@
     {
         NyLPC_cHttpdConnection_unlock(this->_ref_inst);
     }
+    void HttpdConnection::breakPersistentConnection()
+    {
+        NyLPC_cHttpdConnection_setConnectionMode(this->_ref_inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
+    }
 }
\ No newline at end of file
--- a/mbed/HttpdConnection.h	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/HttpdConnection.h	Tue Jun 24 14:34:39 2014 +0000
@@ -67,5 +67,10 @@
          * The function releases the httpd lock.
          */
         void unlockHttpd();
+        /**
+         * The function breaks the persist connection if it enabled.
+         */
+        void breakPersistentConnection();
+
     };
 }
\ No newline at end of file
--- a/mbed/mod/ModJsonRpc.cpp	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/mod/ModJsonRpc.cpp	Tue Jun 24 14:34:39 2014 +0000
@@ -44,17 +44,23 @@
         ModBaseClass::setParam(i_path);
         this->_rpc_table=i_rpc_table;
     }
-
+    bool ModJsonRpc::isStarted(){
+        return this->_mod!=NULL;
+    }
     bool ModJsonRpc::execute(HttpdConnection& i_connection)
     {
+        i_connection.lockHttpd();
         if(this->_mod!=NULL){
+            i_connection.unlockHttpd();
             return false;
         }
         this->_mod=(NyLPC_TcModJsonRpc_t*)malloc(sizeof(NyLPC_TcModJsonRpc_t));
+        i_connection.unlockHttpd();
+    
         if(this->_mod==NULL){
             return false;
         }
-        
+
         //initialize websocket
         NyLPC_cModJsonRpc_initialize(this->_mod,this->_path,this->_rpc_table);        
         if(NyLPC_cModJsonRpc_canHandle(this->_mod,i_connection._ref_inst)){
@@ -66,7 +72,9 @@
         }
         NyLPC_cModJsonRpc_finalize(this->_mod);
         free(this->_mod);
+        i_connection.lockHttpd();
         this->_mod=NULL;
+        i_connection.unlockHttpd();
         return false;
     }
 
--- a/mbed/mod/ModJsonRpc.h	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/mod/ModJsonRpc.h	Tue Jun 24 14:34:39 2014 +0000
@@ -59,6 +59,7 @@
          */
         ModJsonRpc(const char* i_path,const struct NyLPC_TJsonRpcClassDef** i_rpc_table);
         virtual ~ModJsonRpc();
+        bool isStarted();
         void setParam(const char* i_path,const struct NyLPC_TJsonRpcClassDef** i_rpc_table);        
         /**
          * This function prepares Json rpc loop with websocket negotiation.
--- a/mbed/mod/ModWebSocket.cpp	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/mod/ModWebSocket.cpp	Tue Jun 24 14:34:39 2014 +0000
@@ -20,6 +20,10 @@
             this->_mod=NULL;
         }
     }
+    bool ModWebSocket::isStarted(){
+        return this->_mod!=NULL;
+    }
+    
     void ModWebSocket::setParam(const char* i_path)
     {
         ModBaseClass::setParam(i_path);
@@ -27,10 +31,14 @@
     
     bool ModWebSocket::execute(HttpdConnection& i_connection)
     {
+        i_connection.lockHttpd();
         if(this->_mod!=NULL){
+            i_connection.unlockHttpd();
             return false;
         }
         this->_mod=(NyLPC_TcModWebSocket_t*)malloc(sizeof(NyLPC_TcModWebSocket_t));
+        i_connection.unlockHttpd();
+
         if(this->_mod==NULL){
             return false;
         }
@@ -43,7 +51,9 @@
         }
         NyLPC_cModWebSocket_finalize(this->_mod);
         free(this->_mod);
+        i_connection.lockHttpd();
         this->_mod=NULL;
+        i_connection.unlockHttpd();
         return false;
     }
     bool ModWebSocket::write(const void* i_tx_buf,int i_tx_size)
@@ -77,6 +87,9 @@
     }
     bool ModWebSocket::canRead()
     {
+        if(this->_mod==NULL){
+            return false;
+        }
         return NyLPC_cModWebSocket_canRead(this->_mod)?true:false;
     }
 
--- a/mbed/mod/ModWebSocket.h	Tue Jun 24 09:42:07 2014 +0000
+++ b/mbed/mod/ModWebSocket.h	Tue Jun 24 14:34:39 2014 +0000
@@ -27,7 +27,8 @@
         ModWebSocket();
         ModWebSocket(const char* i_path);
         virtual ~ModWebSocket();
-        void setParam(const char* i_path);        
+        void setParam(const char* i_path);
+        bool isStarted();
         /**
          * This function executes websocket negotiation to the current connection. 
          * Should be handle websocket session if function successful.