Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
Diff: mbed/jsonrpc/RpcPortIn.cpp
- Revision:
- 78:8cdb8fc7eda8
- Child:
- 85:416f8bbbdf54
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcPortIn.cpp	Mon Jun 23 04:45:57 2014 +0000
@@ -0,0 +1,47 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+    class PortInHandler :RpcHandlerBase
+    {
+    public:
+        static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//ud
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            unsigned int port;
+            int mask;
+            if(getParamUInt(mod,i_rpc,port,0)){
+                if(getParamInt(mod,i_rpc,mask,1)){
+                 	addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<PortIn>(new PortIn(portId2PortName(port),mask)));
+                }
+            }
+            return NyLPC_TBool_TRUE;
+        }
+        static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+        {
+        	//d return d
+            ModJsonRpc* mod=(ModJsonRpc*)i_param;
+            PortIn* inst=(PortIn*)getObjectBatch(mod,i_rpc);
+			if(inst!=NULL){
+				mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()));
+			}
+            return NyLPC_TBool_TRUE;
+        }
+    };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+    { "_new1"	,"ud"   ,PortInHandler::new1},
+    { "read"	,"d"	,PortInHandler::read},
+    { NULL      ,NULL   ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_PORT_IN={
+    "mbedJS","PortIn",func_table
+};
+
+
+
+}
    