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

myrpc.cpp

Committer:
iva2k
Date:
2009-12-09
Revision:
0:5e068c08724a

File content as of revision 0:5e068c08724a:

// 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