All info can be found here: GPS Tracking @ Pre Dev Wiki
This little modification will allow you to track your Palm Pre if it ever gets lost or stolen. Just ask this guy what he thinks about GPS tracking on his iPhone.
After implementing this GPS tracking method, your Pre will email you updates with GPS coordinates based on a predefined schedule. The email you receive will contain the Pre’s battery information as well as a Google Maps link of where the GPS coordinates are pointing to.
To start, you’ll need to have a rooted Pre with SSH access.
Instructions:
- Mount the file system with read-write access.
mount -o remount,rw /
- Make a directory for the GPS tracking script we’re about to make.
mkdir /home/scripts
- Add the code below to the beginning of the /etc/event.d/crond to enable the cron daemon at startup.
start on stopped configure stop on runlevel [!2] description "crond"
- Create a crontab entry and schedule the tracking script to run. NOTE: I’m using nano as the text editor. If you do not have nano, you can install it using the Optware package feed, or just use vi as the editor.
mkdir -p /etc/cron/crontabs nano -w /etc/cron/crontabs/root
Add the following to /etc/cron/crontabs/root:
*/5 * * * * /home/scripts/track.sh
The */5 means the script will run every time the number of minutes is divisible by 5. E.g. at 5, 10, 15 minutes, etc. Increase the denominator for less frequent updates.
- Finally, create the track.sh script in the /home/scripts directory created in step 2.
nano -w /home/scripts/track.sh
Copy/paste the code below, but be sure to edit line 2 to include your email address
#!/bin/sh DEST=YOUR_USERID@DOMAIN.com pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{"appId": "ILovePalm", "subscribe": true}' 2>&1 | tail -1 | cut -d, -f4,5,8 | sed -r 's/[^-\.0-9,]//g') lat=$(echo $pos | cut -d, -f1) lon=$(echo $pos | cut -d, -f2) spd=$(echo $pos | cut -d, -f3) bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//') now=$(date) # Enable this below if you want to keep logs - not sure where to write them /var/home/root not the best place. # echo $now,$lat,$lon,$spd,$bat >>mygpsdata.log #Build a message variable for all the data to be logged. msg=$(echo $now,$lat,$lon,$spd,$bat ) #Build message content to be sent msg2=$(echo $now Speed:$spd Battery Level:$bat URL http://maps.google.com/maps?q=$lat%2C$lon) ret1=$(luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{"recipientJSONArray": [{"value": "'${DEST}'", "contactDisplay": "'${DEST}'", "prefix": "to$A", "identifier": "palm_anon_element_8"}], "messageText": "'"$msg2"'"}' 2>&1) exit - Reboot your phone to start the cron daemon and you’re finished. You should now see emails coming into your inbox with the GPS coordinates of your Pre. I just archive the emails in Gmail to keep my inbox from becoming cluttered.
Here’s the tracking in action:




{ 1 trackback }
{ 12 comments… read them below or add one }
Just as a caveat – copy/pasting this in nano or vi, even via ssh in the terminal, “broke” (wrapped) some of the longer lines in this. Once I cleaned up the line breaks this worked nicely.
Hey, i’ve been trying to get crond to work while the phone is asleep (eg the screen is off but it’s really on). this method nor using the ipkg-opt crond seams to allow a process to while the screen is off.
Update http://predev.wikidot.com/crond if you know how to fix this
corq – Thanks for pointing that out. That’s the same problem I had at one point. The solution is to use “nano -w”; I’ve updated the post with this info.
Eric – Unfortunately, it seems like that’s just the way things are. When the phone is charging, the emails get sent every 5 minutes. When it’s not, cron seems to run the job sporadically. The variance opens up to 5-20 minutes.
I added a bit more to this script to allow someone to send a text message to my pre with a “secret” word. when my pre gets the text message, it replies back to the sending phone with the gps coordinates embedded in a googlemap URL. you still get emailed the google URL every 5 minutes as well.
if anyone’s interested, send me an email!
Mike Kuriger
as for cron, it seems the entire OS is put to sleep when the power management daemon shuts the screen off. I found that if I kill powerd (initctl stop powerd) cron works great. However, you can’t shut the screen off anymore. Hopefully someone comes up with a way for cron (or some other job scheduler) to wake the pre up in the background
Mike, don’t see your email, but would be interested in the secret txt!
my email is my post name AT houseofraymond dot com
Since PalmPre battery is pretty bad, I have GPS off to save battery. In order for this to work I have added calls to turn on GPS before and after this code.
# make sure gps is on
luna-send -n 1 palm://com.palm.location/setUseGps {\"useGps\":\"true\"} >/dev/null
# wait for 1min so gps gets a lock
sleep 60
# the rest of the code from the top of this article.
# disable gps
luna-send -n 1 palm://com.palm.location/setUseGps {\"useGps\":\"false\"} >/dev/null
Did anyone figure out how to use mail API instead of text message to send mail?.
The stderr redirection part got cut off in my post, here is the full command including it
luna-send -n 1 palm://com.palm.location/setUseGps {\”useGps\”:\”true\”} >/dev/null 2>&1
luna-send -n 1 palm://com.palm.location/setUseGps {\”useGps\”:\”false\”} >/dev/null 2>&1
Mike,
I would also like to get your mod to this. If possible could you include aselvan’s code to turn on the GPS?
email: my name at hotmail dot com
Thank you!
Hey Mike,
I would love to have that feature for my Pre as well. I dont know about anyone else but it would give me a great sense of security.
email: lerocky AT yahoo dot com
I followed every instruction to the letter, and been going over it for the past 2 days. Still not working >.<
email = lerocky at yahoo dot com