RPC programming

Communication from the mbed to a web page is achieved with RPC, Remote Procedure Calls. JavaScript running in the webpage will either call an RPC function to perform an mbed process or will access an RPCVariable in order to read a variable resident on the mbed.

In my case I included the RPCInterface library. This library has the following API's:

Using the RPC class

  1. Import the RPCInterface library
  2. Put an include to RPCInterface.h
  3. declare the variables, etc int var1;
  4. link the vars to the RPCVariable class. RPCVariable<int> rpc_v1(&var1, “var1”);
  5. Inside the javascript HTML page, call the RPC java program:script src=“mbedRPC.js”
  6. Javascript: instantiate mbed: mbed = new HTTPRPC();
  7. Javascript: create new var: var = new RPCVariable(mbed, “var1”);
  8. Javascript: read var as follows: i = var.read();
  9. Javascript: write vas as follows: var.write() = val;