Difference between revisions of "Install phoneDistance"
(→Install xPL phone distance calculator) |
(→Install xPL phone distance calculator) |
||
Line 4: | Line 4: | ||
Before all, make sure you have installed an [[install xpl hub|xPL hub]]. | Before all, make sure you have installed an [[install xpl hub|xPL hub]]. | ||
− | = Install | + | = Install the phone distance calculator = |
== Mobile phone == | == Mobile phone == |
Revision as of 16:44, 4 June 2015
The distance calculator receives NMEA position messages on an UDP port. From this, it calculates the distance to several locations such as home or work and sends them as an xPL message.
Before all, make sure you have installed an xPL hub.
Contents
[hide]Install the phone distance calculator
Mobile phone
On your mobile phone, install a GPS location streamer such as GPS2IP.
Set-up the application to send GPGGA
messages to a selected UDP port (default is 11123).
My GPS2IP settings are:
- time between sending: 60 seconds
- GPS accuracy: moderate
- NMEA message to send: GGA
- Generate in background mode: on
- Connection method: UDP push
- Phone IP selection: cellular IP
Linux machine
Download the xPL phone distance calculator script.
Move the script to xPL scripts directory:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls mv xpl-phoneDistance.pl $SCRIPTS_BASE_DIR chown control:users $SCRIPTS_BASE_DIR/*.pl chmod 775 $SCRIPTS_BASE_DIR/*.pl
Test the phone distance calculator
Test it:
su control SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-phoneDistance.pl -h $SCRIPTS_BASE_DIR/xpl-phoneDistance.pl -vn alert
Open a 2nd terminal window (on any machine with xPL installed) and monitor the xPL protocol:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-monitor.pl -vf
Open a 3rd terminal window (on any machine with xPL installed) and control the lights:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play $SCRIPTS_BASE_DIR/xpl-send.pl -v -c alert.basic command=play soundFile=pop.wav
The doorbell sound should play.
Launch the xPL distance calculator at startup
Multiple instances of the distance calculator can be launched at startup, each with a different GPS UDP port, allowing to follow different phones.
The xPL distance calculator is to be launched after the xPL hub.
Ubuntu
On Ubuntu, the xPL distance calculator starts-up once xpl-hub_started
has been emitted.
Edit /etc/init/xpl-phoneDistance.conf
:
################################################################################ # xPL phone distance calculator # description "xPL phone distance" version "1.0" author "Francois Corthay" #------------------------------------------------------------------------------- # Configuration variables # env SCRIPTS_DIR='/home/control/Documents/Controls' env SCRIPT_NAME='xpl-phoneDistance.pl' env PARAMETERS='-n iPhone' #------------------------------------------------------------------------------- # Start and stop conditions # start on xpl-hub_started stop on shutdown respawn setuid control setgid users #------------------------------------------------------------------------------- # Start daemon # exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS
Start the device and test it:
su root service xpl-phoneDistance start service xpl-phoneDistance status initctl list | grep xpl ps aux | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///' | sort