Sensor with Web Server
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
RPCType.cpp@0:c385e589a779, 2014-04-08 (annotated)
- Committer:
- afilipem
- Date:
- Tue Apr 08 12:13:32 2014 +0000
- Revision:
- 0:c385e589a779
1 version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afilipem | 0:c385e589a779 | 1 | #include "mbed.h" |
afilipem | 0:c385e589a779 | 2 | #include "mbed_rpc.h" |
afilipem | 0:c385e589a779 | 3 | #include "RPCType.h" |
afilipem | 0:c385e589a779 | 4 | |
afilipem | 0:c385e589a779 | 5 | |
afilipem | 0:c385e589a779 | 6 | RPCType::RPCType(): |
afilipem | 0:c385e589a779 | 7 | supported_types() |
afilipem | 0:c385e589a779 | 8 | { |
afilipem | 0:c385e589a779 | 9 | } |
afilipem | 0:c385e589a779 | 10 | |
afilipem | 0:c385e589a779 | 11 | RPCType& RPCType::instance() |
afilipem | 0:c385e589a779 | 12 | { |
afilipem | 0:c385e589a779 | 13 | static RPCType t; |
afilipem | 0:c385e589a779 | 14 | return t; |
afilipem | 0:c385e589a779 | 15 | } |
afilipem | 0:c385e589a779 | 16 | |
afilipem | 0:c385e589a779 | 17 | void RPCType::register_types() |
afilipem | 0:c385e589a779 | 18 | { |
afilipem | 0:c385e589a779 | 19 | RPCType &t = instance(); |
afilipem | 0:c385e589a779 | 20 | |
afilipem | 0:c385e589a779 | 21 | RPC::add_rpc_class<RpcDigitalOut>(); |
afilipem | 0:c385e589a779 | 22 | t.supported_types.push_back("DigitalOut"); |
afilipem | 0:c385e589a779 | 23 | RPC::add_rpc_class<RpcDigitalIn>(); |
afilipem | 0:c385e589a779 | 24 | t.supported_types.push_back("DigitalIn"); |
afilipem | 0:c385e589a779 | 25 | RPC::add_rpc_class<RpcDigitalInOut>(); |
afilipem | 0:c385e589a779 | 26 | t.supported_types.push_back("DigitalInOut"); |
afilipem | 0:c385e589a779 | 27 | |
afilipem | 0:c385e589a779 | 28 | #if DEVICE_PWMOUT |
afilipem | 0:c385e589a779 | 29 | RPC::add_rpc_class<RpcPwmOut>(); |
afilipem | 0:c385e589a779 | 30 | t.supported_types.push_back("PwmOut"); |
afilipem | 0:c385e589a779 | 31 | #endif |
afilipem | 0:c385e589a779 | 32 | #if DEVICE_SPI |
afilipem | 0:c385e589a779 | 33 | t.supported_types.push_back("SPI"); |
afilipem | 0:c385e589a779 | 34 | RPC::add_rpc_class<RpcSPI>(); |
afilipem | 0:c385e589a779 | 35 | #endif |
afilipem | 0:c385e589a779 | 36 | #if DEVICE_SERIAL |
afilipem | 0:c385e589a779 | 37 | t.supported_types.push_back("Serial"); |
afilipem | 0:c385e589a779 | 38 | RPC::add_rpc_class<RpcSerial>(); |
afilipem | 0:c385e589a779 | 39 | #endif |
afilipem | 0:c385e589a779 | 40 | RPC::add_rpc_class<RpcTimer>(); |
afilipem | 0:c385e589a779 | 41 | t.supported_types.push_back("Timer"); |
afilipem | 0:c385e589a779 | 42 | } |
afilipem | 0:c385e589a779 | 43 | |
afilipem | 0:c385e589a779 | 44 | bool RPCType::is_supported_type(char *type) |
afilipem | 0:c385e589a779 | 45 | { |
afilipem | 0:c385e589a779 | 46 | for(std::list<char*>::iterator itor = instance().supported_types.begin(); |
afilipem | 0:c385e589a779 | 47 | itor != instance().supported_types.end(); |
afilipem | 0:c385e589a779 | 48 | ++itor) |
afilipem | 0:c385e589a779 | 49 | if(!strcmp(*itor,type)) |
afilipem | 0:c385e589a779 | 50 | return true; |
afilipem | 0:c385e589a779 | 51 | |
afilipem | 0:c385e589a779 | 52 | return false; |
afilipem | 0:c385e589a779 | 53 | } |
afilipem | 0:c385e589a779 | 54 | |
afilipem | 0:c385e589a779 | 55 |