Winter break means plenty of time to toy around with something new. I’m not sure what inspired this project, perhaps the ethernet driver we designed for our Operating Systems course, but I’ve decided to explore the field of embedded networking. And you can’t get much more embedded than a 16 MHz Arduino Uno with 32K of memory.
I want to create an Arduino-based web server, but with a few twists, because the idea already exists and has been implemented. The first link points to Lady Ada’s quick and dirty Arduino file server, which can serve up character-based files stored on micro SD. The second link offers a more functional server called Webduino, which claims to offer image support (ie. binary transfers). However, reading through the code, it looks like the developer took the easy way out by re-encoding a PNG as hex values, and then sending those values byte-by-byte over the network. That’s not image support! Also, both implementations seem to suffer from the limitation that only one client can connect at a time.
Because the Arduino has no formal notion of threads, it would make sense that multiple clients just won’t work. But I’ve been reading up on a project called Protothreads, which adds the most basic threading you can imagine. No separate stacks. No pre-emptive scheduling. Just a way to give the appearance that two computations are concurrent. I’m hoping that I can use protothreading to allow multiple clients to connect.
Additionally, it would be nice to find a way to do binary transfers. Glancing at the EthernetClient and EthernetServer API, it looks like they’re both set up for byte transfers. I wonder if there’s a way I can trick it into sending binary information. We’ll see.
Update – 26 January 2012:
I found an easy way (untested) to get the Arduino to send non-text content over the EthernetClient interface. When a client requests a file of a certain type, say, PNG, you can send a response indicating that you will be sending PNG binary data byte by byte as follows:
client.println("HTTP/1.1 200 OK"); client.println("Content-Type: image/png");
I hope to test this technique soon. Admittedly, I still have a long way to go on this project, but other projects (iPhone app, stay tuned) keep arising.