Community discussions

 
almj
just joined
Topic Author
Posts: 1
Joined: Thu Sep 08, 2016 8:29 am

Traccar GPS http post advice

Wed Sep 05, 2018 6:55 am

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!
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Traccar GPS http post advice

Fri Sep 07, 2018 12:08 am

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..."}
 
mibauer1701
just joined
Posts: 2
Joined: Mon Sep 17, 2018 7:20 pm

Re: Traccar GPS http post advice

Mon Sep 24, 2018 11:58 pm

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
 
VipITBE
just joined
Posts: 23
Joined: Tue Apr 02, 2013 10:40 am

Re: Traccar GPS http post advice

Mon Nov 26, 2018 12:34 pm

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
 
User avatar
jspool
Member
Member
Posts: 390
Joined: Sun Oct 04, 2009 4:06 am
Location: Oregon

Re: Traccar GPS http post advice

Mon Nov 26, 2018 6:32 pm

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.
 
VipITBE
just joined
Posts: 23
Joined: Tue Apr 02, 2013 10:40 am

Re: Traccar GPS http post advice

Tue Nov 27, 2018 10:57 am

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
Last edited by VipITBE on Tue Nov 27, 2018 1:49 pm, edited 1 time in total.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24191
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Traccar GPS http post advice

Tue Nov 27, 2018 1:18 pm

v6.44beta37 will have:

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

ddmm will be an option.
No answer to your question? How to write posts
 
VipITBE
just joined
Posts: 23
Joined: Tue Apr 02, 2013 10:40 am

Re: Traccar GPS http post advice

Tue Nov 27, 2018 1:50 pm

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 ?
 
VipITBE
just joined
Posts: 23
Joined: Tue Apr 02, 2013 10:40 am

Re: Traccar GPS http post advice

Thu Nov 29, 2018 2:35 pm

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
 
User avatar
jspool
Member
Member
Posts: 390
Joined: Sun Oct 04, 2009 4:06 am
Location: Oregon

Re: Traccar GPS http post advice

Fri Nov 30, 2018 2:48 am

v6.44beta37 will have:

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

ddmm will be an option.
Thanks Normis!
 
nemke
Member Candidate
Member Candidate
Posts: 107
Joined: Thu Jul 31, 2014 2:52 am

Re: Traccar GPS http post advice

Wed Dec 19, 2018 12:03 am

Where is "cordinate format" in CLI ?
Under system/gps I can't find it. I use 6.44.beta50
 
bazzer
Trainer
Trainer
Posts: 79
Joined: Sat Mar 07, 2009 11:51 pm
Contact:

Re: Traccar GPS http post advice

Fri Dec 21, 2018 10:39 pm

continued monitoring
/system gps monitor format=<dd ddmm dms>
one off read out
/system gps monitor once format=<dd ddmm dms>
Barry Higgins
Mikrotik Certified Trainer
MTCRE MTCWE MTCTCE MTCUME MTCIPv6E MTCINE MTCSE
https://www.allness.it

Who is online

Users browsing this forum: No registered users and 11 guests