July 3, 2009: Hacking an embedded chat room.
Jenell gave me a very awesome toy, an old Linksys WRT54G router. Turns out this particular model can run third part open source firmware. I choose an OpenWRT derivative, Gargoyle. One really big reason stands behind this: the author provides prebuilt binaries, giving Gargoyle the lowest barrier to entry. The second, smaller reason: Gargoyle is really pretty, in an SVG sort of way.
Today I felt feel like added adding a crazy feature to it, a chat room. The environment is pretty limited. One MB of free flash, BusyBox utilities, 2.4 series kernel. Most browser based chats expect PHP and MySQL. I found one using just perl. There is not enough free space to even install microperl, so I will have to roll my own. The existing CGI pages are generated through Haserl, a nifty wrapper for shell scripts. Basically, it acts like PHP but with shell scripts as the embedded language. There is some mild, easy to circumvent sandboxing. It is basically a pleasure to use, though I am constantly working around the cut down feature set of BusyBox.
- AJAX - JSON - Server enforced security - Random, persistent nickname coloring
Sadly, it is not usable. You need to know the IP address of the router and the password to get in. Optimally, when not connected to the internet, all URLs would be redirected to the chat room. I've requested help on the Gargoyle forums.
Some more detail on the primary use case: You have people with laptops all packed together, but there is no available wifi. This scenario sound odd and contrived, but I frequently find myself in just such an arrangement whenever traveling. Except for BoltBus, lack of internet is a common deficiency shared by trains, planes and buses.
I'll be making one small addition to the hardware to better support this use case. A small battery backup, made from eight NiMH AAA batteries, will be put inline with the AC adapter. I've designed the dumbest possible slow charger, with automatic switchover when power is lost. It should be enough to run the router for 30 minutes with several active wifi connections. Draining the batteries that fast might be a bad idea, AAs might be a better idea.
Finally, here is the code: chat.sh.