info:mbed_rpc_library_notes
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:
- RPCFunction to access mbed functions
- RPCVariable to read and set an attached variable using the RPC
- SerialRPCInterface to send and receive serial messages
Using the RPC class
- Import the RPCInterface library
- Put an include to RPCInterface.h
- declare the variables, etc int var1;
- link the vars to the RPCVariable class. RPCVariable<int> rpc_v1(&var1, “var1”);
- Inside the javascript HTML page, call the RPC java program:script src=“mbedRPC.js”
- Javascript: instantiate mbed: mbed = new HTTPRPC();
- Javascript: create new var: var = new RPCVariable(mbed, “var1”);
- Javascript: read var as follows: i = var.read();
- Javascript: write vas as follows: var.write() = val;
info/mbed_rpc_library_notes.txt · Last modified: 2011/02/22 11:57 by tomgee