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
RpcDigitalIn.cpp
00001 #include "RpcHandlerBase.h" 00002 00003 namespace MiMic 00004 { 00005 class DigitalInHandler :RpcHandlerBase 00006 { 00007 public: 00008 static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00009 { 00010 //u 00011 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00012 PinName pin; 00013 if(getParamsAsPin(mod,i_rpc,&pin,1)){ 00014 addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<DigitalIn>(new DigitalIn(pin))); 00015 } 00016 return NyLPC_TBool_TRUE; 00017 } 00018 static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00019 { 00020 //d return d 00021 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00022 DigitalIn* inst=(DigitalIn*)getObjectBatch(mod,i_rpc); 00023 if(inst!=NULL){ 00024 mod->putResult(i_rpc->method.id,"%d",(int)(inst->read())); 00025 } 00026 return NyLPC_TBool_TRUE; 00027 } 00028 static NyLPC_TBool mode(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00029 { 00030 //dd return void 00031 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00032 DigitalIn* inst=(DigitalIn*)getObjectBatch(mod,i_rpc); 00033 if(inst!=NULL){ 00034 int v; 00035 if(getParamInt(mod,i_rpc,v,1)){ 00036 inst->mode(pinmodeId2PinMode(v)); 00037 mod->putResult(i_rpc->method.id); 00038 } 00039 } 00040 return NyLPC_TBool_TRUE; 00041 } 00042 }; 00043 00044 00045 00046 const static struct NyLPC_TJsonRpcMethodDef func_table[]= 00047 { 00048 { "_new1" ,"u" ,DigitalInHandler::new1}, 00049 { "read" ,"d" ,DigitalInHandler::read}, 00050 { "mode" ,"dd" ,DigitalInHandler::mode}, 00051 { NULL ,NULL ,NULL} 00052 }; 00053 00054 const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_DIGITAL_IN={ 00055 "mbedJS","DigitalIn",func_table 00056 }; 00057 00058 00059 00060 }
Generated on Tue Jul 12 2022 16:22:59 by
