by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
robt
Date:
Sun Jun 16 15:34:26 2013 +0000
Commit message:
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9206091eda82 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 16 15:34:26 2013 +0000
@@ -0,0 +1,41 @@
+/* Program Example 12.12 Using RPC variables for remote mbed control
+                                                                        */
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPServer.h"
+#include "RPCVariable.h"
+#include "SerialRPCInterface.h"
+LocalFileSystem fs("webfs");
+EthernetNetIf eth(
+    IpAddr(192,168,0,101),//IP Address
+    IpAddr(255,255,255,0),//Network Mask
+    IpAddr(192,168,0,1),  //Gateway
+    IpAddr(192,168,0,1)   //DNS
+);
+HTTPServer svr;
+DigitalOut Led1(LED1);              // define mbed object
+DigitalIn Button1(p21);             // button
+int RemoteLEDStatus=0;
+RPCVariable<int> RPC_RemoteLEDStatus(&RemoteLEDStatus,"RemoteLEDStatus");
+int RemoteLED1Button=0;
+RPCVariable<int> RPC_RemoteLED1Button(&RemoteLED1Button,"RemoteLED1Button");
+int main() {
+    Base::add_rpc_class<DigitalOut>();        // RPC base command
+    eth.setup();                              // Ethernet setup
+    FSHandler::mount("/webfs", "/");   // Mount /webfs path root path
+    svr.addHandler<FSHandler>("/"); //Default handler
+    svr.addHandler<RPCHandler>("/rpc");       // Define RPC handler
+    svr.bind(80);
+    printf("Listening...\n");
+    while (true) {
+        Net::poll();
+        if ((Button1==1)|(RemoteLED1Button==1)) {
+            Led1=1;
+            RemoteLEDStatus=1;
+        } else {
+            Led1=0;
+            RemoteLEDStatus=0;
+        }
+    }
+}
+
diff -r 000000000000 -r 9206091eda82 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jun 16 15:34:26 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file