Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NySNICInterface mbed-rtos mbed
Fork of RESTServerSample by
Diff: RPCObject.h
- Revision:
- 0:998e2e00df0c
diff -r 000000000000 -r 998e2e00df0c RPCObject.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RPCObject.h Tue Feb 10 12:15:47 2015 +0000
@@ -0,0 +1,79 @@
+#ifndef RPCOBJECT
+#define RPCOBJECT
+
+#include <map>
+#include "mbed.h"
+
+enum RPC_PIN_TYPE {
+ RPC_PIN_DIGITAL_IN,
+ RPC_PIN_DIGITAL_OUT,
+ RPC_PIN_DIGITAL_INOUT,
+ RPC_PIN_UNKNOWN
+};
+
+struct rpc_arg
+{
+ char *name;
+ char *val;
+};
+
+class RPCClass
+{
+ public :
+ virtual int read()= 0;
+ virtual void write(int value) = 0;
+};
+
+class RPCDigitalIn : public RPCClass
+{
+ public :
+ RPCDigitalIn(PinName pin) :i(pin){}
+ virtual int read(void){return i.read();}
+ virtual void write(int value){}
+
+ private :
+ DigitalIn i;
+};
+
+class RPCDigitalOut : public RPCClass
+{
+ public :
+ RPCDigitalOut(PinName pin) :o(pin){}
+ virtual int read(void){return o.read();}
+ virtual void write(int value){o.write(value);}
+
+ private :
+ DigitalOut o;
+};
+
+class RPCDigitalInOut : public RPCClass
+{
+ public :
+ RPCDigitalInOut(PinName pin) :o(pin){}
+ virtual int read(void){return o.read();}
+ virtual void write(int value){o.write(value);}
+
+ private :
+ DigitalInOut o;
+};
+
+class RPCObject
+{
+ public :
+ RPCObject();
+ int decode(char *request, char* reply);
+
+ RPC_PIN_TYPE get_type() const { return type; }
+ PinName get_pin_name() const { return pin_name; }
+ int get_value() const { return value; }
+ bool create_pin_object(char* reply);
+ std::map<PinName, RPCClass*> pinObjects;
+
+ private :
+ RPC_PIN_TYPE type;
+ char obj_name[20];
+ PinName pin_name;
+ int value;
+};
+#endif
+

