mbed RPC Server - Eclipse SmartHome Variante

Dependencies:   EthernetInterface HttpServer Motor Servo mbed-rtos mbed StepperMotorUni TMP175

Fork of RPCHTTPServerSimple by smd.iotkit2.ch

Das ist der mbed Teil zu Eclipse SmartHome (openHAB2). Compiliert das Programm und lädt es auf das Board.

Installation Eclipse SmartHome

Lädt eine vorbereitete Version des openHAB2 Runtimes von http://images.workshoptage.ch/images/ws4/ herunter und entpackt es auf Eurem PC. Alternativ kann die Entwicklungsumgebung von openHAB2 inkl. Eclipse wie hier beschrieben, installiert werden.

Zusätzlich ist das Addon (Eclipse Plug-In - ch.iotkit.smarthome.binding.mbedRPC*), ebenfalls von http://images.workshoptage.ch/images/ws4/ downzuladen und ins Verzeichnis addons zu kopieren.

Danach kann das openHAB2 Runtime mittels des start Datei gestartet werden und das UI mittels http://localhost:8080 aufrufen werden.

Der Sourcecode zum Eclipse Plug-In befindet sich auf GitHub

Konfiguration

Vorgehen:

  • Konfiguriert die Ethernet Bridge mit der IP Adresse des IoTKit SMD Shield
  • Fügt die Sensoren, Aktoren, LED's etc. vom IoTKit SMD Shield hinzu, aufbauend auf der Bridge

Unterstützte Geräte

  • Sensoren (auf Shield)
    • Poti (Pin A0)
    • Helligkeits Sensor (Pin A1)
    • Hall Sensor (Pin A2)
    • Temperatur Sensor (mittels I2C Bus)
  • Aktoren
    • Motor (Pin D3, D2, D4), verbinden mit DCMOT D2-D7 oben
    • Servo (Pin D9), verbinden mit Servo2 Stecker
    • Stepper (K64F Pins), verbinden mit STEPPER3, rotes Kabel nach unten
  • LED's (auf Shield)
    • LED's rot, gelb, grün, blau (Pin D10 - D13)
  • LED Strip 12 Volt (Pin D5 - D7), verbinden mit FET D5-D7, 12V oben

Der Motor und der LED Strip benötigen ein externes 12 Volt Netzteil.

cURL

Die Funktionen können mittels cURL oder Browser wie folgt getestet werden:

# RGB LED Strip (weiss 0xFFFFFF, rot 0xFF00, grün 0xFF0000, blau, 0xFF)
http://192.168.178.32/rpc/ledstrip/write+16777215
http://192.168.178.32/rpc/ledstrip/write+‭16711680‬
http://192.168.178.32/rpc/ledstrip/write+65280
http://192.168.178.32/rpc/ledstrip/write+255
 
# Motor Up, Down, Stop (Simulation Rollladen)
http://192.168.178.32/rpc/motor1/up
http://192.168.178.32/rpc/motor1/down
http://192.168.178.32/rpc/motor1/stop
 
# Schrittmotor                               
http://192.168.178.32/rpc/stepper1/up
http://192.168.178.32/rpc/stepper1/down
 
# Servo (Positionieren 0 - 1.0 und Position lesen)
http://192.168.178.32/rpc/servo1/write+0.5
http://192.168.178.32/rpc/servo1/read
 
# Temperatur Sensor abfragen                        
http://192.168.178.32/rpc/temp/read

IP-Adresse entsprechend dem Board anpassen.

Committer:
marcel1691
Date:
Fri Aug 28 12:33:30 2015 +0000
Revision:
16:d0a5bb230d94
Parent:
11:43e28c85fd75
Temp (I2C), RGB LED Strip impl.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefan1691 11:43e28c85fd75 1 /* mbed Microcontroller Library
stefan1691 11:43e28c85fd75 2 * Copyright (c) 2006-2013 ARM Limited
stefan1691 11:43e28c85fd75 3 *
stefan1691 11:43e28c85fd75 4 * Licensed under the Apache License, Version 2.0 (the "License");
stefan1691 11:43e28c85fd75 5 * you may not use this file except in compliance with the License.
stefan1691 11:43e28c85fd75 6 * You may obtain a copy of the License at
stefan1691 11:43e28c85fd75 7 *
stefan1691 11:43e28c85fd75 8 * http://www.apache.org/licenses/LICENSE-2.0
stefan1691 11:43e28c85fd75 9 *
stefan1691 11:43e28c85fd75 10 * Unless required by applicable law or agreed to in writing, software
stefan1691 11:43e28c85fd75 11 * distributed under the License is distributed on an "AS IS" BASIS,
stefan1691 11:43e28c85fd75 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
stefan1691 11:43e28c85fd75 13 * See the License for the specific language governing permissions and
stefan1691 11:43e28c85fd75 14 * limitations under the License.
stefan1691 11:43e28c85fd75 15 */
stefan1691 11:43e28c85fd75 16 #ifndef MBED_CLASSES_H
stefan1691 11:43e28c85fd75 17 #define MBED_CLASSES_H
stefan1691 11:43e28c85fd75 18
stefan1691 11:43e28c85fd75 19 #include "rpc.h"
stefan1691 11:43e28c85fd75 20
stefan1691 11:43e28c85fd75 21 namespace mbed {
stefan1691 11:43e28c85fd75 22
stefan1691 11:43e28c85fd75 23 class RpcDigitalOut : public RPC {
stefan1691 11:43e28c85fd75 24 public:
stefan1691 11:43e28c85fd75 25 RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 26
stefan1691 11:43e28c85fd75 27 void write(int a0) {o.write(a0);}
stefan1691 11:43e28c85fd75 28 int read(void) {return o.read();}
stefan1691 11:43e28c85fd75 29
stefan1691 11:43e28c85fd75 30 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 31 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 32 {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
stefan1691 11:43e28c85fd75 33 {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
stefan1691 11:43e28c85fd75 34 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 35 };
stefan1691 11:43e28c85fd75 36 return rpc_methods;
stefan1691 11:43e28c85fd75 37 }
stefan1691 11:43e28c85fd75 38 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 39 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 40 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
stefan1691 11:43e28c85fd75 41 RPC_METHOD_END
stefan1691 11:43e28c85fd75 42 };
stefan1691 11:43e28c85fd75 43 static rpc_class c = {"DigitalOut", funcs, NULL};
stefan1691 11:43e28c85fd75 44 return &c;
stefan1691 11:43e28c85fd75 45 }
stefan1691 11:43e28c85fd75 46 private:
stefan1691 11:43e28c85fd75 47 DigitalOut o;
stefan1691 11:43e28c85fd75 48 };
stefan1691 11:43e28c85fd75 49
stefan1691 11:43e28c85fd75 50 class RpcDigitalIn : public RPC {
stefan1691 11:43e28c85fd75 51 public:
stefan1691 11:43e28c85fd75 52 RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 53
stefan1691 11:43e28c85fd75 54 int read(void) {return o.read();}
stefan1691 11:43e28c85fd75 55
stefan1691 11:43e28c85fd75 56 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 57 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 58 {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
stefan1691 11:43e28c85fd75 59 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 60 };
stefan1691 11:43e28c85fd75 61 return rpc_methods;
stefan1691 11:43e28c85fd75 62 }
stefan1691 11:43e28c85fd75 63 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 64 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 65 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
stefan1691 11:43e28c85fd75 66 RPC_METHOD_END
stefan1691 11:43e28c85fd75 67 };
stefan1691 11:43e28c85fd75 68 static rpc_class c = {"DigitalIn", funcs, NULL};
stefan1691 11:43e28c85fd75 69 return &c;
stefan1691 11:43e28c85fd75 70 }
stefan1691 11:43e28c85fd75 71 private:
stefan1691 11:43e28c85fd75 72 DigitalIn o;
stefan1691 11:43e28c85fd75 73 };
stefan1691 11:43e28c85fd75 74
stefan1691 11:43e28c85fd75 75 class RpcDigitalInOut : public RPC {
stefan1691 11:43e28c85fd75 76 public:
stefan1691 11:43e28c85fd75 77 RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 78
stefan1691 11:43e28c85fd75 79 int read(void) {return o.read();}
stefan1691 11:43e28c85fd75 80 void write(int a0) {o.write(a0);}
stefan1691 11:43e28c85fd75 81 void input(void) {o.input();}
stefan1691 11:43e28c85fd75 82 void output(void) {o.output();}
stefan1691 11:43e28c85fd75 83
stefan1691 11:43e28c85fd75 84 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 85 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 86 {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
stefan1691 11:43e28c85fd75 87 {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
stefan1691 11:43e28c85fd75 88 {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
stefan1691 11:43e28c85fd75 89 {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
stefan1691 11:43e28c85fd75 90 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 91 };
stefan1691 11:43e28c85fd75 92 return rpc_methods;
stefan1691 11:43e28c85fd75 93 }
stefan1691 11:43e28c85fd75 94 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 95 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 96 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
stefan1691 11:43e28c85fd75 97 RPC_METHOD_END
stefan1691 11:43e28c85fd75 98 };
stefan1691 11:43e28c85fd75 99 static rpc_class c = {"DigitalInOut", funcs, NULL};
stefan1691 11:43e28c85fd75 100 return &c;
stefan1691 11:43e28c85fd75 101 }
stefan1691 11:43e28c85fd75 102 private:
stefan1691 11:43e28c85fd75 103 DigitalInOut o;
stefan1691 11:43e28c85fd75 104 };
stefan1691 11:43e28c85fd75 105
stefan1691 11:43e28c85fd75 106 #if DEVICE_ANALOGIN
stefan1691 11:43e28c85fd75 107 class RpcAnalogIn : public RPC {
stefan1691 11:43e28c85fd75 108 public:
stefan1691 11:43e28c85fd75 109 RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 110
stefan1691 11:43e28c85fd75 111 float read(void) {return o.read();}
stefan1691 11:43e28c85fd75 112 unsigned short read_u16(void) {return o.read_u16();}
stefan1691 11:43e28c85fd75 113
stefan1691 11:43e28c85fd75 114 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 115 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 116 {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
stefan1691 11:43e28c85fd75 117 {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
stefan1691 11:43e28c85fd75 118 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 119 };
stefan1691 11:43e28c85fd75 120 return rpc_methods;
stefan1691 11:43e28c85fd75 121 }
stefan1691 11:43e28c85fd75 122 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 123 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 124 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
stefan1691 11:43e28c85fd75 125 RPC_METHOD_END
stefan1691 11:43e28c85fd75 126 };
stefan1691 11:43e28c85fd75 127 static rpc_class c = {"AnalogIn", funcs, NULL};
stefan1691 11:43e28c85fd75 128 return &c;
stefan1691 11:43e28c85fd75 129 }
stefan1691 11:43e28c85fd75 130 private:
stefan1691 11:43e28c85fd75 131 AnalogIn o;
stefan1691 11:43e28c85fd75 132 };
stefan1691 11:43e28c85fd75 133 #endif
stefan1691 11:43e28c85fd75 134
stefan1691 11:43e28c85fd75 135 #if DEVICE_ANALOGOUT
stefan1691 11:43e28c85fd75 136 class RpcAnalogOut : public RPC {
stefan1691 11:43e28c85fd75 137 public:
stefan1691 11:43e28c85fd75 138 RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 139
stefan1691 11:43e28c85fd75 140 float read(void) {return o.read();}
stefan1691 11:43e28c85fd75 141 void write(float a0) {o.write(a0);}
stefan1691 11:43e28c85fd75 142 void write_u16(unsigned short a0) {o.write_u16(a0);}
stefan1691 11:43e28c85fd75 143
stefan1691 11:43e28c85fd75 144 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 145 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 146 {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
stefan1691 11:43e28c85fd75 147 {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
stefan1691 11:43e28c85fd75 148 {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
stefan1691 11:43e28c85fd75 149 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 150 };
stefan1691 11:43e28c85fd75 151 return rpc_methods;
stefan1691 11:43e28c85fd75 152 }
stefan1691 11:43e28c85fd75 153 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 154 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 155 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
stefan1691 11:43e28c85fd75 156 RPC_METHOD_END
stefan1691 11:43e28c85fd75 157 };
stefan1691 11:43e28c85fd75 158 static rpc_class c = {"AnalogOut", funcs, NULL};
stefan1691 11:43e28c85fd75 159 return &c;
stefan1691 11:43e28c85fd75 160 }
stefan1691 11:43e28c85fd75 161 private:
stefan1691 11:43e28c85fd75 162 AnalogOut o;
stefan1691 11:43e28c85fd75 163 };
stefan1691 11:43e28c85fd75 164 #endif
stefan1691 11:43e28c85fd75 165
stefan1691 11:43e28c85fd75 166 #if DEVICE_PWMOUT
stefan1691 11:43e28c85fd75 167 class RpcPwmOut : public RPC {
stefan1691 11:43e28c85fd75 168 public:
stefan1691 11:43e28c85fd75 169 RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 11:43e28c85fd75 170
stefan1691 11:43e28c85fd75 171 float read(void) {return o.read();}
stefan1691 11:43e28c85fd75 172 void write(float a0) {o.write(a0);}
stefan1691 11:43e28c85fd75 173 void period(float a0) {o.period(a0);}
stefan1691 11:43e28c85fd75 174 void period_ms(int a0) {o.period_ms(a0);}
stefan1691 11:43e28c85fd75 175 void pulsewidth(float a0) {o.pulsewidth(a0);}
stefan1691 11:43e28c85fd75 176 void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
stefan1691 11:43e28c85fd75 177
stefan1691 11:43e28c85fd75 178 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 179 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 180 {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
stefan1691 11:43e28c85fd75 181 {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
stefan1691 11:43e28c85fd75 182 {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
stefan1691 11:43e28c85fd75 183 {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
stefan1691 11:43e28c85fd75 184 {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
stefan1691 11:43e28c85fd75 185 {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
stefan1691 11:43e28c85fd75 186 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 187 };
stefan1691 11:43e28c85fd75 188 return rpc_methods;
stefan1691 11:43e28c85fd75 189 }
stefan1691 11:43e28c85fd75 190 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 191 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 192 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
stefan1691 11:43e28c85fd75 193 RPC_METHOD_END
stefan1691 11:43e28c85fd75 194 };
stefan1691 11:43e28c85fd75 195 static rpc_class c = {"PwmOut", funcs, NULL};
stefan1691 11:43e28c85fd75 196 return &c;
stefan1691 11:43e28c85fd75 197 }
stefan1691 11:43e28c85fd75 198 private:
stefan1691 11:43e28c85fd75 199 PwmOut o;
stefan1691 11:43e28c85fd75 200 };
stefan1691 11:43e28c85fd75 201 #endif
stefan1691 11:43e28c85fd75 202
stefan1691 11:43e28c85fd75 203 #if DEVICE_SPI
stefan1691 11:43e28c85fd75 204 class RpcSPI : public RPC {
stefan1691 11:43e28c85fd75 205 public:
stefan1691 11:43e28c85fd75 206 RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
stefan1691 11:43e28c85fd75 207
stefan1691 11:43e28c85fd75 208 void format(int a0, int a1) {o.format(a0, a1);}
stefan1691 11:43e28c85fd75 209 void frequency(int a0) {o.frequency(a0);}
stefan1691 11:43e28c85fd75 210 int write(int a0) {return o.write(a0);}
stefan1691 11:43e28c85fd75 211
stefan1691 11:43e28c85fd75 212 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 213 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 214 {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
stefan1691 11:43e28c85fd75 215 {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
stefan1691 11:43e28c85fd75 216 {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
stefan1691 11:43e28c85fd75 217 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 218 };
stefan1691 11:43e28c85fd75 219 return rpc_methods;
stefan1691 11:43e28c85fd75 220 }
stefan1691 11:43e28c85fd75 221 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 222 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 223 {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
stefan1691 11:43e28c85fd75 224 RPC_METHOD_END
stefan1691 11:43e28c85fd75 225 };
stefan1691 11:43e28c85fd75 226 static rpc_class c = {"SPI", funcs, NULL};
stefan1691 11:43e28c85fd75 227 return &c;
stefan1691 11:43e28c85fd75 228 }
stefan1691 11:43e28c85fd75 229 private:
stefan1691 11:43e28c85fd75 230 SPI o;
stefan1691 11:43e28c85fd75 231 };
stefan1691 11:43e28c85fd75 232 #endif
stefan1691 11:43e28c85fd75 233
stefan1691 11:43e28c85fd75 234 #if DEVICE_SERIAL
stefan1691 11:43e28c85fd75 235 class RpcSerial : public RPC {
stefan1691 11:43e28c85fd75 236 public:
stefan1691 11:43e28c85fd75 237 RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
stefan1691 11:43e28c85fd75 238
stefan1691 11:43e28c85fd75 239 void baud(int a0) {o.baud(a0);}
stefan1691 11:43e28c85fd75 240 int readable(void) {return o.readable();}
stefan1691 11:43e28c85fd75 241 int writeable(void) {return o.writeable();}
stefan1691 11:43e28c85fd75 242 int putc(int a0) {return o.putc(a0);}
stefan1691 11:43e28c85fd75 243 int getc(void) {return o.getc();}
stefan1691 11:43e28c85fd75 244 int puts(const char * a0) {return o.puts(a0);}
stefan1691 11:43e28c85fd75 245
stefan1691 11:43e28c85fd75 246 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 247 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 248 {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
stefan1691 11:43e28c85fd75 249 {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
stefan1691 11:43e28c85fd75 250 {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
stefan1691 11:43e28c85fd75 251 {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
stefan1691 11:43e28c85fd75 252 {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
stefan1691 11:43e28c85fd75 253 {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
stefan1691 11:43e28c85fd75 254 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 255 };
stefan1691 11:43e28c85fd75 256 return rpc_methods;
stefan1691 11:43e28c85fd75 257 }
stefan1691 11:43e28c85fd75 258 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 259 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 260 {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
stefan1691 11:43e28c85fd75 261 RPC_METHOD_END
stefan1691 11:43e28c85fd75 262 };
stefan1691 11:43e28c85fd75 263 static rpc_class c = {"Serial", funcs, NULL};
stefan1691 11:43e28c85fd75 264 return &c;
stefan1691 11:43e28c85fd75 265 }
stefan1691 11:43e28c85fd75 266 private:
stefan1691 11:43e28c85fd75 267 Serial o;
stefan1691 11:43e28c85fd75 268 };
stefan1691 11:43e28c85fd75 269 #endif
stefan1691 11:43e28c85fd75 270
stefan1691 11:43e28c85fd75 271 class RpcTimer : public RPC {
stefan1691 11:43e28c85fd75 272 public:
stefan1691 11:43e28c85fd75 273 RpcTimer(const char *name=NULL) : RPC(name), o() {}
stefan1691 11:43e28c85fd75 274
stefan1691 11:43e28c85fd75 275 void start(void) {o.start();}
stefan1691 11:43e28c85fd75 276 void stop(void) {o.stop();}
stefan1691 11:43e28c85fd75 277 void reset(void) {o.reset();}
stefan1691 11:43e28c85fd75 278 float read(void) {return o.read();}
stefan1691 11:43e28c85fd75 279 int read_ms(void) {return o.read_ms();}
stefan1691 11:43e28c85fd75 280 int read_us(void) {return o.read_us();}
stefan1691 11:43e28c85fd75 281
stefan1691 11:43e28c85fd75 282 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 11:43e28c85fd75 283 static const rpc_method rpc_methods[] = {
stefan1691 11:43e28c85fd75 284 {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
stefan1691 11:43e28c85fd75 285 {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
stefan1691 11:43e28c85fd75 286 {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
stefan1691 11:43e28c85fd75 287 {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
stefan1691 11:43e28c85fd75 288 {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
stefan1691 11:43e28c85fd75 289 {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
stefan1691 11:43e28c85fd75 290 RPC_METHOD_SUPER(RPC)
stefan1691 11:43e28c85fd75 291 };
stefan1691 11:43e28c85fd75 292 return rpc_methods;
stefan1691 11:43e28c85fd75 293 }
stefan1691 11:43e28c85fd75 294 static struct rpc_class *get_rpc_class() {
stefan1691 11:43e28c85fd75 295 static const rpc_function funcs[] = {
stefan1691 11:43e28c85fd75 296 {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
stefan1691 11:43e28c85fd75 297 RPC_METHOD_END
stefan1691 11:43e28c85fd75 298 };
stefan1691 11:43e28c85fd75 299 static rpc_class c = {"Timer", funcs, NULL};
stefan1691 11:43e28c85fd75 300 return &c;
stefan1691 11:43e28c85fd75 301 }
stefan1691 11:43e28c85fd75 302 private:
stefan1691 11:43e28c85fd75 303 Timer o;
stefan1691 11:43e28c85fd75 304 };
stefan1691 11:43e28c85fd75 305
stefan1691 11:43e28c85fd75 306 }
stefan1691 11:43e28c85fd75 307
stefan1691 11:43e28c85fd75 308 #endif