

Ambient bus arrival monitor from hacked Linksys WRT54GL - jgrahamc
http://blog.jgc.org/2012/03/ambient-bus-arrival-monitor-from-hacked.html

======
darklajid
Amazing.

Unfortunately it makes me sad to see so nice ways of using the public
transport data - and having it not available everywhere where I'd care.

In Cologne/DE I actually sent mails and calls to a bunch of contact addresses
(both technical and marketing/customer service) and tried to get access to
similar data for the bus and subway lines. They .. don't get it. Open data
seems to be scary..

Well done, this project is technically interesting and looks decent enough to
sit in a room that is partially controlled by my SO _and_ it's useful. Full
points.

~~~
VMG
Have a look at the Öffi Android app: <http://oeffi.schildbach.de/>

That guy somehow figured out how to get the data for a lot of cities, Cologne
being one of them. Maybe he knows how to get it.

~~~
derwildemomo
Actually, fyi, the company that is responsible for most of the schedules and
time tables is hacon, and the system they offer is called hafas. If you search
for the term, you'll find that many, if not most, european transportation
providers rely on them for their services. That's why I can search for a train
in suburban france using my deutsche bahn-iphone app. it would only be a
matter of understanding that one api and the data would be open ( without any
screen-scraping or other hacks involved ).

~~~
derda
A friend of mine started to reverse engineer the API, that the DB-Navigator
App uses, as it covers pretty much every public transport in Germany and at
least trains (and sometimes trams and buses) in all of Europe. It can even
give you a route to Pjönyang, North Korea. I don't know how successful he has,
though.

------
SkyMarshal
Great hack. Slight diversion but I just bought that router a few weeks ago,
flashed it with Tomato Speedmod firmware [2], and love it. First router I've
owned in years that is fast, has no lag, no drops, no hangups, and is
completely trouble free. Plus, Linux (ssh, etc). I think that's due to the
combination of stable, reliable hardware and continually evolving OSS firmware
[1][2][3][4]

It also occurs to me the extent to which software can squeeze every ounce of
power and performance out of even old hardware, but requires time to evolve
and optimize (the last 20% of performance/reliability requires 80% of the
work, but makes a big difference). Hence, this 2004 router is better than any
other router I've owned since then. And I'm not alone in that assessment, as
positive reviews are still rolling in weekly [5][6].

In Bill Gate's day, 640k was enough for any good programmer. Eg, systems were
hardware bound. But now that appears reversed, and in many cases systems don't
reach the hardware's limits simply because the software isn't given enough
time to evolve and optimize. By the time the software gets to, say, 80% of the
hardware capability, the model is discontinued for a shiny new one, but with
software that's starting over again on a new platform.

Thankfully that's not always the case, as with this router, or all of Apple's
products for instance.

1\. Tomato: <http://www.polarcloud.com/tomato>

2\. Tomato speedmod: [http://touristinparadise.blogspot.com/2008/04/linksys-
wrt54g...](http://touristinparadise.blogspot.com/2008/04/linksys-wrt54gl-
routers-improving.html)

3\. OpenWRT: <http://openwrt.org/>

4\. DD-WRT: <http://www.dd-wrt.com/>

5\.
[http://www.newegg.com/Product/Product.aspx?Item=N82E16833124...](http://www.newegg.com/Product/Product.aspx?Item=N82E16833124190)

6\. [http://www.amazon.com/Cisco-Linksys-WRT54GL-Wireless-G-
Broad...](http://www.amazon.com/Cisco-Linksys-WRT54GL-Wireless-G-Broadband-
Router/dp/B000BTL0OA/)

~~~
swah
I bought a "Linksys by Cisco" router thinking "no more generic china routers,
this thing will work so well out of the box yay" and it was crap (WRT160N). I
also had to install DD-WRT in it (because it would slow down after a while),
but most people will just live with a slow router.

~~~
SkyMarshal
I considered that one also, but its Amazon and Newegg reviews made it clear
that despite the fact that the WRT160N is positioned as the successor the
WRT54GL, WRT54GL > WRT160N.

~~~
swah
Bought mine in a physical store! Imagine that

------
bretthopper
Hacker News often leaves me jealous of someone's programming skills, but this
has made me realize that electrical engineering feats more often lead me to
say "I wish I could do that".

~~~
joshu
Start by not being afraid. This stuff is pretty accessible these days.

------
StavrosK
That's a fantastic hack! I have just one question, how did you use stty to
talk to the serial port with Lua? I have a LEGO Mindstorms set I want to
program, and I flashed pbLua on it and am building a little framework to talk
to it, but it's having trouble sending lots of text to the serial port (the
brick freezes).

What I'm doing is similar to what you are (as far as I know, anyway, I'm
pretty new to Lua), which is just opening and writing to the socket. I can
get/send text, but I'm wondering if there's some other mysterious setting I
need to change for it to work. Also, since this is serial over USB, I'm not
sure if it's the same thing at all, actually...

~~~
rogerbinns
> how did you use stty to talk to the serial port with Lua

The stty being used is the command line program. You can find it on any
regular Unix box. It is used to set baud rate, stop bits and similar details,
not to do the actual communication which should work just fine once the
parameters have been set correctly.

~~~
StavrosK
No, I understand that. I'm just unsure whether there's a parameter that can
make my terminal hang or whether it's completely irrelevant due to the USB
connection.

In my Lua code, for example, I have to pause a bit every line, otherwise it
hangs. I'm wondering if that's normal.

------
cpeterso
I thought this article was going to be about how he hid a Linksys WRT54GL _on
the actual buses_ to gather the real-time bus data himself! <:)

One could hide Raspberry Pi devices on the buses that are programmed to
geolocate using Wi-Fi networks along the bus route and then opportunistically
use any open Wi-Fi networks to upload their current position.

~~~
icebraining
Connecting to Wi-Fi on the run is probably not feasible most of the time. DHCP
is slow on most residential routers.

Maybe it could work by cheating (e.g. sending UDP packets to multiple common
IPs of routers, like 192.168.{0,1,2,3}.1, without waiting for DHCP), but the
auth frame exchange alone would probably take too much time.

~~~
pflanze
I haven't tried these tips myself but they are supposedly making access to
wifis from a bus a real possibility: <http://syn.theti.ca/2008/10/25/wifi-
roaming-on-the-move/> .

------
nabilt
Great hack. For the Canadian folks here is the open data initiative with
similar APIs <http://toronto.ca/open>. Likes for Ottawa, Edmonton and
Vancouver are on the right.

[Edit] Direct link for North America
<http://www.nextbus.com/predictor/agencySelector.jsp>

------
matthewowen
Very nice!

I've been very interested in mobile bus times, so I built better mobile sites
for live bus times from:

Oxford - <http://www.oxbus.co.uk>

and

London - <http://londonb.us>

They both harvest live bus arrivals data from the relevant providers, then
send it out based on the user's location - basically, it's a really quick and
easy user experience when you're out and about and want to know how long until
the next bus at a nearby stop.

------
djb_hackernews
Nice, never thought of using a stereo head phone jack as a serial adapter.

Does Lua really have no way to put the current thread to sleep? does that busy
loop affect the routers capabilities to route?

~~~
justincormack
Lua can sleep no problem.

------
stephengillie
The apk you are looking for is One Bus Away. It does this for Seattle only.

------
danielharan
A small ISP could copy this and turn it into a great publicity hack.

Imagine a display that is pre-configured with their router for your address.
That definitely would get press coverage.

------
joshu
I wish there was stuff like wrt54gl with just a bit more hardware IO and
ram/storage. RaspberryPinis halfway there but it is more of a conventional PC.

Maybe something like a beaglebone with half the MHz would be good.

I've been using TP-link 703n for projects - wifi, USB, Ethernet, and about 2x
the storage of a wrt54gl. Different archtecture so half the packages under
openwrt are missing.

~~~
Ecio78
I was just doing some research in the past days for linux/bsd based router (I
need it for OpenVPN), and i found:

\- some lowcost TP-link wifi routers that can use openwrt / ddwrt like the one
you used [1]

\- a Buffalo router that seems to ship already with ddwrt, and of course you
can upgrade it too to newer versions [2]

\- the Miktrotik Routerboard devices, really lowcost but runs a modified linux
os so I dont think they're ok for you (afaik you can just do some scripting)
[3]

\- many appliances that can run pfsense but are not so cheap[4]

I'm still tryin to understand, if I choose a wrt solution, what's best between
openwrt and ddwrt (it seems there are sometimes problem with wifi not working
etc..)

[1] [http://www.tp-link.com/en/products/details/?model=TL-
WR1043N...](http://www.tp-link.com/en/products/details/?model=TL-WR1043ND)

[2] <http://www.dd-wrt.com/wiki/index.php/Buffalo_WZR-HP-G300NH>

[3] <http://routerboard.com/>

[4]
[http://www.applianceshop.eu/index.php/firewalls/opnsense/opn...](http://www.applianceshop.eu/index.php/firewalls/opnsense/opnsense-
wl-pfsense-appliance.html)

~~~
joshu
Main difference is cli vs web, really.

What are you tying to build? You might try a routerstation (pretty buff for a
router) or even PCEngines Alix (which is x86 geode based and has a LOT more
ram and uses CF for storage.)

~~~
Ecio78
I need a VPN endpoint for a small office (max 3 users), unfortunately I must
put it behind another router that allows only tcp/udp port forwarding, so I
cant use pptp or ipsec. I'm thinkin about using one of the above solution as
an OpenVPN appliance.

~~~
joshu
Check into a PCEngines ALIX. You can run full OpenBSD or whatever on them.

Example: [http://www.ebay.com/itm/PC-Engines-Alix-2D2-Full-
Kit-/280832...](http://www.ebay.com/itm/PC-Engines-Alix-2D2-Full-
Kit-/280832935089?pt=COMP_EN_Routers&hash=item4162f284b1#ht_500wt_1413)

Unfortunately, it appears that the Routerstation has been discontinued.

------
drewda
From the headline, I was hoping that this would somehow use the hacked access
point to listen for some sort of WiFi signal from the busses and be able to
measure when they are nearby (rather than fetch that information from a Web
service).

------
peterhajas
Sounds really interesting, but I was unable to read the post at much length.
The mobile version of your site (reading from iPhone) seems to want to
activate strange gestures half the time when I scroll.

------
dfc
[http://blog.jgc.org.nyud.net/2012/03/ambient-bus-arrival-
mon...](http://blog.jgc.org.nyud.net/2012/03/ambient-bus-arrival-monitor-from-
hacked.html)

In case its not up...

~~~
jgrahamc
It'll be up... it's managed by CloudFlare.

~~~
dfc
The first time I tried it was down. I got some error, maybe its because it was
looking for the mobile theme.

FYI, I just received the following:

ERROR

The requested URL could not be retrieved

Sorry, we can't open the web page that you requested because the server
hosting the web page might be unavailable.

Possible solutions:

\- Try again later.

\- Contact the web page administrator.

Error Code: 10005

------
drsim
Totally awesome! I live in London and use the TFL website every day, but had
no idea the live bus departures thing existed.

~~~
peteri
m.countdown.tfl.gov.uk is the mobile version which last time I looked wasn't
obvious from the website.

------
nivertech
Anybody has a reference for the JSON API referenced in the article?

~~~
mattmillr
He links to the site that uses it. It's not hard at all to use your browser's
developer tools to inspect the requests that site is making and find the one
that returns a JSON list of all the busses for a given stop. Give it a shot,
no reference needed.

------
eliben
Cool hack, nicely done!

------
ktizo
Could you use this data feed to enable ferrying little autonomous quadcopters
around london on the roofs of buses and just get them to make short hops from
bus to bus to save on power when getting about?

