Page 1 of 1

Traccar GPS http post advice

Posted: Wed Sep 05, 2018 6:55 am
by almj
Hi Team,

I've got hAP ac2 which will live in my car together with 3G modem and a GPS receiver.
It's all configured, I have internet and VPN tunnel back to home, GPS data is also getting through.

Now I need to send the GPS data to the Traccar server.
There is a script on wiki:
{
:global lat
:global lon
/system gps monitor once do={
:set $lat $("latitude")
:set $lon $("longitude")
}
tool fetch mode=http url="http://10.55.8.160/index.php" port=8080 http-method=post \
http-data=("{\"lat\":\"" . $lat . "\",\"lon\":\"" . $lon . "\"}") http-content-type="application/json"
:put ("{\"lat\":\"" . $lat . "\",\"lon\":\"" . $lon . "\"}")
}
The problem is that I need to send data in OsmAnd format, the syntax is very simple:
http://demo.traccar.org:5055/?id=123456&lat={0}&lon={1}&timestamp={2}&hdop={3}&altitude={4}&speed={5}
id is fixed for the current device.

Can you please help to modify the original script?

Thank you so much!

Re: Traccar GPS http post advice

Posted: Fri Sep 07, 2018 12:08 am
by ADahi
I do not have GPS, but i tried to write one, may help you
:do {
:local latitude ([/system gps monitor as-value once]->"latitude");
:local longitude ([/system gps monitor as-value once]->"longitude");

:do {/tool fetch keep-result=no url=("http://demo.traccar.org:5055/\?id=123456&lat=" . $latitude . "&lon=" . $longitude . "&timestamp={2}&hdop={3}&altitude={4}&speed={5}")
} on-error={:log error message="Fetch failed..."}

} on-error={:log error message="GPS script failed..."}

Re: Traccar GPS http post advice

Posted: Mon Sep 24, 2018 11:58 pm
by mibauer1701
Thanks for the hint, but I´m not able to get it working...

Can please someone add a working script? Or give at least a little help?

Thanks!!
Michael

Re: Traccar GPS http post advice

Posted: Mon Nov 26, 2018 12:34 pm
by VipITBE
The problem is that the values returned by the tik GPS are not in a decimal value.
You need the data in a decimal value to post to traccar. Same with altitude and speed. For those you need to remove m and km/h from the data.
Just tested with Postman and after converting the latitude and longtitude to decimal value it would post

Re: Traccar GPS http post advice

Posted: Mon Nov 26, 2018 6:32 pm
by jspool
viewtopic.php?f=9&t=137114&p=697697&hil ... pi#p697348

When Mikrotik updates the GPS package and enables it to output the location data to a friendly format it should work fine without requiring a middleman server to translate the data.
Currently I use Particle Electrons to send location data to Traccar and it works great. However I would love to use the LtAP as well.

Re: Traccar GPS http post advice

Posted: Tue Nov 27, 2018 10:57 am
by VipITBE
I've got a working script since last night.
Started working on it and took some code snips from other scripts, including a github page I've found to be very helpfull, and the script translates the coordinates - outputted by /gps monitor - to decimal coordinates.
I've uploaded the script to github, but will be making some changes.
The tracket ID is the same as the LTE IMEI address
I'll be experimenting with the date-time so that can also be uploaded to traccar.

The current variables that need be updated are:
:local serverurl "demo5.traccar.org";
:local serverport "5055";
The script is located at
https://github.com/CreasaBE/Mikrotik_Sc ... ar_updater

Re: Traccar GPS http post advice

Posted: Tue Nov 27, 2018 1:18 pm
by normis
v6.44beta37 will have:

*) gps - added "coordinate-format" parameter (CLI only);

ddmm will be an option.

Re: Traccar GPS http post advice

Posted: Tue Nov 27, 2018 1:50 pm
by VipITBE
v6.44beta37 will have:

*) gps - added "coordinate-format" parameter (CLI only);

ddmm will be an option.
Sweet!
Is there some way of extracting or generating a datetime timestamp ?

Re: Traccar GPS http post advice

Posted: Thu Nov 29, 2018 2:35 pm
by VipITBE
v6.44beta37 will have:

*) gps - added "coordinate-format" parameter (CLI only);

ddmm will be an option.
Sweet!
Is there some way of extracting or generating a datetime timestamp ?
Timestamp issue solved with a script from forum user adeeadee
viewtopic.php?t=75555

script updated with the addition of the datestamp and posting the datestamp to the Traccar server

Re: Traccar GPS http post advice

Posted: Fri Nov 30, 2018 2:48 am
by jspool
v6.44beta37 will have:

*) gps - added "coordinate-format" parameter (CLI only);

ddmm will be an option.
Thanks Normis!

Re: Traccar GPS http post advice

Posted: Wed Dec 19, 2018 12:03 am
by nemke
Where is "cordinate format" in CLI ?
Under system/gps I can't find it. I use 6.44.beta50

Re: Traccar GPS http post advice

Posted: Fri Dec 21, 2018 10:39 pm
by bazzer
continued monitoring
/system gps monitor format=<dd ddmm dms>
one off read out
/system gps monitor once format=<dd ddmm dms>