Traccar Server forward GPS devices to PhoneTrack

Forward GPS devices from Traccar Server to PhoneTrack application in Nextcloud

GPS Device (bin data) —> Traccar Server —> Nextcloud PhoneTrack

Motivation
The Traccar Server supports a lot of GPS devices, especially a lot of devices sending binary data instead of http requests. PhoneTrack can by its nature only support devices sending http requests.
Therefore I want to forward device information from Traccar Server to PhoneTrack.

GPS Device
In this example I used Sinotrack ST-901 GPS-Tracker, with is sending binary data in so called “h02” protocol.

Traccar Server device list:
https://www.traccar.org/devices/

Install Traccar Server Docker Image
I installed the docker image of Traccar Server on my Synology NAS.
https://hub.docker.com/r/traccar/traccar
Traccar Server uses a lot of ports for the different device protocols, checkout the device list, which ports you need.
My docker ports:
-p 8082:8082 (Webinterface)
-p 5013:5013 (h02 protocol)
-p 5055:5055 (Traccar client app on Android)

My docker volumes:
-v host/path/traccar/logs:/opt/traccar/logs
-v host/path/traccar/data:/opt/traccar/data
-v host/path/traccar/conf/traccar.xml:/opt/traccar/conf/traccar.xml

Default traccar.xml can be downloaded from here:
https://github.com/traccar/traccar/blob/master/setup/traccar.xml

Setup Router
Configure your router to forward needed ports, in my case I use only TCP 5013 for the GPS device.
Setup an dyndns service for your router, if needed.

Setup GPS Device
In my case I have to send an SMS command to configure the device the ip address and port of my router.
Sinotrack ST-901:
IP#mydevicename.dyndns.org#5013#

Device in Traccar Server
Checkout out the log file of Traccar Server if data is received.
You need to configure a new device in Traccar and fill in the device id, which is printed in the log file.
Do NOT use spaces in the device name or special chars!
The device status should go to online when data is received next time.

PhoneTrack configuration
Create a new session, e.g. with the name “MyTraccar”.
Click on “Links for logging apps”
Copy the link of “HTTP GET link”.
Do not use the Traccar link. (This can be used for the android Traccar Client app)
The link looks like:
https://myNextcloud.domain.com/index.php/apps/phonetrack/logGet/abcSessionID123/yourname?lat=LAT&lon=LON&alt=ALT&acc=ACC&bat=BAT&sat=SAT&speed=SPD&bearing=DIR&timestamp=TIME

Traccar Server configuration
Open “traccar.xml” and add following values:

<entry key='forward.json'>false</entry>
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>https://mynextcloud.domain.com/index.php/apps/phonetrack/logGet/abcSessionID123/{name}?lat={latitude}&amp;lon={longitude}&amp;alt={altitude}&amp;speed={speed}&amp;bearing={course}&amp;timestamp={fixTime}</entry>
  • Replace the link until your session id.
  • Restart Traccar Server
  • Each “&” in the link needs to be encoded as “&” otherwise the server will crash.

For possible replacements in the link you need to checkout the source code here:
https://github.com/traccar/traccar/blob/master/src/main/java/org/traccar/WebDataHandler.java

Checkout again the Traccar log, if data is received from your GPS device.

PhoneTrack
GPS Data of each Traccar device should now be forwarded the PhoneTrack.
Each device appears with the device name configured in Traccar server.

Traccar Events
Traccar can forward events as well …

<entry key="event.forward.enable">true</entry>
<entry key='event.forward.url'>https://mydomain.com/api/mywebhooks</entry>

Currently I don’t know how to configure it together with PhoneTrack, please post it here, if you know how it works.

Traccar forward json format
Traccar can be configured to forward json formatted data with.
As far as i know PhoneTrack does not understand this.
This could be a feature request to the developers :slight_smile:

<entry key='forward.json'>true</entry>
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>https://mynextcloud.domain.com/index.php/apps/phonetrack/logGet/abcSessionID123/</entry>

Links
https://www.my-gps.org/292-sinotrack-st901-anleitung
https://github.com/traccar/traccar/issues/3040#issuecomment-288382772

1 Like