Remote Procedure Call (RPC) over Websockets (uses MbedJSONValue)
Dependents: RPC_mbed_client RPC_Wifly_HelloWorld RPC_Ethernet_HelloWorld
Diff: MbedJSONRpc.cpp
- Revision:
- 2:af408b5cae75
- Parent:
- 0:a53d1c86196c
- Child:
- 7:067cb01b491e
diff -r 7b7230760e0c -r af408b5cae75 MbedJSONRpc.cpp --- a/MbedJSONRpc.cpp Thu Sep 22 10:20:52 2011 +0000 +++ b/MbedJSONRpc.cpp Thu Sep 22 10:38:50 2011 +0000 @@ -1,12 +1,12 @@ #include "MbedJSONRpc.h" -RPC_TYPE MbedJSONRpc::call(char * fn, char * dest, MbedRpcValue& val, MbedRpcValue& resp) { +RPC_TYPE MbedJSONRpc::call(char * fn, char * dest, MbedJSONValue& val, MbedJSONValue& resp) { char json[150]; RPC_TYPE t; string str = val.serialize(); int id = rand() % 100; - MbedRpcValue tmp; + MbedJSONValue tmp; sprintf(json, (const char *)MSG_CALL, my_id, dest, id, fn, str.c_str()); @@ -18,7 +18,7 @@ return CALL_OK; } -RPC_TYPE MbedJSONRpc::waitAnswer(MbedRpcValue& v, int id, char * json) { +RPC_TYPE MbedJSONRpc::waitAnswer(MbedJSONValue& v, int id, char * json) { Timer tmr; tmr.start(); @@ -57,7 +57,7 @@ void MbedJSONRpc::checkMethods(char * dest) { char json[150]; char name[5]; - MbedRpcValue tmp; + MbedJSONValue tmp; int id = rand() % 100; sprintf(json, (const char *)MSG_INFO_METHODS, my_id, dest, id); @@ -71,7 +71,7 @@ printf("\r\n"); } -RPC_TYPE MbedJSONRpc::decodeMsg(MbedRpcValue& v, int id) { +RPC_TYPE MbedJSONRpc::decodeMsg(MbedJSONValue& v, int id) { if (v.hasMember("id_msg")) if (v["id_msg"].get<int>() != -1 && id != v["id_msg"].get<int>()) { @@ -108,10 +108,10 @@ } -RPC_TYPE MbedJSONRpc::registerMethod(const char * public_name, void (*fn)(MbedRpcValue& val, MbedRpcValue& res) ) { +RPC_TYPE MbedJSONRpc::registerMethod(const char * public_name, void (*fn)(MbedJSONValue& val, MbedJSONValue& res) ) { char json[100]; int id = rand() % 100; - MbedRpcValue tmp; + MbedJSONValue tmp; RPC_TYPE t; sprintf(json, (const char *)MSG_REGISTER, my_id, id, public_name); @@ -130,7 +130,7 @@ void MbedJSONRpc::work() { char json_recv[150]; DigitalOut led4(LED4); - MbedRpcValue v, r; + MbedJSONValue v, r; int i = -1; while (1) { wait(0.2);