I see the start.html file that ships on the BBB can run bonescript right the from browser. It really slick the way you can take bonescript code from the browser and have it run remotely on the Bone.
My question is: Is there a tutorial on how to use this remote procedure call? I have a demo that pulls audio from a web cam on the Bone and displays the waveform on a web page. I have another demo that reads various sensors on the Bone and plots the results on a web page.
I’d like to switch these two examples to use the same RPC server the bonescript demo uses. Any pointers one where to start?
Copy-and-paste to start.
Let’s start with BeagleBoard.org - getPlatform.
What happened with the initial implementation of the BoneScript server was that the proper address for making the socket.io connection wasn’t properly communicated and if you were using a page served up by http://beagleboard.org, it wouldn’t make a connection unless you updated the BoneScript server. This made beagle-ui.js a bit uglier than I’d planned by introducing the need for a work-around, _onSocketIOLoaded_workaround() to be precise. This isn’t needed if you have the latest BoneScript server, but is being carried by beagle-ui.js nevertheless. I also introduced a couple more work-arounds here to provide interfaces to send messages that aren’t RPCs to the socket.io connection for running shell commands, since I never properly introduced a BoneScript library shell() function.
You’ll also see that beagle-ui.js provides that nifty “Your board is connected!” message. It seems pretty self-explanatory to me, but I wrote it, so it would. Perhaps a few more well-phrased questions would help result in some better documentation here.
Looking back at bonescript-demo.js, you’ll see a handful of functions I use within the BeagleBoard.org - BoneScript pages to provide you with live editors and ‘run’ buttons, namely initClient() will run demoEdit() on any blocks where it sees the “use-editor” class and demoRun() will extract code from the identified block for execution, respectively. I’ve simply created a ‘run’ button on the BeagleBoard.org - getPlatform page to call demoRun() on the block containing the example code. Pages like BeagleBoard.org - dogtag simply execute the provided script (in that case using shellRun()) upon establishing a connection.
Assuming an up-to-date BoneScript server/library and using the http://beagleboard.org/static/bonescript.js with the setTargetAddress function to point to the target board could result in a rather clean implementation of your application on your website. Simply provide a solution for providing the target ‘address’ of your board and set ‘handlers’ appropriately for the socket.io notifications for which you’d like to add UI elements and you are good to go!
Hope this helps. Patches welcome!