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:


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.

[User Picture]From: mart
2008-10-26 07:56 pm (UTC)

Presumably in practice this would be activated before Brad heads home from somewhere else, so the extra stop wouldn't be necessary. I assume he did it this way for the test just because home was both the source and the destination.

(Reply) (Parent) (Thread)
[User Picture]From: ciphergoth
2008-10-26 08:02 pm (UTC)
But that means the door sits open throughout his journey, which seems to defeat the purpose...
(Reply) (Parent) (Thread)
[User Picture]From: mart
2008-10-26 08:06 pm (UTC)

The previous version was as you describe; you had to pull the phone out while near the house and explicitly open the door. The thing that's new about Brad's Android app is that it figures out using wi-fi signals when Brad is approaching his house, so even if he turns it on an hour before it won't actually open until he's close by. This isn't possible on other phones because they don't let you get access to the wi-fi bits to do AP scanning.

(Reply) (Parent) (Thread)
From: (Anonymous)
2008-11-19 03:36 am (UTC)

Re: Purpose

I think you're misunderstanding... The service automatically checks for his wifi, and only after it finds his house's wifi does it connect and send the request... Unless someone deviously places an access point spoofing his AP's MAC address somewhere on his way home, he's reasonably safe.
(Reply) (Parent) (Thread)