?

Log in

No account? Create an account
Android Garage Door Opener, part 2 - brad's life [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Android Garage Door Opener, part 2 [Oct. 26th, 2008|12:06 pm]
Brad Fitzpatrick
[Tags|, , , ]

This is a follow-up to my previous post to say:

SO. FUCKING. AWESOME.

I got it all working. I now have an Android Activity (GarageDoorActivity) which interacts with an Android Service I wrote (InRangeService), letting me start and stop the service's wifi scanning task. The service gets the system WifiManager, holds a WifiLock to keep the radio active, and then does a Wifi scan every couple seconds, looking for my house.

When my house is in range, it does the magic HTTP request to my garage door opener's webserver (HMAC-signed timestamped URL, for non-replayability/forgeability if sniffed) and my garage door opens. Complete with a bunch of fun Toast notifications (like Growl) and Android Notifications (both persistent ongoing notifications for background scanning, and one-time notifications for things like the garage door actually opening).

I just threw on some shoes and hopped on my motorcycle to do a test lap around the neighborhood. When I got to the corner, I pulled up the activity and press "Start" (aka "Going home now"). A lady on the corner saw me playing with my phone on my motorcycle and said, "The reception's not so good up here." I thanked her, not wanting to explain what I was actually doing.

I then finished the lap around the block and the garage door started opening a few houses away. By the time I pulled up, I could already back the bike into the garage. HELL YES.

Update 2008-11-16: The source code is now available.
LinkReply

Comments:
[User Picture]From: brad
2008-10-26 08:22 pm (UTC)
No, like Mart said below, starting the service just means starting the search for my house, not opening the garage door immediately.

And now the next step (briefly alluded to in the previous LJ post) is to automatically start the background service based on conditions, such as my common case:

-- I come home sitting on the Google shuttle for 30-60 minutes, with the Google shuttle's Wi-Fi in range. this is between, say, 4pm and 8pm.
-- Suddenly the Google shuttle wifi disappears, so I must be off the shuttle now and walking a half block to where I park my motorcycle.
-- The service turns on now, at least for 10 minutes (it takes about 5 minutes to motorcycle home), assuming I'm heading home

So in that common case, I do nothing: my phone notices my common case (going home) and opens it when I approach.

In the lesser common case, like I just did now: I met a friend for brunch. When I was putting on my helmet, I pushed the "Start" button on my phone before I put on my gloves. When I got home in 10 minutes, the garage opened.

(Reply) (Parent) (Thread)
[User Picture]From: ciphergoth
2008-10-26 08:25 pm (UTC)
ooooh! OK, yes, that is super neat :-)
(Reply) (Parent) (Thread)
[User Picture]From: jwz
2008-10-26 08:26 pm (UTC)
This is kind of awesome.

I love the idea of this expert system tracking you: "you appear to be on a bus in the evening. Would you like to go to DEFCON GARAGE DOOR now?"
(Reply) (Parent) (Thread)
[User Picture]From: bandicoot
2008-10-26 08:50 pm (UTC)
Can't you combine it with GPS data so the garage door just opens when you get close enough?
(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 08:51 pm (UTC)
In theory, but the GPS kinda blows even with a direct view of the sky. I don't trust it to work in my pocket at all.
(Reply) (Parent) (Thread)
[User Picture]From: mart
2008-10-26 10:21 pm (UTC)

I've found in the past that non-assisted GPS has real trouble getting going without an unobstructed view of the sky, but once it's got going it'll work fine in my pocket. Not sure if that applies to a GPS reciever embedded in a load of other transmitters and electronics, though, and kinda sucks for your "I'm heading home right now" use-case. Hopefully once they get the assisted GPS working it'll be better, though.

(Reply) (Parent) (Thread)
From: (Anonymous)
2008-10-28 07:19 am (UTC)
What about using cellid? You must have GSM/UMTS radio on anyway (well, if you want to use your G1 as phone), so why not just pull cell ids and start the wifi scanning when you are in your "home cell"?
(Reply) (Parent) (Thread)
[User Picture]From: mart
2008-10-26 10:18 pm (UTC)

Does Google really only have one vehicle, or do all of them have something in common that you can use to recognise them?

(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 10:56 pm (UTC)
There are tons of them. They all have the same SSID, though.
(Reply) (Parent) (Thread)
[User Picture]From: ellenlouise
2008-10-27 10:10 am (UTC)

ohmygod you get to go home at 4pm sometimes?

i assume you can also do this the old fashioned way in case there's a blackout?
(Reply) (Parent) (Thread)
From: (Anonymous)
2008-10-28 12:38 am (UTC)

What about more?

You could add another layer of geekiness just to make sure: (assuming you could have automatic pick-up when it's from your server and that you have an earpiece)
when you approach your house, your webserver gives you a call to ask confirmation with a nice sexy voice, a little bit of voice recognition for "yes", "no" and/or a password and you're good to go, no?

Maybe too far :)

But good job otherwise! I really love the multiple steps involved in doing it.

Question though: couldn't you do it only on the server's side by catching when your phone's MAC address is connecting to your WAP? I know it's missing the point of the Android app, but for people who don't have an Android phone, I suppose that could be another way of doing something similar.
(Reply) (Parent) (Thread)