RESTduino - Arduino hacking for the REST of us
jasongullickson.posterous.com
jasongullickson.posterous.com
But - and I hate to be the REST Nazi - this is RPC, not REST.
"REpresentational State Transfer" is about making things happen by Transferring REpresentations of resources' State.
The GET requests are good, but for setting outputs it should do something like:
PUT http://192.168.1.177/9
with body HIGH
POST could work too, the important thing is that the resource's state, the resource's address, and the action being performed are all separate.This RPC system is beautifully simple, it does what it needs to and I can't think of any way that making it RESTful would improve it, but it's not RESTful right now, and calling it that only deepens the confusion about what REST is.
I set out to build it as a "proper" REST interface but ran into some snags with POST on the Arduino side and decided (reluctantly) to implement the output functions as GET requests for the time being.
I plan to remedy this as time allows, however I didn't want to put sharing the code at the mercy of my schedule. I have a few more improvements in mind as well and I wanted to gather some feedback to help prioritize future development.
They think people should be using the arduino as a rapid prototyping system, and then making their own circuit board with the individual components arranged as needed.
They is a constant stream of blog posts looking for ways to get noob arduino hackers to "graduate" to designing their own circuits.
While it all seems terribly unreasonable from the point of view of a software developer used to the idea of a tradeoff between hardware costs vs development time, it is very similar to the programming language wars.
See: http://hackaday.com/2011/02/11/how-the-arduino-won-this-is-h...
Don't get me wrong, I love coding down to the bare metal too but if something like this encourages one "Rails Guy" to interface his web stats to a water fountain then I'm delighted.
Besides, the smart hacker would see the business opportunity in helping these "noobs" turn their over-powered Arduino designs into streamlined products.
I'm totally doing that.
I made something similar a couple of years ago (the details of which used to be at http://code.rancidbacon.com/Flashduino and may return when I get a server back up).
The demo I had actually served up an Adobe Flash file that was stored in the Arduino's flash memory (it was small and generated with Python & Ming) that then interacted with the Arduino via the "REST" interface. I got it reading/writing pins and the EEPROM from both Adobe Flash and Javascript before I got distracted. :)
I've long thought that interacting with Firmata via REST could be a nice approach--I think Massimo from the Arduino team wrote an Ethernetised Firmata at one stage but don't think it used HTTP.
Also interesting is BugLabs' "web services" where you can log into each module using a RESTful API:
In theory it means that you can get a pre-programmed Arduino with network connectivity and give it to a web dev person who has no knowledge of microcontrollers and show they how they can turn an LED on or off by accessing a URL from Javascript. No IDE required.
Up until now this has been true with the official Arduino Ethernet shield but there's been work integrating DHCP and DNS functionality into the Arduino core. I believe it's targeted at the Arduino 1.0 release.
Other networking shields (like the WiFly--disclosure, I wrote the library for it for the manufacturer) have DHCP and DNS support out of the box.