<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wilderf353</id>
	<title>WebOS Internals - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wilderf353"/>
	<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/wiki/Special:Contributions/Wilderf353"/>
	<updated>2026-04-15T07:46:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=USBnet_networking_setup&amp;diff=6584</id>
		<title>USBnet networking setup</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=USBnet_networking_setup&amp;diff=6584"/>
		<updated>2009-10-19T14:44:34Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: /* On Windows XP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;USBnet allows you to create an IP network over the USB cable. This will allow you to talk to your Pre without WiFi or Bluetooth, and it keeps the battery charged.&lt;br /&gt;
&lt;br /&gt;
This page is a duplicate of [[USBnet Setup]]&lt;br /&gt;
&lt;br /&gt;
== On Your Linux-Accessed Pre==&lt;br /&gt;
&lt;br /&gt;
run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
usbnet enable&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
as root and then restart the device as instructed. When it comes back up, run 'ifconfig' and verify you now have a usb0 interface. Mine had the IP of 192.168.0.202.  The IP can be changed in /etc/network/interfaces.  After a change, bounce the usb0 interface: ifdown usb0; ifup usb0&lt;br /&gt;
&lt;br /&gt;
== Optional Setup to enable DHCP (so you don't have to set the IP address below)==&lt;br /&gt;
# Edit /etc/dnsmasq.palm.conf&lt;br /&gt;
# Add interface=usb0 below the existing interface line&lt;br /&gt;
# Add dhcp-range=192.168.0.11,192.168.0.12,12h below the existing dhcp-range&lt;br /&gt;
# Restart the dnsmasq process: stop dnsmasq; start dnsmasq&lt;br /&gt;
&lt;br /&gt;
== On Windows XP==&lt;br /&gt;
First: If you have previously installed Novacom on this machine, bring up Windows Task Manager before proceeding.  Once you install USBnet below, you may discover a conflict between USBnet and novacomd where the novacomd process will consume lots of CPU and your machine will become very unresponsive.  Since you have Task Manager up already, you can easily use it to kill novacomd if this occurs.&lt;br /&gt;
# Download the driver here: [http://gitorious.org/webos-internals/usbnet-pre/blobs/raw/master/windows/usbnet-pre.inf usbnet-pre windows driver(32 bit)] or [http://gitorious.org/webos-internals/usbnet-pre/blobs/raw/master/windows/usbnet-pre-64.inf usbnet-pre windows driver(64 bit)] and save the file to disk as usbnet-pre.inf&lt;br /&gt;
# Plug the Pre into your computer. The Add New Hardware Wizard should come up, asking to install an ethernet gadget.&lt;br /&gt;
# Follow detailed instructions (screenshots and all) here if you are unfamiliar with installing drivers: [http://docwiki.gumstix.org/index.php/Windows_XP_usbnet Windows XP USBnet install]&lt;br /&gt;
# When you finish, you should have a network setup. Goto &amp;quot;Network Connections&amp;quot; via Network Places or the Control Panel&lt;br /&gt;
# Right-click on the new network, which probably be named Local Area Connection 2&lt;br /&gt;
# Select Properties&lt;br /&gt;
# Double click on Internet Protocol (TCP/IP)&lt;br /&gt;
# Click Advanced&lt;br /&gt;
# UNCheck Automatic metric, put 100 in its place.  This will keep Windows from attempting to [http://support.microsoft.com/default.aspx/kb/299540 route] traffic over the Pre (it won't work anyway)&lt;br /&gt;
# Click OK&lt;br /&gt;
# If you did not enable DHCP, you will need to set an IP address manually:&lt;br /&gt;
 # Set your IP address as 192.168.0.203 ( could be anything except 192.168.0.202, assuming this is the Pre's address)&lt;br /&gt;
 # Subnet mask: 255.255.255.0&lt;br /&gt;
 # Default Gateway: 192.168.0.202 (your Pre's address for the usb0 interface)&lt;br /&gt;
 # Set DNS to your preferred servers. Addresses are not currently resolving for me, regardless of the server I use&lt;br /&gt;
# Hit OK&lt;br /&gt;
&lt;br /&gt;
The network should now be setup. To verify, ssh to 192.168.0.202, and you should be prompted for a login.&lt;br /&gt;
&lt;br /&gt;
=== Notes:===&lt;br /&gt;
* This has only been tested on Windows XP 32 bit. For Windows 2000, you will need an additional download from Microsoft. The link is in the header of the INF file.&lt;br /&gt;
- From zinge: I have several confirmations via the precentral forums that this only works on XP sp3. Sp2 gives &amp;quot;error code 10, the device cannot start&amp;quot;. Has anyone followed this process and had it work on XP sp2? Update: Upgraded to SP3 on my laptop, and it immediately started working.&lt;br /&gt;
* The 64 bit driver is unverified at this point, but I think it works.&lt;br /&gt;
* wayne47: I was having all kinds of issues with this on my WinXP notebook.  Clicking on the //safely remove hardware// icon in the tray indicated two devices associated with the Pre: Novacom and a USB drive.  Stopping the Novacom service resolved the issues.  Note that I need to do this each time that I attach the Pre via USB.&lt;br /&gt;
&lt;br /&gt;
== On Mac OS X==&lt;br /&gt;
mdklein notes that as of 1.0.4 the g_composite driver appears to only operate usbnet in rndis mode which is not the method OS-X includes. He has made a version that implements CDC-ECM, but it breaks a few other things. Working on this.&lt;br /&gt;
 &lt;br /&gt;
Allegedly, Mac OS X 10.4 should create a usb0 interface after you plug in a usbnet enabled pre. 10.5 needs a modified driver, which is not working for me (and carazy) yet.&lt;br /&gt;
See http://bugcommunity.com/wiki/index.php/Start_Guide_Mac_OS_X_10.5 for more details.&lt;br /&gt;
&lt;br /&gt;
== Windows Vista (64-bit)==&lt;br /&gt;
* If driver/device fails to come online in network sharing center, simply click start-&amp;gt;right click computer-&amp;gt; properties ... Click Device manager and look for the device &amp;quot;Linux USB Ethernet/RNDIS Gadget&amp;quot; you can then right click disable/enable the device. That's all. &lt;br /&gt;
* This device/driver can also be cycled with MS Windows own [http://support.microsoft.com/kb/311272 DevCon] application.&lt;br /&gt;
&lt;br /&gt;
== Windows 7 RC Build 7100 (64-bit)==&lt;br /&gt;
* User lars47 confirms this is working on Windows 7 x64.  Wrestled with the driver installation at first, it would not install, Windows complained of a file in use.  I rebooted, and the next time I plugged in the Pre via USB, it &amp;quot;just worked&amp;quot;.  Unsure if I caused the problem, or if a reboot is required/recommended.&lt;br /&gt;
&lt;br /&gt;
== Linux Support==&lt;br /&gt;
Once usbnet was enabled on the Pre, my Ubuntu 9.04 (64 bit) immediately identified the Pre in the NetworkManager and worked without modification to the OS. It seems to already have a driver that works.&lt;br /&gt;
&lt;br /&gt;
== Return to the next steps page:  [[Next_steps | Next Steps ]].==&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=USBnet_networking_setup&amp;diff=6583</id>
		<title>USBnet networking setup</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=USBnet_networking_setup&amp;diff=6583"/>
		<updated>2009-10-19T14:42:49Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: /* On Windows XP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;USBnet allows you to create an IP network over the USB cable. This will allow you to talk to your Pre without WiFi or Bluetooth, and it keeps the battery charged.&lt;br /&gt;
&lt;br /&gt;
This page is a duplicate of [[USBnet Setup]]&lt;br /&gt;
&lt;br /&gt;
== On Your Linux-Accessed Pre==&lt;br /&gt;
&lt;br /&gt;
run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
usbnet enable&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
as root and then restart the device as instructed. When it comes back up, run 'ifconfig' and verify you now have a usb0 interface. Mine had the IP of 192.168.0.202.  The IP can be changed in /etc/network/interfaces.  After a change, bounce the usb0 interface: ifdown usb0; ifup usb0&lt;br /&gt;
&lt;br /&gt;
== Optional Setup to enable DHCP (so you don't have to set the IP address below)==&lt;br /&gt;
# Edit /etc/dnsmasq.palm.conf&lt;br /&gt;
# Add interface=usb0 below the existing interface line&lt;br /&gt;
# Add dhcp-range=192.168.0.11,192.168.0.12,12h below the existing dhcp-range&lt;br /&gt;
# Restart the dnsmasq process: stop dnsmasq; start dnsmasq&lt;br /&gt;
&lt;br /&gt;
== On Windows XP==&lt;br /&gt;
First: If you have previously installed Novacom on this machine, bring up Windows Task Manager before proceeding.  You may discover a conflict between USBnet (once you install it below) and novacomd where the novacomd process will consume lots of CPU and your machine will become very unresponsive.  Since you have Task Manager up already, you can easily use it to kill novacomd if this occurs.&lt;br /&gt;
# Download the driver here: [http://gitorious.org/webos-internals/usbnet-pre/blobs/raw/master/windows/usbnet-pre.inf usbnet-pre windows driver(32 bit)] or [http://gitorious.org/webos-internals/usbnet-pre/blobs/raw/master/windows/usbnet-pre-64.inf usbnet-pre windows driver(64 bit)] and save the file to disk as usbnet-pre.inf&lt;br /&gt;
# Plug the Pre into your computer. The Add New Hardware Wizard should come up, asking to install an ethernet gadget.&lt;br /&gt;
# Follow detailed instructions (screenshots and all) here if you are unfamiliar with installing drivers: [http://docwiki.gumstix.org/index.php/Windows_XP_usbnet Windows XP USBnet install]&lt;br /&gt;
# When you finish, you should have a network setup. Goto &amp;quot;Network Connections&amp;quot; via Network Places or the Control Panel&lt;br /&gt;
# Right-click on the new network, which probably be named Local Area Connection 2&lt;br /&gt;
# Select Properties&lt;br /&gt;
# Double click on Internet Protocol (TCP/IP)&lt;br /&gt;
# Click Advanced&lt;br /&gt;
# UNCheck Automatic metric, put 100 in its place.  This will keep Windows from attempting to [http://support.microsoft.com/default.aspx/kb/299540 route] traffic over the Pre (it won't work anyway)&lt;br /&gt;
# Click OK&lt;br /&gt;
# If you did not enable DHCP, you will need to set an IP address manually:&lt;br /&gt;
 # Set your IP address as 192.168.0.203 ( could be anything except 192.168.0.202, assuming this is the Pre's address)&lt;br /&gt;
 # Subnet mask: 255.255.255.0&lt;br /&gt;
 # Default Gateway: 192.168.0.202 (your Pre's address for the usb0 interface)&lt;br /&gt;
 # Set DNS to your preferred servers. Addresses are not currently resolving for me, regardless of the server I use&lt;br /&gt;
# Hit OK&lt;br /&gt;
&lt;br /&gt;
The network should now be setup. To verify, ssh to 192.168.0.202, and you should be prompted for a login.&lt;br /&gt;
&lt;br /&gt;
=== Notes:===&lt;br /&gt;
* This has only been tested on Windows XP 32 bit. For Windows 2000, you will need an additional download from Microsoft. The link is in the header of the INF file.&lt;br /&gt;
- From zinge: I have several confirmations via the precentral forums that this only works on XP sp3. Sp2 gives &amp;quot;error code 10, the device cannot start&amp;quot;. Has anyone followed this process and had it work on XP sp2? Update: Upgraded to SP3 on my laptop, and it immediately started working.&lt;br /&gt;
* The 64 bit driver is unverified at this point, but I think it works.&lt;br /&gt;
* wayne47: I was having all kinds of issues with this on my WinXP notebook.  Clicking on the //safely remove hardware// icon in the tray indicated two devices associated with the Pre: Novacom and a USB drive.  Stopping the Novacom service resolved the issues.  Note that I need to do this each time that I attach the Pre via USB.&lt;br /&gt;
&lt;br /&gt;
== On Mac OS X==&lt;br /&gt;
mdklein notes that as of 1.0.4 the g_composite driver appears to only operate usbnet in rndis mode which is not the method OS-X includes. He has made a version that implements CDC-ECM, but it breaks a few other things. Working on this.&lt;br /&gt;
 &lt;br /&gt;
Allegedly, Mac OS X 10.4 should create a usb0 interface after you plug in a usbnet enabled pre. 10.5 needs a modified driver, which is not working for me (and carazy) yet.&lt;br /&gt;
See http://bugcommunity.com/wiki/index.php/Start_Guide_Mac_OS_X_10.5 for more details.&lt;br /&gt;
&lt;br /&gt;
== Windows Vista (64-bit)==&lt;br /&gt;
* If driver/device fails to come online in network sharing center, simply click start-&amp;gt;right click computer-&amp;gt; properties ... Click Device manager and look for the device &amp;quot;Linux USB Ethernet/RNDIS Gadget&amp;quot; you can then right click disable/enable the device. That's all. &lt;br /&gt;
* This device/driver can also be cycled with MS Windows own [http://support.microsoft.com/kb/311272 DevCon] application.&lt;br /&gt;
&lt;br /&gt;
== Windows 7 RC Build 7100 (64-bit)==&lt;br /&gt;
* User lars47 confirms this is working on Windows 7 x64.  Wrestled with the driver installation at first, it would not install, Windows complained of a file in use.  I rebooted, and the next time I plugged in the Pre via USB, it &amp;quot;just worked&amp;quot;.  Unsure if I caused the problem, or if a reboot is required/recommended.&lt;br /&gt;
&lt;br /&gt;
== Linux Support==&lt;br /&gt;
Once usbnet was enabled on the Pre, my Ubuntu 9.04 (64 bit) immediately identified the Pre in the NetworkManager and worked without modification to the OS. It seems to already have a driver that works.&lt;br /&gt;
&lt;br /&gt;
== Return to the next steps page:  [[Next_steps | Next Steps ]].==&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5510</id>
		<title>Patch webOS GPS Tracking</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5510"/>
		<updated>2009-09-08T02:49:18Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: /* Email a URL to open Google Maps showing location of phone. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{template:patch}}&lt;br /&gt;
Here is my super happy awesome tracker script!&lt;br /&gt;
&lt;br /&gt;
== Script code ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
SECRET=make up any secret code here&lt;br /&gt;
DEST=put your e-mail address here&lt;br /&gt;
&lt;br /&gt;
track()&lt;br /&gt;
{&lt;br /&gt;
        export IFS=$'\n'&lt;br /&gt;
        for loc in $(luna-send -n 3 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1); do&lt;br /&gt;
                send $(echo $loc|cut -f3- -d,)&lt;br /&gt;
        done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
send()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;Sending Message: $1&amp;quot;&lt;br /&gt;
        msg=$(echo $1| sed s/\&amp;quot;/\\\\\&amp;quot;/g)&lt;br /&gt;
        luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;.timeout 30000&amp;quot; &amp;gt; /tmp/trackersql&lt;br /&gt;
        cmd='SELECT messageText FROM com_palm_pim_FolderEntry WHERE timeStamp &amp;gt; (strftime(&amp;quot;%s000&amp;quot;, &amp;quot;now&amp;quot;)-600000);'&lt;br /&gt;
#       output=$(echo $cmd|sqlite3 /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        output=$(echo $cmd|sqlite3 -init /tmp/trackersql /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        echo $output|grep $SECRET 2&amp;gt; /dev/null &amp;gt; /dev/null&lt;br /&gt;
        status=$?&lt;br /&gt;
&lt;br /&gt;
        if [ $status = 0 ]; then&lt;br /&gt;
                track&lt;br /&gt;
        fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation==&lt;br /&gt;
# mkdir -p /home/scripts&lt;br /&gt;
# Let's say you put the script in /home/scripts/track.sh&lt;br /&gt;
# rootfs_open -w&lt;br /&gt;
# Go [[Crond | here ]] to enable crond.&lt;br /&gt;
# Add the following line to /etc/cron/crontabs/root&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;*/5 * * * * /home/scripts/track.sh&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Now just send the secret code you set in the script to $YOURNUMBER@messaging.sprintpcs.com (without dollar sign but as a ten digit number with area code prefix)&lt;br /&gt;
&amp;gt; Ex: 3335554444@messaging.sprintpcs.com where 333 is your area code, and 5554444 the rest of your phone number.&lt;br /&gt;
and it will send $DEST the GPS data for the device.&lt;br /&gt;
&lt;br /&gt;
Now, just take the latitude and longitude data and generate the URL. As to the other GPS parameter data available we'll have to investigate to see if Google Maps can take those parameters and how they map to the URL. ~Robi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
luna-send -n 1 palm://com.palm.location/getCurrentPosition {}&lt;br /&gt;
** Message: serviceResponse Handling: 2, {&amp;quot;errorCode&amp;quot;:0,&amp;quot;timestamp&amp;quot;:1.245799702311E12,&amp;quot;latitude&amp;quot;:37.48660683631897,&amp;quot;longitude&amp;quot;:-122.23269581794739,&amp;quot;horizAccuracy&amp;quot;:37.947330474853516,&amp;quot;heading&amp;quot;:178,&amp;quot;velocity&amp;quot;:0.75,&amp;quot;altitude&amp;quot;:-13,&amp;quot;vertAccuracy&amp;quot;:24}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which means we can transpose some of that to a Google Maps link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
http://maps.google.com/?ie=UTF8&amp;amp;q=37.48660683631897,-122.23269581794739+(Heading:%20178%0DSpeed:%200.75%20mph)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you know more about the GPS parameters, let us know by updating the page. ~Robi&lt;br /&gt;
&lt;br /&gt;
* Added heading and speed parameters to the URL. If you hover over the pinpoint on the google map, you can see the information, as well as in the info window if you click on the pinpoint. -xluryan&lt;br /&gt;
&lt;br /&gt;
&amp;quot;If [ll=] is used without a query, then the map is centered at the point but no marker or info window is displayed.&amp;quot; To get around this, use q=[Lon,Lat] instead of ll=[Lon,Lat]. I changed the maps link above. -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Troubleshooting Tip:''' Make sure track.sh has the correct file permissions set. To encompass all possibilities, try 'chmod 755 /home/scripts/track.sh'. You can restrict permissions later if you wish. On Windows it's probably easiest to do this through WinSCP (right click&amp;gt;Properties&amp;gt;Permissions).&lt;br /&gt;
&lt;br /&gt;
== Development Ideas==&lt;br /&gt;
1.  Send response as a google maps link that clicked on shows the phones position on a map.&lt;br /&gt;
2.  Find a way to put a hook into message reception so that messages don't have to be checked with a cron job.  Even better if the message could be intercepted before appearing on the phone, it would be a useful way to track a stolen phone.&lt;br /&gt;
3. After implementing the script that emails me every 20 minutes, it occured to me that the following would be great:&lt;br /&gt;
  3a. The ability to log the entries instead of just sending an email, and maintain a preset number of logged entries (say the last 24 entries).&lt;br /&gt;
  3b. Using the original implementation - send a message to the device to have the logged information emailed. This would show a &amp;quot;track&amp;quot; of where the device has been.&lt;br /&gt;
  3c. Control of the number of log entries, and the frequency.&lt;br /&gt;
== Another Simple Method==&lt;br /&gt;
Why not use this script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,8 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f3)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
ret=$(wget -qO- &amp;quot;http://yoursite.com/trackme/$1/requests.php?lat=$lat&amp;amp;lon=$lon&amp;amp;speed=$spd&amp;amp;batt=$bat&amp;quot; | egrep -o '[0-9]+$')&lt;br /&gt;
exit $ret&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have a web server setup with //requests.php// taking '''//lat//''', '''//lon//''', '''//speed//''', and '''//batt//''' arguments. Then it writes them to a file. Use the data however you want. I have mine plug into a google map and show me the data.&lt;br /&gt;
&lt;br /&gt;
Just set up a cron job to call the script every 20 minutes or so. Hardly effects battery life at all :)&lt;br /&gt;
&lt;br /&gt;
Credit to ddoc for info on how to grab battery status. I would still like to find a more efficient way of grabbing battery level rather than searching through the entire message log. Though for now, it works exactly like it should.&lt;br /&gt;
&lt;br /&gt;
Here's the Method for getting battery status:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;Mojo.Service.Request('palm://com.palm.power/com/palm/power/', {method: 'batteryStatusQuery',});&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
-pEEf&lt;br /&gt;
&lt;br /&gt;
== Email a URL to open Google Maps showing location of phone.==&lt;br /&gt;
Below is a code snippet that will send an email with working URL to open Google Map and show you the location of your phone.&lt;br /&gt;
The cron job mentioned above is setup to call this script every 20 minutes on my machine...works great.  I let GMAIL archive them.&lt;br /&gt;
If the phone gets stolen, I can find it as long as it has service.&lt;br /&gt;
&lt;br /&gt;
The larger Accuracy is, the further away the coordinates output will be from your actual position.&lt;br /&gt;
&lt;br /&gt;
Added speed &amp;amp; heading to Google URL. Is there any way to have the sent messages not appear in the Text Messaging app, or to use the shell to email the output via mailx? Until I figure out a built-in mail function, you can use an alternative I'm testing that uses a server's mailx command: echo &amp;quot;$msg2&amp;quot; | /opt/bin/ssh -x user@server /bin/mailx $DEST     -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;modified by wilderf353 on 09-09-01:&amp;lt;/i&amp;gt; &lt;br /&gt;
I modified the original script because the Google URL being sent was getting truncated on my phone and a few other people that posted at forums.precentral.net.  I did some testing and it looks like when you use sendMessageFromCompose, you are limited to a message with less than 136 characters. I shortened the message and added :&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on GPS if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on Location Services if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn GPS back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn Location Services back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added altitude and altitude accuracy information to message&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to only send the message if GPS coordinates have changed since the last run&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to send a message on the hour even if GPS coordinates have not changed&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(NOTE: You will need to add your email address to the script)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
####### Stuff to set&lt;br /&gt;
&lt;br /&gt;
## email address to mail info to&lt;br /&gt;
DEST=johns@gmail.com&lt;br /&gt;
# example: DEST=wsmith@aol.com   (make sure you don't have any spaces)&lt;br /&gt;
&lt;br /&gt;
## send url with embedded heading/speed info&lt;br /&gt;
# we only have ~136 characters to work with. If you embed heading &amp;amp; speed info, you can't &lt;br /&gt;
# include altitude and altitude accuracy information &lt;br /&gt;
# msg_with_heading=0  (don't embed heading/speed info, but include altitude information)&lt;br /&gt;
# msg_with_heading=1  (embed heading/speed info)&lt;br /&gt;
msg_with_heading=0&lt;br /&gt;
&lt;br /&gt;
# run_only_if_diff=0, send a message every time &lt;br /&gt;
# run_only_if_diff=1, send a message only if GPS coords have changed since last run &lt;br /&gt;
run_only_if_diff=1&lt;br /&gt;
&lt;br /&gt;
# file where gps coords should  be stored until next run&lt;br /&gt;
last_gps_coord_file=/tmp/track_coords&lt;br /&gt;
&lt;br /&gt;
# use with run_only_if_diff&lt;br /&gt;
# send_every_hour=1, send a message on the hour, even if the phone hasn't moved&lt;br /&gt;
# send_every_hour=0, don't send a message on the hour&lt;br /&gt;
send_every_hour=1&lt;br /&gt;
&lt;br /&gt;
######&lt;br /&gt;
&lt;br /&gt;
# get current minute and current time&lt;br /&gt;
cur_min=$(date +&amp;quot;%M&amp;quot;)&lt;br /&gt;
now=$(date +&amp;quot;%D %R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# The GPS should be turned on to get an accurate fix...otherwise you get the tower location&lt;br /&gt;
# Is the GPS turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getUseGps '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # gps is on&lt;br /&gt;
   gps_on=1&lt;br /&gt;
else  &lt;br /&gt;
   #gps is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   gps_on=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
   # wait for 60 seconds so gps gets a good lock&lt;br /&gt;
   sleep 60&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Location services must be turned on, or startTracking will not work (you get a {&amp;quot;errorCode&amp;quot;:7})&lt;br /&gt;
# Are locations service turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getAutoLocate '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # location service is on&lt;br /&gt;
   location_service=1&lt;br /&gt;
else  &lt;br /&gt;
   #location service is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   location_service=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Get current coords&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,6,7,8,9,10 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
acc=$(echo $pos | cut -d, -f3 | cut -d. -f1)&lt;br /&gt;
dir=$(echo $pos | cut -d, -f4)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f5)&lt;br /&gt;
alt=$(echo $pos | cut -d, -f6)&lt;br /&gt;
altacc=$(echo $pos | cut -d, -f7 | cut -d. -f1)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
# turn off GPS?&lt;br /&gt;
if [ $gps_on -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # the GPS was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# turn off location service?&lt;br /&gt;
if [ $location_service -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # location service was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# check if we should send a message&lt;br /&gt;
if [ $run_only_if_diff -eq 1 ] &lt;br /&gt;
then&lt;br /&gt;
    # create short coords. &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.4f\n&amp;quot;,$0)&amp;quot; for 4 decimal places (about 30 feet accuracy)&lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.3f\n&amp;quot;,$0)&amp;quot; for 3 decimal places (about 280 feet accuracy)                                                            &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.2f\n&amp;quot;,$0)&amp;quot; for 2 decimal places (about 0.5 miles accuracy)                                                            &lt;br /&gt;
    sh_lat=$(echo $lat |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
    sh_lon=$(echo $lon |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
&lt;br /&gt;
   # does the file with the last coords exist?&lt;br /&gt;
    if [ -f $last_gps_coord_file ]&lt;br /&gt;
    then&lt;br /&gt;
        $(grep &amp;quot;$sh_lat $sh_lon&amp;quot; $last_gps_coord_file &amp;gt; /dev/null)&lt;br /&gt;
        grep_ret=$?&lt;br /&gt;
        if [ $grep_ret -eq 0 ]&lt;br /&gt;
        then&lt;br /&gt;
            # coords match...don't send a message&lt;br /&gt;
            send_message=0&lt;br /&gt;
        else&lt;br /&gt;
            # coords don't match...send a message and update coord file&lt;br /&gt;
            send_message=1 &lt;br /&gt;
            echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file                                                                                                   &lt;br /&gt;
        fi&lt;br /&gt;
    else&lt;br /&gt;
        # there is not a last coords file...create one for next time&lt;br /&gt;
        send_message=1&lt;br /&gt;
        echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file  &lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    # $run_only_if_diff is false, so send a message&lt;br /&gt;
    send_message=1        &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# if configured to send on the hour...is it time?&lt;br /&gt;
if [ $send_every_hour -eq 1 -a $cur_min = &amp;quot;00&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
  send_message=1 &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Enable this below if you want to keep logs - not sure where to write them /var/home/root not the best place.&lt;br /&gt;
# echo $now,$lat,$lon,$acc,$dir,$spd,$alt,$altacc,$bat &amp;gt;&amp;gt;mygpsdata.log&lt;br /&gt;
&lt;br /&gt;
# send the message&lt;br /&gt;
if [ $send_message -eq 1 ]&lt;br /&gt;
then&lt;br /&gt;
    #Build message content to be sent&lt;br /&gt;
    if [ $msg_with_heading -eq 1 ]&lt;br /&gt;
    then&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; Bat:$bat Acc:$acc &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon+(Heading:%20$dir%0DSpeed:%20$spd)&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon&amp;quot; &amp;quot;\n&amp;quot; Bat=$bat,Acc=$acc,Dir=$dir,Spd=$spd,Alt=$alt,AltAcc=$altacc)&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    $(luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has been running every 20 minutes on my phone for the last 4 days, no problem.&lt;br /&gt;
-dld121&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5479</id>
		<title>Patch webOS GPS Tracking</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5479"/>
		<updated>2009-09-07T13:42:15Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: /* Email a URL to open Google Maps showing location of phone. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{template:patch}}&lt;br /&gt;
Here is my super happy awesome tracker script!&lt;br /&gt;
&lt;br /&gt;
== Script code ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
SECRET=make up any secret code here&lt;br /&gt;
DEST=put your e-mail address here&lt;br /&gt;
&lt;br /&gt;
track()&lt;br /&gt;
{&lt;br /&gt;
        export IFS=$'\n'&lt;br /&gt;
        for loc in $(luna-send -n 3 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1); do&lt;br /&gt;
                send $(echo $loc|cut -f3- -d,)&lt;br /&gt;
        done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
send()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;Sending Message: $1&amp;quot;&lt;br /&gt;
        msg=$(echo $1| sed s/\&amp;quot;/\\\\\&amp;quot;/g)&lt;br /&gt;
        luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;.timeout 30000&amp;quot; &amp;gt; /tmp/trackersql&lt;br /&gt;
        cmd='SELECT messageText FROM com_palm_pim_FolderEntry WHERE timeStamp &amp;gt; (strftime(&amp;quot;%s000&amp;quot;, &amp;quot;now&amp;quot;)-600000);'&lt;br /&gt;
#       output=$(echo $cmd|sqlite3 /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        output=$(echo $cmd|sqlite3 -init /tmp/trackersql /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        echo $output|grep $SECRET 2&amp;gt; /dev/null &amp;gt; /dev/null&lt;br /&gt;
        status=$?&lt;br /&gt;
&lt;br /&gt;
        if [ $status = 0 ]; then&lt;br /&gt;
                track&lt;br /&gt;
        fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation==&lt;br /&gt;
# mkdir -p /home/scripts&lt;br /&gt;
# Let's say you put the script in /home/scripts/track.sh&lt;br /&gt;
# rootfs_open -w&lt;br /&gt;
# Go [[Crond | here ]] to enable crond.&lt;br /&gt;
# Add the following line to /etc/cron/crontabs/root&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;*/5 * * * * /home/scripts/track.sh&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Now just send the secret code you set in the script to $YOURNUMBER@messaging.sprintpcs.com (without dollar sign but as a ten digit number with area code prefix)&lt;br /&gt;
&amp;gt; Ex: 3335554444@messaging.sprintpcs.com where 333 is your area code, and 5554444 the rest of your phone number.&lt;br /&gt;
and it will send $DEST the GPS data for the device.&lt;br /&gt;
&lt;br /&gt;
Now, just take the latitude and longitude data and generate the URL. As to the other GPS parameter data available we'll have to investigate to see if Google Maps can take those parameters and how they map to the URL. ~Robi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
luna-send -n 1 palm://com.palm.location/getCurrentPosition {}&lt;br /&gt;
** Message: serviceResponse Handling: 2, {&amp;quot;errorCode&amp;quot;:0,&amp;quot;timestamp&amp;quot;:1.245799702311E12,&amp;quot;latitude&amp;quot;:37.48660683631897,&amp;quot;longitude&amp;quot;:-122.23269581794739,&amp;quot;horizAccuracy&amp;quot;:37.947330474853516,&amp;quot;heading&amp;quot;:178,&amp;quot;velocity&amp;quot;:0.75,&amp;quot;altitude&amp;quot;:-13,&amp;quot;vertAccuracy&amp;quot;:24}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which means we can transpose some of that to a Google Maps link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
http://maps.google.com/?ie=UTF8&amp;amp;q=37.48660683631897,-122.23269581794739+(Heading:%20178%0DSpeed:%200.75%20mph)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you know more about the GPS parameters, let us know by updating the page. ~Robi&lt;br /&gt;
&lt;br /&gt;
* Added heading and speed parameters to the URL. If you hover over the pinpoint on the google map, you can see the information, as well as in the info window if you click on the pinpoint. -xluryan&lt;br /&gt;
&lt;br /&gt;
&amp;quot;If [ll=] is used without a query, then the map is centered at the point but no marker or info window is displayed.&amp;quot; To get around this, use q=[Lon,Lat] instead of ll=[Lon,Lat]. I changed the maps link above. -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Troubleshooting Tip:''' Make sure track.sh has the correct file permissions set. To encompass all possibilities, try 'chmod 755 /home/scripts/track.sh'. You can restrict permissions later if you wish. On Windows it's probably easiest to do this through WinSCP (right click&amp;gt;Properties&amp;gt;Permissions).&lt;br /&gt;
&lt;br /&gt;
== Development Ideas==&lt;br /&gt;
1.  Send response as a google maps link that clicked on shows the phones position on a map.&lt;br /&gt;
2.  Find a way to put a hook into message reception so that messages don't have to be checked with a cron job.  Even better if the message could be intercepted before appearing on the phone, it would be a useful way to track a stolen phone.&lt;br /&gt;
3. After implementing the script that emails me every 20 minutes, it occured to me that the following would be great:&lt;br /&gt;
  3a. The ability to log the entries instead of just sending an email, and maintain a preset number of logged entries (say the last 24 entries).&lt;br /&gt;
  3b. Using the original implementation - send a message to the device to have the logged information emailed. This would show a &amp;quot;track&amp;quot; of where the device has been.&lt;br /&gt;
  3c. Control of the number of log entries, and the frequency.&lt;br /&gt;
== Another Simple Method==&lt;br /&gt;
Why not use this script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,8 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f3)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
ret=$(wget -qO- &amp;quot;http://yoursite.com/trackme/$1/requests.php?lat=$lat&amp;amp;lon=$lon&amp;amp;speed=$spd&amp;amp;batt=$bat&amp;quot; | egrep -o '[0-9]+$')&lt;br /&gt;
exit $ret&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have a web server setup with //requests.php// taking '''//lat//''', '''//lon//''', '''//speed//''', and '''//batt//''' arguments. Then it writes them to a file. Use the data however you want. I have mine plug into a google map and show me the data.&lt;br /&gt;
&lt;br /&gt;
Just set up a cron job to call the script every 20 minutes or so. Hardly effects battery life at all :)&lt;br /&gt;
&lt;br /&gt;
Credit to ddoc for info on how to grab battery status. I would still like to find a more efficient way of grabbing battery level rather than searching through the entire message log. Though for now, it works exactly like it should.&lt;br /&gt;
&lt;br /&gt;
Here's the Method for getting battery status:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;Mojo.Service.Request('palm://com.palm.power/com/palm/power/', {method: 'batteryStatusQuery',});&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
-pEEf&lt;br /&gt;
&lt;br /&gt;
== Email a URL to open Google Maps showing location of phone.==&lt;br /&gt;
Below is a code snippet that will send an email with working URL to open Google Map and show you the location of your phone.&lt;br /&gt;
The cron job mentioned above is setup to call this script every 20 minutes on my machine...works great.  I let GMAIL archive them.&lt;br /&gt;
If the phone gets stolen, I can find it as long as it has service.&lt;br /&gt;
&lt;br /&gt;
The larger Accuracy is, the further away the coordinates output will be from your actual position.&lt;br /&gt;
&lt;br /&gt;
Added speed &amp;amp; heading to Google URL. Is there any way to have the sent messages not appear in the Text Messaging app, or to use the shell to email the output via mailx? Until I figure out a built-in mail function, you can use an alternative I'm testing that uses a server's mailx command: echo &amp;quot;$msg2&amp;quot; | /opt/bin/ssh -x user@server /bin/mailx $DEST     -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;modified by wilderf353 on 09-09-01:&amp;lt;/i&amp;gt; &lt;br /&gt;
I modified the original script because the Google URL being sent was getting truncated on my phone and a few other people that posted at forums.precentral.net.  I did some testing and it looks like when you use sendMessageFromCompose, you are limited to a message with less than 136 characters. I shortened the message and added :&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on GPS if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on Location Services if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn GPS back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn Location Services back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added altitude and altitude accuracy information to message&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to only send the message if GPS coordinates have changed since the last run&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to send a message on the hour even if GPS coordinates have not changed&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(NOTE: You will need to add your email address to the script)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
####### Stuff to set&lt;br /&gt;
&lt;br /&gt;
## email address to mail info to&lt;br /&gt;
DEST=johns@gmail.com&lt;br /&gt;
# example: DEST=wsmith@aol.com   (make sure you don't have any spaces)&lt;br /&gt;
&lt;br /&gt;
## send url with embedded heading/speed info&lt;br /&gt;
# we only have ~136 characters to work with. If you embed heading &amp;amp; speed info, you can't &lt;br /&gt;
# include altitude and altitude accuracy information &lt;br /&gt;
# msg_with_heading=0  (don't embed heading/speed info, but include altitude information)&lt;br /&gt;
# msg_with_heading=1  (embed heading/speed info)&lt;br /&gt;
msg_with_heading=0&lt;br /&gt;
&lt;br /&gt;
# run_only_if_diff=0, send a message every time &lt;br /&gt;
# run_only_if_diff=1, send a message only if GPS coords have changed since last run &lt;br /&gt;
run_only_if_diff=1&lt;br /&gt;
&lt;br /&gt;
# file where gps coords should  be stored until next run&lt;br /&gt;
last_gps_coord_file=/tmp/track_coords&lt;br /&gt;
&lt;br /&gt;
# use with run_only_if_diff&lt;br /&gt;
# send_every_hour=1, send a message on the hour, even if the phone hasn't moved&lt;br /&gt;
# send_every_hour=0, don't send a message on the hour&lt;br /&gt;
send_every_hour=1&lt;br /&gt;
&lt;br /&gt;
######&lt;br /&gt;
&lt;br /&gt;
# get current minute and current time&lt;br /&gt;
cur_min=$(date +&amp;quot;%M&amp;quot;)&lt;br /&gt;
now=$(date +&amp;quot;%D %R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# The GPS should be turned on to get an accurate fix...otherwise you get the tower location&lt;br /&gt;
# Is the GPS turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getUseGps '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # gps is on&lt;br /&gt;
   gps_on=1&lt;br /&gt;
else  &lt;br /&gt;
   #gps is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   gps_on=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
   # wait for 60 seconds so gps gets a good lock&lt;br /&gt;
   # sleep 60&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Location services must be turned on, or startTracking will not work (you get a {&amp;quot;errorCode&amp;quot;:7})&lt;br /&gt;
# Are locations service turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getAutoLocate '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # location service is on&lt;br /&gt;
   location_service=1&lt;br /&gt;
else  &lt;br /&gt;
   #location service is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   location_service=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Get current coords&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,6,7,8,9,10 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
acc=$(echo $pos | cut -d, -f3 | cut -d. -f1)&lt;br /&gt;
dir=$(echo $pos | cut -d, -f4)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f5)&lt;br /&gt;
alt=$(echo $pos | cut -d, -f6)&lt;br /&gt;
altacc=$(echo $pos | cut -d, -f7 | cut -d. -f1)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
# turn off GPS?&lt;br /&gt;
if [ $gps_on -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # the GPS was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# turn off location service?&lt;br /&gt;
if [ $location_service -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # location service was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# check if we should send a message&lt;br /&gt;
if [ $run_only_if_diff -eq 1 ] &lt;br /&gt;
then&lt;br /&gt;
    # create short coords. &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.4f\n&amp;quot;,$0)&amp;quot; for 4 decimal places (about 30 feet accuracy)&lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.3f\n&amp;quot;,$0)&amp;quot; for 3 decimal places (about 280 feet accuracy)                                                            &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.2f\n&amp;quot;,$0)&amp;quot; for 2 decimal places (about 0.5 miles accuracy)                                                            &lt;br /&gt;
    sh_lat=$(echo $lat |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
    sh_lon=$(echo $lon |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
&lt;br /&gt;
   # does the file with the last coords exist?&lt;br /&gt;
    if [ -f $last_gps_coord_file ]&lt;br /&gt;
    then&lt;br /&gt;
        $(grep &amp;quot;$sh_lat $sh_lon&amp;quot; $last_gps_coord_file &amp;gt; /dev/null)&lt;br /&gt;
        grep_ret=$?&lt;br /&gt;
        if [ $grep_ret -eq 0 ]&lt;br /&gt;
        then&lt;br /&gt;
            # coords match...don't send a message&lt;br /&gt;
            send_message=0&lt;br /&gt;
        else&lt;br /&gt;
            # coords don't match...send a message and update coord file&lt;br /&gt;
            send_message=1 &lt;br /&gt;
            echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file                                                                                                   &lt;br /&gt;
        fi&lt;br /&gt;
    else&lt;br /&gt;
        # there is not a last coords file...create one for next time&lt;br /&gt;
        send_message=1&lt;br /&gt;
        echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file  &lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    # $run_only_if_diff is false, so send a message&lt;br /&gt;
    send_message=1        &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# if configured to send on the hour...is it time?&lt;br /&gt;
if [ $send_every_hour -eq 1 -a $cur_min = &amp;quot;00&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
  send_message=1 &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Enable this below if you want to keep logs - not sure where to write them /var/home/root not the best place.&lt;br /&gt;
# echo $now,$lat,$lon,$acc,$dir,$spd,$alt,$altacc,$bat &amp;gt;&amp;gt;mygpsdata.log&lt;br /&gt;
&lt;br /&gt;
# send the message&lt;br /&gt;
if [ $send_message -eq 1 ]&lt;br /&gt;
then&lt;br /&gt;
    #Build message content to be sent&lt;br /&gt;
    if [ $msg_with_heading -eq 1 ]&lt;br /&gt;
    then&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; Bat:$bat Acc:$acc &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon+(Heading:%20$dir%0DSpeed:%20$spd)&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon&amp;quot; &amp;quot;\n&amp;quot; Bat=$bat,Acc=$acc,Dir=$dir,Spd=$spd,Alt=$alt,AltAcc=$altacc)&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    $(luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has been running every 20 minutes on my phone for the last 4 days, no problem.&lt;br /&gt;
-dld121&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5478</id>
		<title>Patch webOS GPS Tracking</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5478"/>
		<updated>2009-09-07T13:33:03Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: /* Email a URL to open Google Maps showing location of phone. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{template:patch}}&lt;br /&gt;
Here is my super happy awesome tracker script!&lt;br /&gt;
&lt;br /&gt;
== Script code ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
SECRET=make up any secret code here&lt;br /&gt;
DEST=put your e-mail address here&lt;br /&gt;
&lt;br /&gt;
track()&lt;br /&gt;
{&lt;br /&gt;
        export IFS=$'\n'&lt;br /&gt;
        for loc in $(luna-send -n 3 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1); do&lt;br /&gt;
                send $(echo $loc|cut -f3- -d,)&lt;br /&gt;
        done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
send()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;Sending Message: $1&amp;quot;&lt;br /&gt;
        msg=$(echo $1| sed s/\&amp;quot;/\\\\\&amp;quot;/g)&lt;br /&gt;
        luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;.timeout 30000&amp;quot; &amp;gt; /tmp/trackersql&lt;br /&gt;
        cmd='SELECT messageText FROM com_palm_pim_FolderEntry WHERE timeStamp &amp;gt; (strftime(&amp;quot;%s000&amp;quot;, &amp;quot;now&amp;quot;)-600000);'&lt;br /&gt;
#       output=$(echo $cmd|sqlite3 /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        output=$(echo $cmd|sqlite3 -init /tmp/trackersql /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        echo $output|grep $SECRET 2&amp;gt; /dev/null &amp;gt; /dev/null&lt;br /&gt;
        status=$?&lt;br /&gt;
&lt;br /&gt;
        if [ $status = 0 ]; then&lt;br /&gt;
                track&lt;br /&gt;
        fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation==&lt;br /&gt;
# mkdir -p /home/scripts&lt;br /&gt;
# Let's say you put the script in /home/scripts/track.sh&lt;br /&gt;
# rootfs_open -w&lt;br /&gt;
# Go [[Crond | here ]] to enable crond.&lt;br /&gt;
# Add the following line to /etc/cron/crontabs/root&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;*/5 * * * * /home/scripts/track.sh&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Now just send the secret code you set in the script to $YOURNUMBER@messaging.sprintpcs.com (without dollar sign but as a ten digit number with area code prefix)&lt;br /&gt;
&amp;gt; Ex: 3335554444@messaging.sprintpcs.com where 333 is your area code, and 5554444 the rest of your phone number.&lt;br /&gt;
and it will send $DEST the GPS data for the device.&lt;br /&gt;
&lt;br /&gt;
Now, just take the latitude and longitude data and generate the URL. As to the other GPS parameter data available we'll have to investigate to see if Google Maps can take those parameters and how they map to the URL. ~Robi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
luna-send -n 1 palm://com.palm.location/getCurrentPosition {}&lt;br /&gt;
** Message: serviceResponse Handling: 2, {&amp;quot;errorCode&amp;quot;:0,&amp;quot;timestamp&amp;quot;:1.245799702311E12,&amp;quot;latitude&amp;quot;:37.48660683631897,&amp;quot;longitude&amp;quot;:-122.23269581794739,&amp;quot;horizAccuracy&amp;quot;:37.947330474853516,&amp;quot;heading&amp;quot;:178,&amp;quot;velocity&amp;quot;:0.75,&amp;quot;altitude&amp;quot;:-13,&amp;quot;vertAccuracy&amp;quot;:24}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which means we can transpose some of that to a Google Maps link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
http://maps.google.com/?ie=UTF8&amp;amp;q=37.48660683631897,-122.23269581794739+(Heading:%20178%0DSpeed:%200.75%20mph)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you know more about the GPS parameters, let us know by updating the page. ~Robi&lt;br /&gt;
&lt;br /&gt;
* Added heading and speed parameters to the URL. If you hover over the pinpoint on the google map, you can see the information, as well as in the info window if you click on the pinpoint. -xluryan&lt;br /&gt;
&lt;br /&gt;
&amp;quot;If [ll=] is used without a query, then the map is centered at the point but no marker or info window is displayed.&amp;quot; To get around this, use q=[Lon,Lat] instead of ll=[Lon,Lat]. I changed the maps link above. -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Troubleshooting Tip:''' Make sure track.sh has the correct file permissions set. To encompass all possibilities, try 'chmod 755 /home/scripts/track.sh'. You can restrict permissions later if you wish. On Windows it's probably easiest to do this through WinSCP (right click&amp;gt;Properties&amp;gt;Permissions).&lt;br /&gt;
&lt;br /&gt;
== Development Ideas==&lt;br /&gt;
1.  Send response as a google maps link that clicked on shows the phones position on a map.&lt;br /&gt;
2.  Find a way to put a hook into message reception so that messages don't have to be checked with a cron job.  Even better if the message could be intercepted before appearing on the phone, it would be a useful way to track a stolen phone.&lt;br /&gt;
3. After implementing the script that emails me every 20 minutes, it occured to me that the following would be great:&lt;br /&gt;
  3a. The ability to log the entries instead of just sending an email, and maintain a preset number of logged entries (say the last 24 entries).&lt;br /&gt;
  3b. Using the original implementation - send a message to the device to have the logged information emailed. This would show a &amp;quot;track&amp;quot; of where the device has been.&lt;br /&gt;
  3c. Control of the number of log entries, and the frequency.&lt;br /&gt;
== Another Simple Method==&lt;br /&gt;
Why not use this script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,8 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f3)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
ret=$(wget -qO- &amp;quot;http://yoursite.com/trackme/$1/requests.php?lat=$lat&amp;amp;lon=$lon&amp;amp;speed=$spd&amp;amp;batt=$bat&amp;quot; | egrep -o '[0-9]+$')&lt;br /&gt;
exit $ret&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have a web server setup with //requests.php// taking '''//lat//''', '''//lon//''', '''//speed//''', and '''//batt//''' arguments. Then it writes them to a file. Use the data however you want. I have mine plug into a google map and show me the data.&lt;br /&gt;
&lt;br /&gt;
Just set up a cron job to call the script every 20 minutes or so. Hardly effects battery life at all :)&lt;br /&gt;
&lt;br /&gt;
Credit to ddoc for info on how to grab battery status. I would still like to find a more efficient way of grabbing battery level rather than searching through the entire message log. Though for now, it works exactly like it should.&lt;br /&gt;
&lt;br /&gt;
Here's the Method for getting battery status:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;Mojo.Service.Request('palm://com.palm.power/com/palm/power/', {method: 'batteryStatusQuery',});&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
-pEEf&lt;br /&gt;
&lt;br /&gt;
== Email a URL to open Google Maps showing location of phone.==&lt;br /&gt;
Below is a code snippet that will send an email with working URL to open Google Map and show you the location of your phone.&lt;br /&gt;
The cron job mentioned above is setup to call this script every 20 minutes on my machine...works great.  I let GMAIL archive them.&lt;br /&gt;
If the phone gets stolen, I can find it as long as it has service.&lt;br /&gt;
&lt;br /&gt;
The larger Accuracy is, the further away the coordinates output will be from your actual position.&lt;br /&gt;
&lt;br /&gt;
Added speed &amp;amp; heading to Google URL. Is there any way to have the sent messages not appear in the Text Messaging app, or to use the shell to email the output via mailx? Until I figure out a built-in mail function, you can use an alternative I'm testing that uses a server's mailx command: echo &amp;quot;$msg2&amp;quot; | /opt/bin/ssh -x user@server /bin/mailx $DEST     -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;modified by wilderf353 on 09-09-01:&amp;lt;/i&amp;gt; &lt;br /&gt;
I modified the original script because the Google URL being sent was getting truncated on my phone and a few other people that posted at forums.precentral.net.  I did some testing and it looks like when you use sendMessageFromCompose, you are limited to a message with less than 136 characters. I shortened the message and added :&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on GPS if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on Location Services if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn GPS back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn Location Services back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added altitude and altitude accuracy information to message&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to only send the message if GPS coordinates have changed&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added the ability to send a message on the hour even if GPS coordinates have not changed&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(NOTE: You will need to add your email address to the script)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
####### Stuff to set&lt;br /&gt;
&lt;br /&gt;
## email address to mail info to&lt;br /&gt;
DEST=johns@gmail.com&lt;br /&gt;
# example: DEST=wsmith@aol.com   (make sure you don't have any spaces)&lt;br /&gt;
&lt;br /&gt;
## send url with embedded heading/speed info&lt;br /&gt;
# we only have ~136 characters to work with. If you embed heading &amp;amp; speed info, you can't &lt;br /&gt;
# include altitude and altitude accuracy information &lt;br /&gt;
# msg_with_heading=0  (don't embed heading/speed info, but include altitude information)&lt;br /&gt;
# msg_with_heading=1  (embed heading/speed info)&lt;br /&gt;
msg_with_heading=0&lt;br /&gt;
&lt;br /&gt;
# run_only_if_diff=0, send a message every time &lt;br /&gt;
# run_only_if_diff=1, send a message only if GPS coords have changed since last run &lt;br /&gt;
run_only_if_diff=1&lt;br /&gt;
&lt;br /&gt;
# file where gps coords should  be stored until next run&lt;br /&gt;
last_gps_coord_file=/tmp/track_coords&lt;br /&gt;
&lt;br /&gt;
# use with run_only_if_diff&lt;br /&gt;
# send_every_hour=1, send a message on the hour, even if the phone hasn't moved&lt;br /&gt;
# send_every_hour=0, don't send a message on the hour&lt;br /&gt;
send_every_hour=1&lt;br /&gt;
&lt;br /&gt;
######&lt;br /&gt;
&lt;br /&gt;
# get current minute and current time&lt;br /&gt;
cur_min=$(date +&amp;quot;%M&amp;quot;)&lt;br /&gt;
now=$(date +&amp;quot;%D %R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# The GPS should be turned on to get an accurate fix...otherwise you get the tower location&lt;br /&gt;
# Is the GPS turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getUseGps '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # gps is on&lt;br /&gt;
   gps_on=1&lt;br /&gt;
else  &lt;br /&gt;
   #gps is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   gps_on=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
   # wait for 60 seconds so gps gets a good lock&lt;br /&gt;
   # sleep 60&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Location services must be turned on, or startTracking will not work (you get a {&amp;quot;errorCode&amp;quot;:7})&lt;br /&gt;
# Are locations service turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getAutoLocate '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # location service is on&lt;br /&gt;
   location_service=1&lt;br /&gt;
else  &lt;br /&gt;
   #location service is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   location_service=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Get current coords&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,6,7,8,9,10 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
acc=$(echo $pos | cut -d, -f3 | cut -d. -f1)&lt;br /&gt;
dir=$(echo $pos | cut -d, -f4)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f5)&lt;br /&gt;
alt=$(echo $pos | cut -d, -f6)&lt;br /&gt;
altacc=$(echo $pos | cut -d, -f7 | cut -d. -f1)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
# turn off GPS?&lt;br /&gt;
if [ $gps_on -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # the GPS was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# turn off location service?&lt;br /&gt;
if [ $location_service -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # location service was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# check if we should send a message&lt;br /&gt;
if [ $run_only_if_diff -eq 1 ] &lt;br /&gt;
then&lt;br /&gt;
    # create short coords. &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.4f\n&amp;quot;,$0)&amp;quot; for 4 decimal places (about 30 feet accuracy)&lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.3f\n&amp;quot;,$0)&amp;quot; for 3 decimal places (about 280 feet accuracy)                                                            &lt;br /&gt;
    # use &amp;quot;printf(&amp;quot;%3.2f\n&amp;quot;,$0)&amp;quot; for 2 decimal places (about 0.5 miles accuracy)                                                            &lt;br /&gt;
    sh_lat=$(echo $lat |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
    sh_lon=$(echo $lon |  awk '{printf(&amp;quot;%3.4f\n&amp;quot;,$0)}')&lt;br /&gt;
&lt;br /&gt;
   # does the file with the last coords exist?&lt;br /&gt;
    if [ -f $last_gps_coord_file ]&lt;br /&gt;
    then&lt;br /&gt;
        $(grep &amp;quot;$sh_lat $sh_lon&amp;quot; $last_gps_coord_file &amp;gt; /dev/null)&lt;br /&gt;
        grep_ret=$?&lt;br /&gt;
        if [ $grep_ret -eq 0 ]&lt;br /&gt;
        then&lt;br /&gt;
            # coords match...don't send a message&lt;br /&gt;
            send_message=0&lt;br /&gt;
        else&lt;br /&gt;
            # coords don't match...send a message and update coord file&lt;br /&gt;
            send_message=1 &lt;br /&gt;
            echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file                                                                                                   &lt;br /&gt;
        fi&lt;br /&gt;
    else&lt;br /&gt;
        # there is not a last coords file...create one for next time&lt;br /&gt;
        send_message=1&lt;br /&gt;
        echo $sh_lat $sh_lon &amp;gt; $last_gps_coord_file  &lt;br /&gt;
    fi&lt;br /&gt;
else&lt;br /&gt;
    # $run_only_if_diff is false, so send a message&lt;br /&gt;
    send_message=1        &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# if configured to send on the hour...is it time?&lt;br /&gt;
if [ $send_every_hour -eq 1 -a $cur_min = &amp;quot;00&amp;quot; ]&lt;br /&gt;
then&lt;br /&gt;
  send_message=1 &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Enable this below if you want to keep logs - not sure where to write them /var/home/root not the best place.&lt;br /&gt;
# echo $now,$lat,$lon,$acc,$dir,$spd,$alt,$altacc,$bat &amp;gt;&amp;gt;mygpsdata.log&lt;br /&gt;
&lt;br /&gt;
# send the message&lt;br /&gt;
if [ $send_message -eq 1 ]&lt;br /&gt;
then&lt;br /&gt;
    #Build message content to be sent&lt;br /&gt;
    if [ $msg_with_heading -eq 1 ]&lt;br /&gt;
    then&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; Bat:$bat Acc:$acc &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon+(Heading:%20$dir%0DSpeed:%20$spd)&amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
       msg=$(echo $now &amp;quot;\n&amp;quot; &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon&amp;quot; &amp;quot;\n&amp;quot; Bat=$bat,Acc=$acc,Dir=$dir,Spd=$spd,Alt=$alt,AltAcc=$altacc)&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    $(luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has been running every 20 minutes on my phone for the last 4 days, no problem.&lt;br /&gt;
-dld121&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5090</id>
		<title>Patch webOS GPS Tracking</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Patch_webOS_GPS_Tracking&amp;diff=5090"/>
		<updated>2009-09-01T20:51:35Z</updated>

		<summary type="html">&lt;p&gt;Wilderf353: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{template:patch}}&lt;br /&gt;
Here is my super happy awesome tracker script!&lt;br /&gt;
&lt;br /&gt;
== Script code ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
SECRET=make up any secret code here&lt;br /&gt;
DEST=put your e-mail address here&lt;br /&gt;
&lt;br /&gt;
track()&lt;br /&gt;
{&lt;br /&gt;
        export IFS=$'\n'&lt;br /&gt;
        for loc in $(luna-send -n 3 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1); do&lt;br /&gt;
                send $(echo $loc|cut -f3- -d,)&lt;br /&gt;
        done&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
send()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;Sending Message: $1&amp;quot;&lt;br /&gt;
        msg=$(echo $1| sed s/\&amp;quot;/\\\\\&amp;quot;/g)&lt;br /&gt;
        luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg()&lt;br /&gt;
{&lt;br /&gt;
        echo &amp;quot;.timeout 30000&amp;quot; &amp;gt; /tmp/trackersql&lt;br /&gt;
        cmd='SELECT messageText FROM com_palm_pim_FolderEntry WHERE timeStamp &amp;gt; (strftime(&amp;quot;%s000&amp;quot;, &amp;quot;now&amp;quot;)-600000);'&lt;br /&gt;
#       output=$(echo $cmd|sqlite3 /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        output=$(echo $cmd|sqlite3 -init /tmp/trackersql /var/luna/data/dbdata/PalmDatabase.db3)&lt;br /&gt;
        echo $output|grep $SECRET 2&amp;gt; /dev/null &amp;gt; /dev/null&lt;br /&gt;
        status=$?&lt;br /&gt;
&lt;br /&gt;
        if [ $status = 0 ]; then&lt;br /&gt;
                track&lt;br /&gt;
        fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
checkmsg&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation==&lt;br /&gt;
# mkdir -p /home/scripts&lt;br /&gt;
# Let's say you put the script in /home/scripts/track.sh&lt;br /&gt;
# rootfs_open -w&lt;br /&gt;
# Go [[Crond | here ]] to enable crond.&lt;br /&gt;
# Add the following line to /etc/cron/crontabs/root&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;*/5 * * * * /home/scripts/track.sh&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Now just send the secret code you set in the script to $YOURNUMBER@messaging.sprintpcs.com (without dollar sign but as a ten digit number with area code prefix)&lt;br /&gt;
&amp;gt; Ex: 3335554444@messaging.sprintpcs.com where 333 is your area code, and 5554444 the rest of your phone number.&lt;br /&gt;
and it will send $DEST the GPS data for the device.&lt;br /&gt;
&lt;br /&gt;
Now, just take the latitude and longitude data and generate the URL. As to the other GPS parameter data available we'll have to investigate to see if Google Maps can take those parameters and how they map to the URL. ~Robi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
luna-send -n 1 palm://com.palm.location/getCurrentPosition {}&lt;br /&gt;
** Message: serviceResponse Handling: 2, {&amp;quot;errorCode&amp;quot;:0,&amp;quot;timestamp&amp;quot;:1.245799702311E12,&amp;quot;latitude&amp;quot;:37.48660683631897,&amp;quot;longitude&amp;quot;:-122.23269581794739,&amp;quot;horizAccuracy&amp;quot;:37.947330474853516,&amp;quot;heading&amp;quot;:178,&amp;quot;velocity&amp;quot;:0.75,&amp;quot;altitude&amp;quot;:-13,&amp;quot;vertAccuracy&amp;quot;:24}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which means we can transpose some of that to a Google Maps link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
http://maps.google.com/?ie=UTF8&amp;amp;q=37.48660683631897,-122.23269581794739+(Heading:%20178%0DSpeed:%200.75%20mph)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you know more about the GPS parameters, let us know by updating the page. ~Robi&lt;br /&gt;
&lt;br /&gt;
* Added heading and speed parameters to the URL. If you hover over the pinpoint on the google map, you can see the information, as well as in the info window if you click on the pinpoint. -xluryan&lt;br /&gt;
&lt;br /&gt;
&amp;quot;If [ll=] is used without a query, then the map is centered at the point but no marker or info window is displayed.&amp;quot; To get around this, use q=[Lon,Lat] instead of ll=[Lon,Lat]. I changed the maps link above. -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Troubleshooting Tip:''' Make sure track.sh has the correct file permissions set. To encompass all possibilities, try 'chmod 755 /home/scripts/track.sh'. You can restrict permissions later if you wish. On Windows it's probably easiest to do this through WinSCP (right click&amp;gt;Properties&amp;gt;Permissions).&lt;br /&gt;
&lt;br /&gt;
== Development Ideas==&lt;br /&gt;
1.  Send response as a google maps link that clicked on shows the phones position on a map.&lt;br /&gt;
2.  Find a way to put a hook into message reception so that messages don't have to be checked with a cron job.  Even better if the message could be intercepted before appearing on the phone, it would be a useful way to track a stolen phone.&lt;br /&gt;
3. After implementing the script that emails me every 20 minutes, it occured to me that the following would be great:&lt;br /&gt;
  3a. The ability to log the entries instead of just sending an email, and maintain a preset number of logged entries (say the last 24 entries).&lt;br /&gt;
  3b. Using the original implementation - send a message to the device to have the logged information emailed. This would show a &amp;quot;track&amp;quot; of where the device has been.&lt;br /&gt;
  3c. Control of the number of log entries, and the frequency.&lt;br /&gt;
== Another Simple Method==&lt;br /&gt;
Why not use this script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,8 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f3)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
&lt;br /&gt;
ret=$(wget -qO- &amp;quot;http://yoursite.com/trackme/$1/requests.php?lat=$lat&amp;amp;lon=$lon&amp;amp;speed=$spd&amp;amp;batt=$bat&amp;quot; | egrep -o '[0-9]+$')&lt;br /&gt;
exit $ret&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have a web server setup with //requests.php// taking '''//lat//''', '''//lon//''', '''//speed//''', and '''//batt//''' arguments. Then it writes them to a file. Use the data however you want. I have mine plug into a google map and show me the data.&lt;br /&gt;
&lt;br /&gt;
Just set up a cron job to call the script every 20 minutes or so. Hardly effects battery life at all :)&lt;br /&gt;
&lt;br /&gt;
Credit to ddoc for info on how to grab battery status. I would still like to find a more efficient way of grabbing battery level rather than searching through the entire message log. Though for now, it works exactly like it should.&lt;br /&gt;
&lt;br /&gt;
Here's the Method for getting battery status:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;Mojo.Service.Request('palm://com.palm.power/com/palm/power/', {method: 'batteryStatusQuery',});&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
-pEEf&lt;br /&gt;
&lt;br /&gt;
== Email a URL to open Google Maps showing location of phone.==&lt;br /&gt;
Below is a code snippet that will send an email with working URL to open Google Map and show you the location of your phone.&lt;br /&gt;
The cron job mentioned above is setup to call this script every 20 minutes on my machine...works great.  I let GMAIL archive them.&lt;br /&gt;
If the phone gets stolen, I can find it as long as it has service.&lt;br /&gt;
&lt;br /&gt;
The larger Accuracy is, the further away the coordinates output will be from your actual position.&lt;br /&gt;
&lt;br /&gt;
Added speed &amp;amp; heading to Google URL. Is there any way to have the sent messages not appear in the Text Messaging app, or to use the shell to email the output via mailx? Until I figure out a built-in mail function, you can use an alternative I'm testing that uses a server's mailx command: echo &amp;quot;$msg2&amp;quot; | /opt/bin/ssh -x user@server /bin/mailx $DEST     -hopspitfire&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;modified by wilderf353 on 09-09-01:&amp;lt;/i&amp;gt; &lt;br /&gt;
I modified the original script because the Google URL being sent was getting truncated on my phone and a few other people that posted at forums.precentral.net.  I did some testing and it looks like when you use sendMessageFromCompose, you are limited to a message with less than 136 characters. I shortened the message and added :&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on GPS if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the beginning of the script, turn on Location Services if it is off&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn GPS back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;at the end of the script, turn Location Services back off, if it was off when the script started&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;added altitude and altitude accuracy information&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(NOTE: You will need to add your email address to the script)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
####### Stuff to set&lt;br /&gt;
&lt;br /&gt;
## email address to mail info to&lt;br /&gt;
DEST=your_email_address&lt;br /&gt;
# example: DEST=wsmith@aol.com   (make sure you don't have any spaces)&lt;br /&gt;
&lt;br /&gt;
## send url with embedded heading/speed info&lt;br /&gt;
# we only have ~136 characters to work with. If you embed heading &amp;amp; speed info, you can't &lt;br /&gt;
# include altitude and altitude accuracy information &lt;br /&gt;
# msg_with_heading=0  (don't embed heading/speed info, but include altitude information)&lt;br /&gt;
# msg_with_heading=1  (embed heading/speed info)&lt;br /&gt;
msg_with_heading=0&lt;br /&gt;
&lt;br /&gt;
######&lt;br /&gt;
&lt;br /&gt;
# The GPS should be turned on to get an accurate fix...otherwise you get the tower location&lt;br /&gt;
# Is the GPS turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getUseGps '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # gps is on&lt;br /&gt;
   gps_on=1&lt;br /&gt;
else  &lt;br /&gt;
   #gps is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   gps_on=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
   # wait for 60 seconds so gps gets a good lock&lt;br /&gt;
   sleep 60&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Location services must be turned on, or startTracking will not work (you get a {&amp;quot;errorCode&amp;quot;:7})&lt;br /&gt;
# Are locations service turned on? &lt;br /&gt;
$(luna-send -n 1 palm://com.palm.location/getAutoLocate '{}' 2&amp;gt;&amp;amp;1 | grep 'true' &amp;gt; /dev/null)&lt;br /&gt;
grep_ret=$?&lt;br /&gt;
if [ $grep_ret -eq 0 ]        # Test exit status of &amp;quot;grep&amp;quot; command.&lt;br /&gt;
then&lt;br /&gt;
   # location service is on&lt;br /&gt;
   location_service=1&lt;br /&gt;
else  &lt;br /&gt;
   #location service is off...let's turn it on and remember to turn it back off later&lt;br /&gt;
   location_service=0&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:true}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Get current coords&lt;br /&gt;
pos=$(luna-send -n 2 palm://com.palm.location/startTracking '{&amp;quot;appId&amp;quot;: &amp;quot;ILovePalm&amp;quot;, &amp;quot;subscribe&amp;quot;: true}' 2&amp;gt;&amp;amp;1 | tail -1 | cut -d, -f4,5,6,7,8,9,10 | sed -r 's/[^-\.0-9,]//g')&lt;br /&gt;
&lt;br /&gt;
lat=$(echo $pos | cut -d, -f1)&lt;br /&gt;
lon=$(echo $pos | cut -d, -f2)&lt;br /&gt;
acc=$(echo $pos | cut -d, -f3 | cut -d. -f1)&lt;br /&gt;
dir=$(echo $pos | cut -d, -f4)&lt;br /&gt;
spd=$(echo $pos | cut -d, -f5)&lt;br /&gt;
alt=$(echo $pos | cut -d, -f6)&lt;br /&gt;
altacc=$(echo $pos | cut -d, -f7 | cut -d. -f1)&lt;br /&gt;
bat=$(grep BATTERY: /var/log/messages | tail -1 | awk '{print $8}' | sed 's/%,//')&lt;br /&gt;
now=$(date +&amp;quot;%D %R&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# turn off GPS?&lt;br /&gt;
if [ $gps_on -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # the GPS was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setUseGps '{&amp;quot;useGps&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# turn off location service?&lt;br /&gt;
if [ $location_service -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
   # location service was off when we started the script...turn it back off&lt;br /&gt;
   $(luna-send -n 1 palm://com.palm.location/setAutoLocate '{&amp;quot;autoLocate&amp;quot;:false}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
# Enable this below if you want to keep logs - not sure where to write them /var/home/root not the best place.&lt;br /&gt;
# echo $now,$lat,$lon,$acc,$dir,$spd,$alt,$altacc,$bat &amp;gt;&amp;gt;mygpsdata.log&lt;br /&gt;
&lt;br /&gt;
#Build message content to be sent&lt;br /&gt;
if [ $msg_with_heading -eq 1 ]&lt;br /&gt;
then&lt;br /&gt;
   msg=$(echo $now &amp;quot;\n&amp;quot; Bat:$bat Acc:$acc &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon+(Heading:%20$dir%0DSpeed:%20$spd)&amp;quot;)&lt;br /&gt;
else&lt;br /&gt;
   msg=$(echo $now &amp;quot;\n&amp;quot; &amp;quot;http://maps.google.com/maps?q=$lat%2C$lon&amp;quot; &amp;quot;\n&amp;quot; Bat=$bat,Acc=$acc,Dir=$dir,Spd=$spd,Alt=$alt,AltAcc=$altacc)&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# send the message&lt;br /&gt;
$(luna-send -n 1 palm://com.palm.messaging/sendMessageFromCompose '{&amp;quot;recipientJSONArray&amp;quot;: [{&amp;quot;value&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;contactDisplay&amp;quot;: &amp;quot;'${DEST}'&amp;quot;, &amp;quot;prefix&amp;quot;: &amp;quot;to$A&amp;quot;, &amp;quot;identifier&amp;quot;: &amp;quot;palm_anon_element_8&amp;quot;}], &amp;quot;messageText&amp;quot;: &amp;quot;'&amp;quot;$msg&amp;quot;'&amp;quot;}' &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has been running every 20 minutes on my phone for the last 4 days, no problem.&lt;br /&gt;
-dld121&lt;/div&gt;</summary>
		<author><name>Wilderf353</name></author>
	</entry>
</feed>