tracksix v1.2.1
Tracksix
Track your ⛵|🚂|🚙|🚜|🛵|🛷|🚶 with a Raspberry Pi and a GPS.
Features
- OwnTracks Compatable Config & Reporting Format
- MQTT(S) Reporting
- MQTT over WebSocket Reporting
- Programmatic usage or executable use
- Compatable with a huge array of GPS devices through
GPSd - Replays reports when an internet connection arrises
Install
To communicate with your GPS device, tracksix utilises GPSd (Global Positioning System daemon) which standardises the format from different GPS devices.
On OSX:
$ brew install gpsdOn Debian/Ubuntu:
$ sudo apt install gpsdEnsure you have Node.js installed on your device, then install tracksix:
$ npm install --global tracksixUsage
$ tracksix [path to config file]Tracksix uses the same configuration format as OwnTracks, this can be exported from your OwnTracks mobile app or copy the config.example.json and edit the contents appropriately.
Programmatic Usage
First follow the above steps for installing GPSd. Then install the tracksix library into your nodejs project:
$ npm install tracksixImport the library:
const tracksix = require('tracksix')Load your configuration file:
const path = require('path')
const config = tracksix.readConfigSync(
path.resolve(__dirname, './config.json')
)Start tracking:
const tracker = tracksix(config)To listen for errors, tracksix() returns an EventEmitter which emits 'error' events.
tracker.on('error', (err) => {
console.error(err)
})To listen for updates sent to the MQTT server, subscribe to 'location' events. A location event contains the same elements as specified in the OwnTracks location object.
tracker.on('location', (report) => {
console.log(report)
})Run as a service
Write the following to /etc/systemd/system/tracksix.service and update the path to node which node and tracksix which tracksix.
[Unit]
Description=Tracksix Service
After=network.target
[Service]
Type=simple
# Another Type: forking
User=pi
WorkingDirectory=/home/pi
ExecStart=/home/pi/.nvm/versions/node/v10.13.0/bin/node /home/pi/.nvm/versions/node/v10.13.0/bin/tracksix
Restart=on-failure
# Other restart options: always, on-abort, etc
# The install section is needed to use
# `systemctl enable` to start on boot
# For a user service that you want to enable
# and start automatically, use `default.target`
# For system level services, use `multi-user.target`
[Install]
WantedBy=multi-user.targeAfterwards you need to enable the service:
$ sudo systemctl enable tracksix.serviceThen start the service with:
$ sudo systemctl start tracksixYou can check the status / logs with:
$ systemctl status tracksix.serviceDevelopment
To start a mock GPSd server use gpsd-fake: npm install -g gpsd-fake && gpsd-fake.
Licence
MIT © Ben Evans