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