This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
RpcAnalogIn.cpp
00001 #include "RpcHandlerBase.h" 00002 namespace MiMic 00003 { 00004 class AnalogInHandler :RpcHandlerBase 00005 { 00006 public: 00007 static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00008 { 00009 //u 00010 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00011 PinName pin; 00012 if(getParamsAsPin(mod,i_rpc,&pin,1)){ 00013 addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<AnalogIn>(new AnalogIn(pin))); 00014 } 00015 return NyLPC_TBool_TRUE; 00016 } 00017 static NyLPC_TBool read_u16(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00018 { 00019 //d return d 00020 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00021 AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc); 00022 if(inst!=NULL){ 00023 int v=inst->read_u16(); 00024 mod->putResult(i_rpc->method.id,"%d",v); 00025 } 00026 return NyLPC_TBool_TRUE; 00027 } 00028 /** 10000倍したread()の値を返す*/ 00029 static NyLPC_TBool read_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) 00030 { 00031 //d return d 00032 ModJsonRpc* mod=((ModJsonRpc::TcJsonRpcEx_t*)i_param)->cppmod_ptr; 00033 AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc); 00034 if(inst!=NULL){ 00035 mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()*10000)); 00036 } 00037 return NyLPC_TBool_TRUE; 00038 } 00039 }; 00040 00041 00042 00043 const static struct NyLPC_TJsonRpcMethodDef func_table[]= 00044 { 00045 { "_new1" ,"u" ,AnalogInHandler::new1}, 00046 { "read_u16" ,"d" ,AnalogInHandler::read_u16}, 00047 { "read_fx" ,"d" ,AnalogInHandler::read_fx}, 00048 { NULL ,NULL ,NULL} 00049 }; 00050 00051 const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_ANALOG_IN={ 00052 "mbedJS","AnalogIn",func_table 00053 }; 00054 00055 00056 00057 }
Generated on Tue Jul 12 2022 15:46:17 by 1.7.2