waterbearlang/waterbear — Issue #91: Hook up Waterbear to external resources
Author: dethe
Created: 2011-12-29 02:34:54+00:00
State: open

For sending code to Arduino or robots (and any non-Javascript language or non-Browser resource) we need a way to connect to the outside world. We can't currently communicate from Waterbear to things like compilers or serial ports. Currently we generate the code in browser, then it is cut-and-pasted into another environment for compiling and sending over the serial port.

Some possible options include:

* A browser plugin with heightened permissions might be able to communicate to the resources we need. We'd have to create (and maintain!) one for each browser we support, though.

* We could send scripts to a server that could compile them and send them to the serial port. For arduino there is even a Node.js library for communicating between the server and Arduino. This would require writing the server (and we'd need different things for Java robotics than for Arduino, etc.) and either each Waterbear user would have to run a server as well, or there would have to be a centralized server, say in a classroom. This could work in a class setting, but then each student would have to take their arduino or robot to the server to update the code.

* We could wrap a browser in an app and expose the additional APIs needed to communicate with external resources to Javascript (like PhoneGap does for mobile and Titanium does for desktop apps).

* We could create a helper app and register a new protocol, so waterbear apps could call out to our helper app just like browsers call out now to Email and RSS readers. This would require building (and maintaining) a helper app for each platform we support that can register as a protocol handler (one or more: we could create protocols for each compiler, like "arduino:" and "java:" , or a protocol to talk directly to the serial port with "serial:").

* Google and Mozilla are working on something which may help, eventually, if I understand it correctly. Mozilla calls their version Web Activities and Google calls their Web Intents, but they are similar ways to extend web apps to communicate with each other and with other applications, with user control for which applications get used.

Right now I'm leaning towards a simple protocol helper app. It seems to be flexible enough and easy enough to create, and if we use Python or Javascript to write it, it should be cross-platform as well. Making a server to talk with Arduino using Node.js would probably be the fastest solution for that particular problem, but won't help with Java, etc. Longer-term, I hope Web Activities/Intents will take this problem off our plate.

If anyone wants to step up and implement any of these potential solutions, I can help with pointers to resources and specs.

In any of these cases we need to be aware of the security implications.