Main purpose is to ensure that location is available from device to localhost via TCP.
It will allow geoclue to work properly. and enable support for gnome-maps and geoclue dependent applications.
Project location. Build the application. https://github.com/zeenix/gps-share
Default configuration on network is localhost:10110
Command to start gps-share is
$ $HOME/local/bin/gps-share -b 38400 ${GPS_DEV} > /dev/null 2>&1 &
Note: Baud rate and device should point correctly to the actual serial device.
If installed succesfully, should be able to test with /usr/libexec/geoclue-2.0/demos/where-am-i
GPSD allows other popular apps to be able to talk to the GPS device easily. This includes testing apps such as xgps and cgps.
GPSD can be installed using apt. However, the device needs to be changed from normal serial device to network device leveraging gps-share.
# /etc/default/gpsd
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="tcp://localhost:10110"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-b -F /var/run/gpsd.sock"
OPTIONS=""
# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"
Geoclue agent needs to be started in the background
/usr/libexec/geoclue-2.0/demos/agent > /dev/null 2>&1 &
Note: GPDD services should be disabled at startup. We do not want the daemon to startup before the network socket from gps-share is enabled. Moreover, the device should only be enabled when user is logged in. I am not interested in reading the GPS device is a user isn't logged in.
$ systemctl disable gpsd
$ systemctl disable gpsd.socket
$ systemctl stop gpsd
$ systemctl stop gpsd.socket
In order to start up gpsd manually in a script, the following command is used.
$ /usr/sbin/gpsd -b tcp://localhost:10110 > /dev/null 2>&1 &
If installed correctly, the test apps like xgps should be able to retrieve satellite position.
If using pyGPSClient, just need to configure the network socket to use localhost:10110. You can save it into the configuration file so that it doesn't need to be changed at every startup.
The following startup script is used either as part of the user login startup script or rc.local.
My configuration makes use of gnome-startup via "Startup Applications", executing a script "startup.sh" upon user login. i do not want to allow the GPS device to be read, typically, before a user login.
My user is also added to the dialout group via sudo usermod -aG dialout [username]
# GPS_DEV points to the serial device path by id
# GPS_DEV="/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0";
if [ -e "${GPS_DEV}" ]; then
echo "- GPS USB cp210x device possibly found"
echo "- Starting geoclue agent"
/usr/libexec/geoclue-2.0/demos/agent > /dev/null 2>&1 &
echo "- Starting gps-share"
$HOME/local/bin/gps-share -b 38400 ${GPS_DEV} > /dev/null 2>&1 &
echo "- Starting gpsd"
/usr/sbin/gpsd -b tcp://localhost:10110 > /dev/null 2>&1 &
$HOME/local/bin/notify "normal" "GPS Status" "GPS Found: Services started"
else
$HOME/local/bin/notify "normal" "GPS Status" "No GPS device found"
fi
Note: notify command ties to notify-send which allows an alert to be shown on gnome if a GPS device and service is started or not.
If everthing is setup correctly, the following apps should all work at the same time
- xgps
- cgps
- pygpsclient
- gnome-maps
This extension and installation would allow the GPS position to be fed from gpsd to the browser.
Refer to https://github.com/sulph68/gpsd-chrome-extension
This would allow
- maps.google.com
- OSM
- Any web browser that uses geolocation DOM API. Be careful how that is enabled.