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);

Dependencies:   mbed lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers myrpc.cpp Source File

myrpc.cpp

00001 // myrpc.cpp
00002 //
00003 // Based on:
00004 // http://mbed.org/projects/cookbook/svn/Servo/trunk/Servo.h
00005 // http://mbed.org/projects/cookbook/svn/Servo/trunk/Servo.cpp
00006 // http://mbed.org/forum/topic/234/
00007 
00008 #include "myrpc.h"
00009 #ifdef MBED_RPC
00010 #include "rpc.h"
00011 #endif
00012 
00013 namespace mbed {
00014 
00015 myrpc::myrpc(PinName pin, const char *name) : Base(name), _pin(pin) {}
00016 
00017 void myrpc::blink(int n) {
00018   for (int i=0; i<n; i++) {
00019     _pin = 1;
00020     wait(0.2);
00021     _pin = 0;
00022     wait(0.2);
00023   }
00024 }
00025 
00026 #ifdef MBED_RPC
00027 const rpc_method *myrpc::get_rpc_methods() {
00028   static const rpc_method rpc_methods[] = {
00029     { "blink", rpc_method_caller<myrpc, int, &myrpc::blink> },
00030     RPC_METHOD_SUPER(Base)
00031   };
00032   return rpc_methods;
00033 }       
00034 rpc_class *myrpc::get_rpc_class() {
00035     static const rpc_function funcs[] = {
00036         "new", rpc_function_caller<const char*, PinName, const char*, &Base::construct<myrpc,PinName,const char*> >,
00037         RPC_METHOD_END
00038     };
00039     static rpc_class c = { "myrpc", funcs, NULL };
00040     return &c;
00041 }
00042 #endif
00043 
00044 }    // namespace mbed