austinbv/dino — pull request #22 by vickash (2013-01-20 23:07:46+00:00)
Title: Add Ethernet Shield Support

WIP pull request for adding support for ethernet shields.

At first I tried just slapping an HTTP server onto the existing bootstrapper. Passing arbitrary messages between `dino` and the Arduino works great over HTTP. But since all the functions in the existing bootstrapper write directly to the serial interface, actually getting the data we need out of them and into an HTTP response would require heavy modification to the existing code.

Rather than doing that, I'm going to modify the existing bootstrapper first, so that most of the code can be shared between the two versions (and hopefully a future WiFi version), then change just what's needed to create the HTTP version.

Here's the plan:

- [ ] Refactor `du.ino` so that the main loop does all the writing to the serial interface instead of letting the subroutines do so directly. This will make it easy to convert messages to HTTP responses later.

- [ ] Temporarily remove all debugging, since errors (Eg. "badpin") will have to become HTTP errors, and debug lines will still go out over Serial. Also, the messages themselves could use some improvement.

- [ ] Create a second `du_ethernet.ino` bootstrapper that responds over HTTP instead of serial. At this point, thanks to the refactoring, everything below `loop` should be exactly the same in both files, easing future maintenance.

- [ ] Implement better debug and error messages for both versions.

- [ ] Make errors in the HTTP version produce HTTP error responses.

- [ ] Write `TxRx::HTTP`.

- [ ] Adapt this to work with the WiFi shield? I'm assuming the WiFi shield can run a server and respond to HTTP requests as well. I don't have one, but it should be possible to make a few modifications to `du_ethernet.ino` at this point to end up with a `du_wifi.ino` that works for WiFi shields.