MurataTypeYD_RPC_Sample fixed version for 050314

Dependencies:   PowerControl SNICInterface_mod2 mbed-rtos mbed

Fork of HTTPClient_WiFi_HelloWorld by KDDI Fx0 hackathon

Committer:
komoritan
Date:
Thu Mar 12 12:27:31 2015 +0000
Revision:
6:6c49fdc29825
Fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
komoritan 6:6c49fdc29825 1 #ifndef RPCOBJECT
komoritan 6:6c49fdc29825 2 #define RPCOBJECT
komoritan 6:6c49fdc29825 3
komoritan 6:6c49fdc29825 4 #include <map>
komoritan 6:6c49fdc29825 5 #include "mbed.h"
komoritan 6:6c49fdc29825 6
komoritan 6:6c49fdc29825 7 enum RPC_PIN_TYPE {
komoritan 6:6c49fdc29825 8 RPC_PIN_DIGITAL_IN,
komoritan 6:6c49fdc29825 9 RPC_PIN_DIGITAL_OUT,
komoritan 6:6c49fdc29825 10 RPC_PIN_DIGITAL_INOUT,
komoritan 6:6c49fdc29825 11 RPC_PIN_UNKNOWN
komoritan 6:6c49fdc29825 12 };
komoritan 6:6c49fdc29825 13
komoritan 6:6c49fdc29825 14 struct rpc_arg
komoritan 6:6c49fdc29825 15 {
komoritan 6:6c49fdc29825 16 char *name;
komoritan 6:6c49fdc29825 17 char *val;
komoritan 6:6c49fdc29825 18 };
komoritan 6:6c49fdc29825 19
komoritan 6:6c49fdc29825 20 class RPCClass
komoritan 6:6c49fdc29825 21 {
komoritan 6:6c49fdc29825 22 public :
komoritan 6:6c49fdc29825 23 virtual int read()= 0;
komoritan 6:6c49fdc29825 24 virtual void write(int value) = 0;
komoritan 6:6c49fdc29825 25 };
komoritan 6:6c49fdc29825 26
komoritan 6:6c49fdc29825 27 class RPCDigitalIn : public RPCClass
komoritan 6:6c49fdc29825 28 {
komoritan 6:6c49fdc29825 29 public :
komoritan 6:6c49fdc29825 30 RPCDigitalIn(PinName pin) :i(pin){}
komoritan 6:6c49fdc29825 31 virtual int read(void){return i.read();}
komoritan 6:6c49fdc29825 32 virtual void write(int value){}
komoritan 6:6c49fdc29825 33
komoritan 6:6c49fdc29825 34 private :
komoritan 6:6c49fdc29825 35 DigitalIn i;
komoritan 6:6c49fdc29825 36 };
komoritan 6:6c49fdc29825 37
komoritan 6:6c49fdc29825 38 class RPCDigitalOut : public RPCClass
komoritan 6:6c49fdc29825 39 {
komoritan 6:6c49fdc29825 40 public :
komoritan 6:6c49fdc29825 41 RPCDigitalOut(PinName pin) :o(pin){}
komoritan 6:6c49fdc29825 42 virtual int read(void){return o.read();}
komoritan 6:6c49fdc29825 43 virtual void write(int value){o.write(value);}
komoritan 6:6c49fdc29825 44
komoritan 6:6c49fdc29825 45 private :
komoritan 6:6c49fdc29825 46 DigitalOut o;
komoritan 6:6c49fdc29825 47 };
komoritan 6:6c49fdc29825 48
komoritan 6:6c49fdc29825 49 class RPCDigitalInOut : public RPCClass
komoritan 6:6c49fdc29825 50 {
komoritan 6:6c49fdc29825 51 public :
komoritan 6:6c49fdc29825 52 RPCDigitalInOut(PinName pin) :o(pin){}
komoritan 6:6c49fdc29825 53 virtual int read(void){return o.read();}
komoritan 6:6c49fdc29825 54 virtual void write(int value){o.write(value);}
komoritan 6:6c49fdc29825 55
komoritan 6:6c49fdc29825 56 private :
komoritan 6:6c49fdc29825 57 DigitalInOut o;
komoritan 6:6c49fdc29825 58 };
komoritan 6:6c49fdc29825 59
komoritan 6:6c49fdc29825 60 class RPCObject
komoritan 6:6c49fdc29825 61 {
komoritan 6:6c49fdc29825 62 public :
komoritan 6:6c49fdc29825 63 RPCObject();
komoritan 6:6c49fdc29825 64 int decode(char *request, char* reply);
komoritan 6:6c49fdc29825 65
komoritan 6:6c49fdc29825 66 RPC_PIN_TYPE get_type() const { return type; }
komoritan 6:6c49fdc29825 67 PinName get_pin_name() const { return pin_name; }
komoritan 6:6c49fdc29825 68 int get_value() const { return value; }
komoritan 6:6c49fdc29825 69 bool create_pin_object(char* reply);
komoritan 6:6c49fdc29825 70 std::map<PinName, RPCClass*> pinObjects;
komoritan 6:6c49fdc29825 71
komoritan 6:6c49fdc29825 72 private :
komoritan 6:6c49fdc29825 73 RPC_PIN_TYPE type;
komoritan 6:6c49fdc29825 74 char obj_name[20];
komoritan 6:6c49fdc29825 75 PinName pin_name;
komoritan 6:6c49fdc29825 76 int value;
komoritan 6:6c49fdc29825 77 };
komoritan 6:6c49fdc29825 78 #endif
komoritan 6:6c49fdc29825 79