This is really cool, looks like it will make integrating your microcontroller with other systems really easy.
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 completely agree. I tried to be clear about this in the readme on the github page.
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.
This is going to cause so much consternation. The microcontroller hacking community already looks down on the arduino because it is vastly overpowered for what most people use it for.
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.
The Professor on Gilligan's Island made a radio out of coconuts but that doesn't mean you have to...
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.
Yeah, a REST interface a pretty interesting way to interact with the Arduino.
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.
This is pretty cool, but to be honest, as a complete software noob who also hacks with Arduino, I don't get why this is easier than just using the examples that comes with the IDE.
Also interesting is BugLabs' "web services" where you can log into each module using a RESTful API:
> I don't get why this is easier than just using the examples that comes with the IDE.
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.
More than a replacement for learning Arduino, I could see this being more useful as a rapid prototype tool for interfacing between the web and a piece of hardware or circuitry. If all you need to do is check some states and flip some switches, why bother doing the same thing over and over in C when you can do it more reliably in jQuery?
Oh I like the sound of this. Though personally I found this to be the easy part; getting Arduino to send web requests to a webserver on button pushes is far harder (especially if you want it to do DHCP and DNS lookups).
> especially if you want it to do DHCP and DNS lookups
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.
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:
with body 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.