Working with RPC Variables

Dependencies:   RPCInterface mbed

Revision:
0:85792dec3d95
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 12 02:37:08 2016 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "mbed_rpc.h"
+
+// These are examples of some variable types that can be modified through RPC.
+int wheelsOn;
+char lcdBannerMessage;
+float speed;
+
+RPCVariable<int> rpcLights(&wheelsOn, "wheels");
+RPCVariable<char> rpcBanner(&lcdBannerMessage, "banner");
+RPCVariable<float> rpcSpeed(&speed, "speed");
+
+Serial pc(USBTX, USBRX);
+
+int main() {
+    //The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to base class
+    
+    // receive commands, and send back the responses
+    char buf[256], outbuf[256];
+    while(1) {
+        pc.gets(buf, 256);
+        //Call the static call method on the RPC class
+        RPC::call(buf, outbuf); 
+        pc.printf("%s\n", outbuf);
+    }
+}
\ No newline at end of file