talKKonnect GPS Tracking

Introduction

It’s been a while since my last article in Suvir’s blog. It doesn’t mean there was nothing new to report. Suvir had added many great functions to talKKonnect in 2021. To name just a few… mqtt support, voice targets, TTS announcements, rotary encoder support, 7 segment display support, support for MEMS microphones (Waveshare, Seeed Studio WM8960 hats or individual MEMS microphone modules like INMP441 or SPH0645), etc. 2021 was a good year for the maturity of talKKonnect project. talKKonnect code was refactored and optimized. talKKonnect is presently known as “version 2”. However, for me to cover some of these topics will have to wait for another time. In the meantime, for up to date new features and daily development news please keep checking Suvir’s main github project page regularly. The main topic of this article will be more limited. I am going to cover, just one new functionality at this time. A GPS tracking feature.

talKKonnect has an exciting new functionality. Development team members hope you will like this function. talKKonnect is supporting working with GPS tracking solution Traccar, created by Anton Tananaev. Traccar is a great open source GPS tracking solution licensed under Apache 2.0 license. Traccar supports over 200 tracking protocols and more than 2000 tracking devices. Traccar server includes a modern web UI to view locations of tracked devices, check historical tracks on a map and provide other useful reports. Various alerts from the tracked devices can be preconfigured in Traccar server UI and notifications by sound, e-mail, Telegram messenger, SMS or other methods can be sent. Traccar server run’s on Linux or Windows. Traccar has Android and iOS clients and manager application.

Officially supported Traccar client application for Linux, does not currently exist. There had been some attempts to create a Linux client in the past, like tralnx, but this was 9 years ago. Anyone who wished to run Traccar client on Linux was on his own. talKKonnect will try to help fill this gap, so that anyone looking to primarily use PTT over IP, but wants GPS tracking function as an additional feature, can easily reap the benefits of both. For people primarily interested in a GPS tracking, PTT voice can be an added benefit. talKKonnect functions are highly granular and configurable and all functions can be enabled or disabled as needed.

Traccar project has been around for over 10 years. It is a mature project with excellent reputation. I am not going to cover Traccar server configuration in this article. For Traccar questions, please refer to Traccar site, forum or documentation and support pages, all featuring a wealth of information about Traccar.

If you like Traccar, please consider supporting Anton’s work. And if you like what Suvir has done with talKKonnect and want to support his work, you can contact him through project site or his blog.

Make the GPS Tracking Work from taKKonnect

So, now that you know talKKonnect can be used as a Traccar Linux client, how to make the GPS tracking work? You are going to need GNSS UART device connected to talKKonnect and access to Traccar server. You can install your own Traccar server. Or if you just want to test Traccar, you can use some of the Traccar project demo servers.

There are two ways of using GPS tracking with talKKonnect. GPS function can be used as a stand-alone feature, independent of Traccar, to show current position in the display, terminal console screen or logs or work together with other talKKonnect functions like “Panic button”.

Traccar Web GUI with Open Street Maps layer

Traccar Web GUI with “Custom Map” layer

Another way of using GPS with talKKonnect is by sending GPS position reports to Traccar server. For working with Traccar, this option needs to be enabled in talKKonnect, on top of the basic GPS functionality.

For GPS tracking to work, GPS serial device of your choice needs to be enabled first. talKKonnect working as a Traccar client supports 3 different tracking protocols. OsmAnd, T55 and OpenGTS. OsmAnd (OpenStreetMap Automated Navigation Directions) is a protocol designed by OsmAnd project. It works over http. OsmAnd is the recommended protocol for talKKonnect working with Traccar, unless you have a preference for using some other standard. OsmAnd is used in Traccar Android and iOS clients. T55 is an old Traccar protocol, working over tcp. It is an alternative protocol to OsmAnd. OpenGTS is a protocol from OpenGTS project. Other protocols could have been implemented, but talKKonnect team had opted for implementing just the 3 protocols.

GNSS Devices

GNSS devices from a Swiss manufacturer u-blox, like Neo-6, Neo-7, Neo-M8 are recommended for using with talKKonnect. Other UART serial GNSS products, from any other manufacturer will also work. Any GNSS device which talks “serial”, can be used with talKKonnect. GNSS devices can be in the format of USB dongles or boards with direct UART serial (TX/RX/GND) connections. If UART serial without USB is used, it requires connection to serial pins in Raspberry Pi, Orange Pi or other boards. If GNSS USB dongles, like VK-172 (Neo-7) are used, the way of connecting them to Raspberry Pi is obvious, just plug to USB port.

u-blox GNSS devices Neo-6Neo-7 (VK-172),  Neo-M8

GNSS Device Test

To test if GNSS device is working, whether USB or with direct UART serial connection, you can connect them to your board. Verify that device connection is working. If a USB device, when running “lsusb”, you should see your GNSS device in the list,

root@tk-demo-04:~ # lsusb
Bus 001 Device 007: ID 1546:01a7 U-Blox AG [u-blox 7]
Bus 001 Device 004: ID 8086:0808 Intel Corp.
Bus 001 Device 008: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

or use “lsusb -v”

root@tk-demo-04:~ # lsusb -v | grep u-blox
Bus 001 Device 007: ID 1546:01a7 U-Blox AG [u-blox 7]
idProduct 0x01a7 [u-blox 7]
iManufacturer 1 u-blox AG - www.u-blox.com
iProduct 2 u-blox 7 - GPS/GNSS Receiver

Next, try to discover which tty name the device is using? For u-blox, most likely you are looking for ttyACM*.

ls /dev/tty*
root@tk-demo-04:~ # ls /dev/tty*
...
/dev/ttyACM0
...

To check the NMEA readings, ensure GNSS device has a good window to the sky and whether it is receiving the messages. If you “cat” against ttyACM0, you should see something like this,

root@tk-demo-04:~ # cat /dev/ttyACM0
$GPRMC,111541.00,A,4446.82769,N,02030.94029,E,0.375,,100222,,,A*74
$GPVTG,,T,,M,0.375,N,0.695,K,A*28
$GPGGA,111541.00,4446.82769,N,02030.94029,E,1,07,1.16,219.1,M,36.7,M,,*52
$GPGSA,A,3,12,17,15,23,13,24,10,,,,,,2.27,1.16,1.95*0B
$GPGSV,3,1,12,01,04,028,,06,02,120,,10,11,307,26,12,34,244,27*72
$GPGSV,3,2,12,13,35,166,24,14,17,060,08,15,48,209,28,17,42,063,22*79
$GPGSV,3,3,12,19,52,100,,23,12,275,19,24,60,304,30,28,39,055,25*7D
$GPGLL,4446.82769,N,02030.94029,E,111541.00,A,A*6F

For getting a more presentable GPS info from the device, install gpsd clients,

 apt-get install gpsd gpsd-clients

Run,

gpsmon /dev/ttyACM0
tk-demo-04:/dev/ttyACM0 0 8N1 NMEA0183>
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
xTime: 2022-02-10T11:32:20.000Z Lat: 44 46' 49.06991" Non: 20 30' 56.04540" Ex
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Cooked TPV qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x GPRMC GPVTG GPGGA GPGSA GPGSV GPGLL x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Sentences qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
lqqqqqqqqqqqqqqqqqqklqqqqqqqqqqqqqqqqqqqqqqqqqqqqklqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
xCh PRN Az El S/N xxTime: 113220.00 xxTime: 113220.00 x
x 0 1 22 2 0 xxLatitude: 4446.82832 N xxLatitude: 4446.82832 x
x 1 6 115 7 0 xxLongitude: 02030.94090 E xxLongitude: 02030.94090 x
x 2 10 301 10 21 xxSpeed: 0.038 xxAltitude: 213.6 x
x 3 12 250 40 29 xxCourse: xxQuality: 1 Sats: 09 x
x 4 13 167 27 18 xxStatus: A FAA: A xxHDOP: 0.91 x
x 5 14 63 10 16 xxMagVar: xxGeoid: 36.7 x
x 6 15 204 41 21 xmqqqqqqqqqqq RMC qqqqqqqqqqqqjmqqqqqqqqqqq GGA qqqqqqqqqqqqj
x 7 17 56 38 27 xlqqqqqqqqqqqqqqqqqqqqqqqqqqqqklqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x 8 19 86 53 27 xxMode: A3 Sats: 10 12 13 14 xxUTC: RMS: x
x 9 23 269 8 17 xxDOP: H=0.91 V=1.29 P=1.58 xxMAJ: MIN: x
x10 24 307 68 30 xxTOFF: 0.074106136 xxORI: LAT: x
x11 25 249 4 13 xxPPS: xxLON: ALT: x
mqqqqqq GSV qqqqqqqjmqqqqqqqq GSA + PPS qqqqqqqqqjmqqqqqqqqqqq GST qqqqqqqqqqqqj
(31) $GPGSV,4,4,13,28,33,057,32*42
(52) $GPGLL,4446.82854,N,02030.94099,E,113218.00,A,A*6C
(68) $GPRMC,113219.00,A,4446.82840,N,02030.94099,E,0.282,,100222,,,A*7A
(35) $GPVTG,,T,,M,0.282,N,0.521,K,A*2D
(75) $GPGGA,113219.00,4446.82840,N,02030.94099,E,1,09,0.91,213.8,M,36.7,M,,*56
(60) $GPGSA,A,3,12,17,15,23,14,19,13,24,10,,,,1.58,0.91,1.29*04
(66) $GPGSV,4,1,13,01,02,022,,06,07,115,,10,10,301,21,12,40,250,28*72

After you successfully tested your GPS device, you are ready to move on to configuring talKKonnect GPS and Traccar functions.

talKKonnect Configuration for GPS Tracking

This is the relevant talkkonnect.xml configuration section for working with GPS and Traccar.

<gps enabled="true">
<port>/dev/ttyACM0</port>
<baud>115200</baud>
<txdata/>
<even>false</even>
<odd>false</odd>
<rs485>false</rs485>
<rs485highduringsend>false</rs485highduringsend>
<rs485highaftersend>false</rs485highaftersend>
<stopbits>1</stopbits>
<databits>8</databits>
<chartimeout>100</chartimeout>
<minread>0</minread>
<rx>true</rx>
<gpsinfoverbose>true</gpsinfoverbose> <!--GPS info in console screen --> <gpsdiagsounds>true</gpsdiagsounds> <!--GPS diagnostic sound alerts--> 
<gpsdisplayshow>true</gpsdisplayshow> <!--GPS info show in display-->
</gps>


<traccar enabled="true"> 
<!--Traccar functions enabled-->
<track>true</track> 
<!--Send to Traccar-->
<clientid>talkkonnect-device</clientid> <!--Traccar client id-->
<traccardisplayshow>true</traccardisplayshow> <!--Traccar info show in display-->
<protocol name="osmand">
<osmand port="5055">
<serverurl>http://traccar-server-address</serverurl>
</osmand>
<t55 port="5005">
<serverip>traccar-server-ip</serverip>
</t55>
<opengts port="5159">
<serverurl>http://traccar-server-address</serverurl>
</opengts>
</protocol>
</traccar>

For GPS and Traccar diagnostic sound alerts to work you have to add them to the sounds section of the talkkonnect.xml configuration file. The sounds can alert you if GPS and Traccar functions are working correctly or if there are errors. For instance, GPS fix could be lost and no position could be obtained then or network connection to Traccar server is maybe lost. Diagnostic sounds will give you a quick indication if GPS position reports had been sent successfully or nor. You can enable / disable this feature just like any other in talKKonnect or adjust this feature as needed.

<sounds>
<sound event="traccarHTTP2XXResponse" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="traccarHTTP4XXResponse" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="traccarTCPConnOK" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="traccarTCPConnRefused" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="traccarTCPConnError" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="traccarTooManyErrors" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="gpsOK" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="gpsDeviceError" file="file-name" volume="50" blocking="false" enabled="true"/>
<sound event="gpsNoGoodRead" file="file-name" volume="50" blocking="false" enabled="true"/>
</sounds>

GPS Reporting

Golang GPS reporting function is still under development. Keep checking for new talKKonnect versions at github project page. In the mean time you can create Traccar reporting tasks through a cron job and http api functions in talKKonnect. Edit a local cron job with your favorite text editor

crontab –e

For reporting every minute use

# m h dom mon dow command
* * * * * curl 'http://127.0.0.1:8080/?command=gpsposition'

Cron is not designed for working with seconds. For reporting every 5 seconds use a workaround

# m h dom mon dow command
* * * * * curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 5; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 10; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 15; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 20; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 25; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 30; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 35; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 40; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 45; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 50; curl 'http://127.0.0.1:8080/?command=gpsposition'
* * * * * sleep 55; curl 'http://127.0.0.1:8080/?command=gpsposition'

Or adjust cron job for any other reporting rate as you like? After saving the changes, run

crontab –l

to list the current cron jobs and make changes come to an effect.

If you configured talKKonnect correctly for GPS and Traccar functions and if GNSS device is working, you should be able to see GPS Tracking in action in the terminal screen

[ debug ] 2022/02/10 12:47:16 commandkeys.go:363: F12 pressed
[ info ] 2022/02/10 12:47:16 commandkeys.go:364: GPS details requested
[ warn ] 2022/02/10 12:47:17 commandkeys.go:413: Could Not Get a Good GPS Read
[ debug ] 2022/02/10 12:47:17 commandkeys.go:421: Playing a GPS diagnostic sound
[ debug ] 2022/02/10 12:47:31 commandkeys.go:363: F12 pressed
[ info ] 2022/02/10 12:47:31 commandkeys.go:364: GPS details requested
[ debug ] 2022/02/10 12:47:32 gps.go:230: GPS Good Read Broadcasting to 3 GPSDataChannelReceivers
[ debug ] 2022/02/10 12:47:32 gps.go:518: RMC Validity (A), GGA GPS Quality Indicator (1) 6/15
[ debug ] 2022/02/10 12:47:32 gps.go:519: RMC Date Time 10/02/22 11:47:32.0000
[ debug ] 2022/02/10 12:47:32 gps.go:520: OS DateTime(UTC) 2022-02-10 11:47:32.074844211 +0000 UTC
[ debug ] 2022/02/10 12:47:32 gps.go:521: RMC Latitude,Longitude DMS 44.7803745,20.5157155
[ debug ] 2022/02/10 12:47:32 gps.go:522: RMC Speed, Course 0.264,0
[ debug ] 2022/02/10 12:47:32 gps.go:523: RMC Variation, GGA HDOP 0,1.8
[ debug ] 2022/02/10 12:47:32 gps.go:524: GGA Altitude 196.9
[ debug ] 2022/02/10 12:47:32 gps.go:526: GSV SVPRNNumber,SNR, Azimuth Sat(0) 12,29,256
[ debug ] 2022/02/10 12:47:32 gps.go:526: GSV SVPRNNumber,SNR, Azimuth Sat(1) 13,20,168
[ debug ] 2022/02/10 12:47:32 gps.go:526: GSV SVPRNNumber,SNR, Azimuth Sat(2) 10,17,295
[ debug ] 2022/02/10 12:47:32 gps.go:526: GSV SVPRNNumber,SNR, Azimuth Sat(3) 15,32,200
[ debug ] 2022/02/10 12:47:32 gps.go:535: Device Screen Latitude : 44.780375 Longitude : 20.515715
[ debug ] 2022/02/10 12:47:32 gps.go:292: osmand Protocol Traccar Server HTTP Response Code 200 With Status OK
[ debug ] 2022/02/10 12:47:32 gps.go:299: Playing a Traccar diagnostic sound

You can also verify GPS tracking is working by checking Traccar server UI screen and logs.

Traccar server log usually located in /opt/traccar/logs/ directory should show talKKonnect connecting to Traccar server and passing position reports successfully.

root@traccar-srv:~# tail -f /opt/traccar/logs/traccar-server.log
2022-02-10 12:56:13 INFO: [e8b8b2e3] connected
2022-02-10 12:56:13 INFO: [e8b8b2e3: osmand < 87.116.161.185] HEX: 474554202f3f69643d746b2d64656d6f2d30342674696d657374616d703d323032322d30322d313025323031313a35363a3032266c61743d34342e373830343435266c6f6e3d32302e3531353839332673706565643d302e34363030303026636f757273653d302e30303030303026766172696174696f6e3d302e3030303030302668646f703d312e30313030303026616c7469747564653d3231342e39303030303020485454502f312e310d0a486f73743a2034352e36322e3233312e3131323a353035350d0a557365722d4167656e743a20476f2d687474702d636c69656e742f312e310d0a4163636570742d456e636f64696e673a206e6f6e650d0a436f6e6e656374696f6e3a20636c6f73650d0a0d0a
2022-02-10 12:56:13 INFO: [e8b8b2e3: osmand > 87.116.161.185] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2022-02-10 12:56:13 INFO: [e8b8b2e3] id: tk-demo-04, time: 2022-02-10 11:56:02, lat: 44.78045, lon: 20.51589, speed: 0.5, course: 0.0
2022-02-10 12:56:13 INFO: [e8b8b2e3] disconnected

Traccar messages are in HEX format. When the message is decoded, it should read

GET /?id=tk-demo-04&timestamp=2022-02-10%2011:59:47&lat=44.780503&lon=20.515676&speed=0.371000&course=0.000000&variation=0.000000&hdop=1.000000&altitude=192.400000 HTTP/1.1
Host: 45.62.231.112:5055
User-Agent: Go-http-client/1.1
Accept-Encoding: none
Connection: close

and

HTTP/1.1 200 OK
content-length: 0

ERRORS AND DIAGNOSTIC MESSAGES

GPS or Traccar Console Error Message Fault Display Message Sound Alerts (If Enabled)
1 GPS device not connected GPS Function Returned Error Message gnss not enabled Disconnected GPS Dongle GPS ERR1
gpsDeviceError
2 No GPS fix GPS No Good Reading Error GPS is dongle connected. Blocked window to the sky. Weak GPS signal. GPS ERR2
gpsNoGoodRead
3 GPS enabled. Traccar disabled. GPS fix. No error messages No faults GPS OK
gpsOK
4 GPS Enabled. GPS Fix. Traccar enabled. Network connection to Traccar server working. Authentication to Traccar successful.

Traccar server return 2XX OK status message.

Tracking is successful.

No error messages. If gpsinfoverbose in talkkonnect.xml is true, GPS verbose messages will be shown in console screen. No faults TRACK OK
traccarHTTP2XXResponse

(for OsmAnd and OpenGTS)

traccarTCPConnOK

(for T55)

5 Traccar server http connection error.
dial tcp server_address:5055 connect: connection refused
TCP/IP Error Communicating with Traccar Server
A stopped Traccar server or trying to connect to non-existent server

(OsmAnd, OpenGTS, t55)

TRACK ERR1
traccarTCPConnError
6 Traccar server 4XX error.

User is not existing in server.

Or format of http request is wrong

osmand Protocol Traccar Server HTTP Response Code 400 With Status Bad Request
DisableedTraccar device id or using a wrong device name

(osmand, opengts)

TRACK ERR2
traccarHTTP4XXResponse
7 Traccar tcp connection error.
dial tcp server_address:5005 connect: connection refused
Just with t55 TRACK ERR3
traccarTCPConnRefused
8 User is not existing in Traccar server. Or format of t55 protocol tcp message is wrong. There is a problem detecting wrong message format or non-existing user with t55. Client will keep reporting “TRACK OK” to LCD screen even if Traccar server didn’t allow connection. However, there will be a “WARN: Unknown device” warning in the Traccar server log. The error can not be detected in tcp by the client. As far as the client is concerned, it opened up a tcp connection and sent the message. No errors had been returned to client from Traccar server.

Traccar server log will show a warning …

2022-01-16 14:32:46 INFO: [047bf2e5: t55 < 87.116.161.185] HEX: 24504749442c746b2d64656d6f2d30342a30460d0a
2022-01-16 14:32:46 WARN: Unknown device - tk-demo-04 (10.8.0.100)

In most cases we can trust the “TRACK OK” with t55. But it won’t be 100% reliable. In case wrong device client ID was used, LCD message may in deed be “OK”, but the tracking won’t work. Therefore, “ TRACK OK * ” will be printed to LCD display, meaning this is just “conditionally” OK, as long as the device id used is correct. If a connection to server is not working with t55, error message TRACK ERR3 will be shown in the display.

GPS OK. GPS receiver has a “fix”. Serial communication to talKKonnect device is working. You will see this message when GPS is enabled in stand alone mode without Traccar function.

TRACK OK. Sending position report to Traccar server was successful.

GPS device is disconnected. Or serial communication is not working.

GPS ERROR 2 indicates there was no GPS fix with satellites usually because  there is no clear window to the sky.

talKKonnect GPS position reporting to LCD screen.