BackgroundSo I have been pondering for ages what to do with my old iPhone 3G, and after finding my steering lock broken on my motorcycle, I have decided to turn it into a GPS tracker to fit to my motorcycle.
Find my phone doesn't seem to work on my jailbroken device, so I have gone for my own implementation.
My solution is this. A python script on the phone will periodically query the CoreLocation subsystem for the phone location and then post the in a RESTlike manner to a django web service running on one of my websites. I won't cover the django web service in this post, but needless to say you can adapt this script to advertise the location of the phone to you in a variety of ways.
Once I have the location, just pasting the coordinates into google maps will show where the phone is located.
iPhone 3G running iOS 4.2.1 Jailbroken
Python ( Cydia )
pyobjc ( Cydia )
OpenSSH ( Cydia )
Some public web server you have access to. ( I host my own, if you don't have access to one, maybe use some other nifty trick / API / twitter to send yourself the location. )
If you haven't already, jailbreak your phone. You can google that separately as I'm not going to cover the details of that. Just remember that if you need to network unlock your phone, pay special attention to the modem firmware you load. The default one that comes with 4.2.1 is not unlockable at this stage without breaking the GPS.
Once jailbroken, use cydia to install Python, Pyobjc, VIM and OpenSSH. Now that we have all the software we need, ssh into your phone, the default username is root and password is alpine.
Get the script http://pastebin.com/mHwigZXT and adapt to you needs. You need to create a web service to receive the coordinates or conjure up some other creative way. I thought about using twitter REST API via python to twit the location.
I have just setup my own django app that is logging the REST calls to a specific url with location coordinates and accuracy. You can go low-tech and just use the apache logs of your server to track your phone as-well. Just pasting the coordinates into google will show you where the phone is.
Get the script http://pastebin.com/mHwigZXT
Name the script without any extension, e.g. "location" ( I had troubles running it from launchctl as location.py )
SCP the script up to your phone : scp location email@example.com:/var/mobile/ ( username root passwd alpine )
SSH into your phone, chmod +x /var/mobile/location and then execute the script manually to check it. It takes a while to load all the objects and location, so be patient. 15 seconds or so at least.
To get your application to launch at boot time and to re-run the script every 15 minutes, you need to create a application plist file and put it in the right location. I have made one for you!
Get the application plist file file from http://pastebin.com/1jdb1d3d
scp that to your phone with:
scp com.my.tracker.plist firstname.lastname@example.org:/System/Library/LaunchDaemons/
reboot the phone.
And thats that. You should now see some calls to your apache server with a URL containing the coordinates of you phone.
Remember to leave WIFI and 3G and location services enabled! ;)
I have integrated the phone into my motorcycle and even wired to up to the bike to let it charge when the bike runs. There is also a small solar panel which charges the phone slowly to extend the life.