Webserver for peach-board

Committer:
thudt90
Date:
Thu Mar 12 08:26:27 2015 +0000
Revision:
1:f1f734dd23ee
Parent:
0:6ec14f880a00
Just test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thudt90 0:6ec14f880a00 1 #include "mbed.h"
thudt90 0:6ec14f880a00 2 #include "mbed_rpc.h"
thudt90 0:6ec14f880a00 3 #include "RPCType.h"
thudt90 0:6ec14f880a00 4
thudt90 0:6ec14f880a00 5
thudt90 0:6ec14f880a00 6 RPCType::RPCType():
thudt90 0:6ec14f880a00 7 supported_types()
thudt90 0:6ec14f880a00 8 {
thudt90 0:6ec14f880a00 9 }
thudt90 0:6ec14f880a00 10
thudt90 0:6ec14f880a00 11 RPCType& RPCType::instance()
thudt90 0:6ec14f880a00 12 {
thudt90 0:6ec14f880a00 13 static RPCType t;
thudt90 0:6ec14f880a00 14 return t;
thudt90 0:6ec14f880a00 15 }
thudt90 0:6ec14f880a00 16
thudt90 0:6ec14f880a00 17 void RPCType::register_types()
thudt90 0:6ec14f880a00 18 {
thudt90 0:6ec14f880a00 19 RPCType &t = instance();
thudt90 0:6ec14f880a00 20
thudt90 0:6ec14f880a00 21 RPC::add_rpc_class<RpcDigitalOut>();
thudt90 0:6ec14f880a00 22 t.supported_types.push_back("DigitalOut");
thudt90 0:6ec14f880a00 23 RPC::add_rpc_class<RpcDigitalIn>();
thudt90 0:6ec14f880a00 24 t.supported_types.push_back("DigitalIn");
thudt90 0:6ec14f880a00 25 RPC::add_rpc_class<RpcDigitalInOut>();
thudt90 0:6ec14f880a00 26 t.supported_types.push_back("DigitalInOut");
thudt90 0:6ec14f880a00 27
thudt90 0:6ec14f880a00 28 #if DEVICE_PWMOUT
thudt90 0:6ec14f880a00 29 RPC::add_rpc_class<RpcPwmOut>();
thudt90 0:6ec14f880a00 30 t.supported_types.push_back("PwmOut");
thudt90 0:6ec14f880a00 31 #endif
thudt90 0:6ec14f880a00 32 #if DEVICE_SPI
thudt90 0:6ec14f880a00 33 t.supported_types.push_back("SPI");
thudt90 0:6ec14f880a00 34 RPC::add_rpc_class<RpcSPI>();
thudt90 0:6ec14f880a00 35 #endif
thudt90 0:6ec14f880a00 36 #if DEVICE_SERIAL
thudt90 0:6ec14f880a00 37 t.supported_types.push_back("Serial");
thudt90 0:6ec14f880a00 38 RPC::add_rpc_class<RpcSerial>();
thudt90 0:6ec14f880a00 39 #endif
thudt90 0:6ec14f880a00 40 RPC::add_rpc_class<RpcTimer>();
thudt90 0:6ec14f880a00 41 t.supported_types.push_back("Timer");
thudt90 0:6ec14f880a00 42 }
thudt90 0:6ec14f880a00 43
thudt90 0:6ec14f880a00 44 bool RPCType::is_supported_type(char *type)
thudt90 0:6ec14f880a00 45 {
thudt90 0:6ec14f880a00 46 for(std::list<char*>::iterator itor = instance().supported_types.begin();
thudt90 0:6ec14f880a00 47 itor != instance().supported_types.end();
thudt90 0:6ec14f880a00 48 ++itor)
thudt90 0:6ec14f880a00 49 if(!strcmp(*itor,type))
thudt90 0:6ec14f880a00 50 return true;
thudt90 0:6ec14f880a00 51
thudt90 0:6ec14f880a00 52 return false;
thudt90 0:6ec14f880a00 53 }
thudt90 0:6ec14f880a00 54
thudt90 0:6ec14f880a00 55