TUAW Responds: iPhone LoJack
Way back, one of our readers begged for an iPhone LoJack solution. He wanted his iPhone to "call home" regularly in case of loss or, let's be more realistic, theft. Over the past week, I finally had a chance to give this request some time, and I put together findme. It's a command-line program that returns the location of the cell phone tower nearest to your iPhone. When run, it tells you the tower id, plus its latitude and longitude courtesy of Google Maps.
Still, how to get the location report to a place you can get it... but nobody else can... and without receiving a zillion SMSes? For this part of the puzzle, enter Twitter. Twitter dev Britt Selvitelle helped walk me through the setup for a private account that allows your iPhone to phone home but keeps the location data relatively secure.
To do this, create a new Twitter account just for your iPhone (it will need its own unique email address, separate from your main account, so have one handy). Open the Settings panel, and look for the "Protect My Updates" checkbox. It's towards the bottom of the page, just above the Save button. Check this and click Save. With protected updates, only the Twitter users you approve will see the updates for this iPhone-only account (just you? you + spouse? spouse, kids, and "special friends?" Up to you).
Update: I've put an updated version of findme (findme-better) into the TUAW folder on my site. Please let me know if this works better for location for you. To use, just copy to your iPhone (you may have to use Firefox if you get errors after downloading with Safari), rename to "findme" and replace the original findme.
After creating your phone's Twitter account, you're ready to set up your iPhone to tweet in on a regular basis. Here's how.
1. Install findme Add findme to your local binaries folder. Under 1.1.3, I've been using /var/root/bin for my utilities. If you use another location, substitute that path for mine. Make sure to chmod 755 findme so that it can be executed.
2. Make sure you have curl It's a standard part of the BSD distribution, if memory serves. You'll need it to contact Twitter. Your iPhone will only be able to call in via curl and Twitter if it has Internet access, through EDGE or WiFi.
3. Create a tweet shell script Copy the following text into a new text file, and add it to your binaries folder.
#! /bin/sh
curl --basic --user username:password \
--data status="`/var/root/bin/findme`" \
http://twitter.com/statuses/update.xml
Use the proper path to findme and substitute your actual username and password. Make the file executable, i.e.
chmod 755 tweet
4. Create a launch daemon In /System/Library/LaunchDaemons, you'll find a simple daemon that runs once a day, called com.apple.daily.plist. Copy this to com.sadun.tweet.plist, and edit it as follows:
- Update the Label to com.sadun.tweet.
- Kill the two lines that relate to "nice". You don't want your lojack to be usurped by other processes.
- Change the program arguments to /var/root/bin/tweet.
- Change the start interval from 86400, according to your needs. 86400 is once a day (60 seconds * 60 minute * 24 hours). Right now, I have mine running every ten minutes (600) because I needed to check that the LaunchDaemon was functioning properly.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sadun.tweet</string>
<key>ProgramArguments</key>
<array>
<string>/var/root/bin/tweet</string>
</array>
<key>StartInterval</key>
<integer>600</integer>
</dict>
</plist>
5. Reboot. This allows our iPhone to restart, loading your new launch daemon.
The findme software was written around material orginated by the iPhone dev team and by Hisper of the Google Maps online developer forum, and was helped by Saurik -- because the iPhone's built in host name resolution is horrible. Thanks also to aCujo for his help. The Twitter curl calls are courtesy of Britt's brilliant assistance. You can drop him a note to say thank you. Thanks also go to Mike Rose, whose idea it was to use Twitter instead of SMS.
Tip: If you find that your tweets are full of "Location Not Found" messages, edit the tweet shell script and duplicate the curl call. This runs the call twice. Usually the "Location Not Found" message goes away the second time.
Another Tip: If you're traveling across the country, change your start interval to 15 minutes or a half hour and use a public Twitter account. (Remember to reboot after making changes to the Launch Daemon). Your friends will be able to track your progress using the Google Maps URL that's tinyURL'ed into each tweet.
Enjoy your newfound location awareness!


![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 7)
Bassir said 4:20PM on 2-21-2008
Next, can you make it tell me when I'm hungry or have to go to the bathroom?
Reply
Lucky888 said 2:01AM on 2-22-2008
Bassir,
If it could tell you when you were hungry you would be picking your nose and eating your buggers more often than you do...
Chris said 4:23PM on 2-21-2008
Apple just updated iTunes
Reply
blinkcowz182 said 5:01PM on 2-21-2008
7.6.1 downloading now!
kirankonathala said 4:35PM on 2-21-2008
That was me who bugged Erica for such a solution cos' my friend lost his iPhone in a matter of few seconds and I couldn't seee him cry :( But yeah, thanks a ton Erica :) you rock big time!!
Reply
Charles said 4:36PM on 2-21-2008
Wow.
I've resisted jailbreaking my iPhone so far (and with the SDK coming out in the next eight days (ha!), I still may not), but this is quite tempting.
Reply
Bassir said 4:57PM on 2-21-2008
I've been tempted for months now, in anticipation of the SDK, and now more than ever I'm being tempted... I need third party applications.
Shannon Hicks said 4:43PM on 2-21-2008
OMG! Finally, a decent solution to photo geocaching! My cell can get a signal pretty much anywhere. Just sync the phone data with the picture timestamps, and you're good to go!
Reply
Michael said 5:06PM on 2-21-2008
Okay - pretty cool solution to get your iPhone to send geo data back to you. Let's continue with the theft scenario however:
- Your iPhone gets stolen
- You've setup your iPhone to 'phone' home twice a day (once at 8.00AM and once at 8.00PM)
- Your iPhone was stolen around 10.00 AM
- You wait until 8.00PM for the message and sure enough, it works, you have a location
Now what? The location is approximate from 50 feet to a quarter mile based on cellular triangulation and wifi access points. How are you supposed to locate your phone exactly?
Reply
Michael Rose said 5:47PM on 2-21-2008
Interesting point. 1x a day may be too low for realistic tracking... I would be curious if anyone with a law-enforcement background can comment on the usefulness of nearest-tower data.
Fritz Laurel said 5:57PM on 2-21-2008
I would think you would collect multiple days of data to the point where you can build a usage profile. For that, getting the iPhone to phone home at random intervals would be best. If you can capture someone at home and then at work, for example, you can narrow it down quite a bit.
Maybe you'd have to track them to their neighborhood and then go door to door, asking a neighbor who works at XYZ company or something.
Once you have the perp's house, you might be able to get the cops involved?
Just thinking out loud.
Or, you could just buy some insurance. But, then you wouldn't get to use this awesome idea (I LOVE this idea!).
Cheers,
FL
Fritz Laurel said 6:07PM on 2-21-2008
Of course, all of this assumes the thief doesn't swap SIMs on you or wipe the phone right away...
Robert said 6:17PM on 2-21-2008
With a little bit of ingenuity, a website could be created to say if the phone was actually stolen, and have the phone update only if the page says to. If it says the phone is stolen, a photo could be taken at a set interval and uploaded, along with specifying the location, in hopes that you could snag a pic of the thief.
Reply
Maria said 6:26PM on 2-21-2008
I don't even have an iPhone or a need for this solution, but I agree that it ROCKS!
Reply
WickDC said 5:12PM on 2-21-2008
NICE! I think the tracking for friends and geo data back is probably more useful than the LoJack tho. :) Erica - any plans to make a GUI for this? It'd also be super cool if it could also save the location data and timestamp into a local database instead of Twitter. It would be great to have that as GPS data (well, semi-accurate obviously) on a trip to time stamp along with photos. I've held back on purchasing a GPS tracker/saver with this, but there's software to put geocoding into images based on the times from an outside database.
Reply
dansays said 5:20PM on 2-21-2008
If you're pinging Twitter, why not have it watch for a special code that would trigger a "stolen/lost" mode, a la Undercover. Instead of just sending geo data, automatically snap and upload photos to Flickr.
Reply
Michael Rose said 8:42PM on 2-21-2008
At the moment, the app is only sending TO twitter, not reading messages from. A trigger message won't work, unfortunately.
YodaMac said 5:19PM on 2-21-2008
I guess you'd go to the location and start calling your iPhone and listen for it to ring to know who has it... unless the thief has already changed the ring tone.
Reply
gldfsh419 said 5:26PM on 2-21-2008
Yeah... I agree that it's cool, but I'm a bit perplexed on exactly how this will lead to stolen iPhone recovery.
Reply
Eddie said 5:26PM on 2-21-2008
What'd be great is if someone picked this up and set the app to communicate w/ a custom website. Then you could login to the site, and tell the app to update you, say, hourly. Now you have hourly updates on where your iphone is going (creepy?). In bigger cities the maps location works almost exactly (ny here).
Reply