TX1 node

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RPCType.cpp Source File

RPCType.cpp

00001 #include "mbed.h"
00002 #include "mbed_rpc.h"
00003 #include "RPCType.h"
00004 
00005 
00006 RPCType::RPCType():
00007 supported_types()
00008 {
00009 }
00010 
00011 RPCType& RPCType::instance()
00012 {
00013     static RPCType t;
00014     return t;
00015 }
00016 
00017 void RPCType::register_types()
00018 {
00019     RPCType &t = instance();
00020     
00021     RPC::add_rpc_class<RpcDigitalOut>();
00022     t.supported_types.push_back("DigitalOut");
00023     RPC::add_rpc_class<RpcDigitalIn>();
00024     t.supported_types.push_back("DigitalIn");
00025     RPC::add_rpc_class<RpcDigitalInOut>();
00026     t.supported_types.push_back("DigitalInOut");
00027 
00028     #if DEVICE_ANALOGIN
00029     RPC::add_rpc_class<RpcAnalogIn>();
00030     t.supported_types.push_back("AnalogIn");
00031     #endif
00032     #if DEVICE_PWMOUT
00033     RPC::add_rpc_class<RpcPwmOut>();
00034     t.supported_types.push_back("PwmOut");
00035     #endif
00036     #if DEVICE_SPI
00037     t.supported_types.push_back("SPI");
00038     RPC::add_rpc_class<RpcSPI>();
00039     #endif
00040     #if DEVICE_SERIAL
00041     t.supported_types.push_back("Serial");
00042     RPC::add_rpc_class<RpcSerial>();
00043     #endif
00044     RPC::add_rpc_class<RpcTimer>();
00045     t.supported_types.push_back("Timer");
00046 }
00047 
00048 bool RPCType::is_supported_type(char *type)
00049 {
00050     for(std::list<char*>::iterator itor = instance().supported_types.begin();
00051         itor != instance().supported_types.end();
00052         ++itor)
00053         if(!strcmp(*itor,type))
00054             return true;
00055 
00056     return false;
00057 }
00058 
00059