tralfamadore.com
get unstuck, in time

27 August 2008

Changelog for Locatable 0.3

I'm just about to submit the new version of Locatable. Here are the changes: Locatable
  • More accurate GPS readings. When retrieving a location, wait until the accuracy is within the specified range, or 20 seconds, whichever comes first (i.e. if you set it to "Best", it'll spend the full 20 seconds).
  • New option "Expire after" specifies how stale of a location is allowed to be sent to web sites. Default is 10 minutes. If you set this to "each request", Locatable will pop up every time a web site wants to read your location.
  • New option "Ask permission" defines if and how many times you'll be prompted to allow a site to see your location. Default is to always ask. Set this to "Twice per site" to mimic the behaviour of iPhone native apps.
Relocatable
  • Relocatable is now a daemon process. You can control how often and how fast it runs by editing /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist.
  • You can also run it from the command line (it now lives in /usr/libexec/relocatable), which gives you the following options:
~ root# /usr/libexec/relocatable/Relocatable -h
Usage: Relocatable [-v] [-t SECONDS] [-d SECONDS] [-e CMD]
-d SECONDS      run as a daemon, delay specified seconds between fixes
-e CMD          execute given program (with args) after each location fix,
                 can include @lat@, @long@, and @hacc@ tokens
-t SECONDS      spend specified seconds waiting for a fix, default 30
-v              turn on verbose logging
Let me know if you encounter any issues. Update (30 Aug 08): A few people had questions about getting the command execution piece to work. Here's an example — the important bit is to wrap the whole command in single quotes, otherwise the shell gets confused. First, if Relocatable is already running as a daemon (it will be by default), you need to stop it:
~ root# launchctl unload /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist
Once that's done, you can run Relocatable as a one-off from the command line:
~ root# /usr/libexec/relocatable/Relocatable -v \
> -e 'curl "http://my.site.com/savepos.pl?lat=@lat@&long=@long@&acc=@hacc@"'
Opened LBS database for read...
Started updates...
newLocation: <+51.xxxxxxxxx, -0.xxxxxxxx> +/- 93.21m @ 2008-08-30 13:17:44 +0100
newLocation: <+51.xxxxxxxxx, -0.xxxxxxxx> +/- 93.21m @ 2008-08-30 13:18:29 +0100
Stopped updates
Opened LBS database for write...
* About to connect() to my.site.com port 80 (#0)
*   Trying xxx.xxx.xxx.xxx... connected
* Connected to my.site.com (xxx.xxx.xxx.xxx) port 80 (#0)
> GET /savepos.pl?lat=51.xxxxxxxxxx&lng=-0.xxxxxxxxxxxx&acc=93.21 HTTP/1.1
> User-Agent: curl/7.17.1 (arm-apple-darwin9) libcurl/7.17.1 OpenSSL/0.9.8g zlib/1.2.3
Note the use of the single quotes (to bracket the command passed to Relocatable) and double quotes (to bracket the URL, so it can contain characters that would otherwise confuse the shell, like the ampersand). The same rules regarding quoting apply to editing the daemon plist. Once you're happy with your settings and have edited the plist to your satisfaction, remember to start it back up:
~ root# launchctl load /System/Library/LaunchDaemons/com.tralfamadore.locatable.plist

Labels: , , , ,

Copyright (C) 2001-2008 Tralfamadore.com