HTTPServer example with additional functions: * Link status indication (LED4); * Local file system (create index.htm page on MBED!); * RPC-able class (myrpc, allows remote function call that blinks LED1 N times);
Diff: myrpc.cpp
- Revision:
- 0:5e068c08724a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myrpc.cpp Wed Dec 09 01:55:06 2009 +0000 @@ -0,0 +1,44 @@ +// myrpc.cpp +// +// Based on: +// http://mbed.org/projects/cookbook/svn/Servo/trunk/Servo.h +// http://mbed.org/projects/cookbook/svn/Servo/trunk/Servo.cpp +// http://mbed.org/forum/topic/234/ + +#include "myrpc.h" +#ifdef MBED_RPC +#include "rpc.h" +#endif + +namespace mbed { + +myrpc::myrpc(PinName pin, const char *name) : Base(name), _pin(pin) {} + +void myrpc::blink(int n) { + for (int i=0; i<n; i++) { + _pin = 1; + wait(0.2); + _pin = 0; + wait(0.2); + } +} + +#ifdef MBED_RPC +const rpc_method *myrpc::get_rpc_methods() { + static const rpc_method rpc_methods[] = { + { "blink", rpc_method_caller<myrpc, int, &myrpc::blink> }, + RPC_METHOD_SUPER(Base) + }; + return rpc_methods; +} +rpc_class *myrpc::get_rpc_class() { + static const rpc_function funcs[] = { + "new", rpc_function_caller<const char*, PinName, const char*, &Base::construct<myrpc,PinName,const char*> >, + RPC_METHOD_END + }; + static rpc_class c = { "myrpc", funcs, NULL }; + return &c; +} +#endif + +} // namespace mbed