Traccar

195 views
Skip to first unread message

mike

unread,
Mar 1, 2019, 4:00:41 PM3/1/19
to Open Source CAD
I have just set up Traccar on another server, but in the same subnet as the Tickets server.

So far, I am very impressed with Traccar, not only is it much easier to set up then OpenGTS was, but I like the GUI and usability of it much better. 

I am, however, having trouble getting Tickets to update unit locations from it. 
Here is what I have done:
  1. Created a MySQL user for tickets
  2. Gave that user select permissions.
  3. Modified the bind address of MySQL
  4. I can SSH into the tickets server and connect remotely to the Traccar MySQL server without issue.
  5. I modified the Tickets config with the IP address of Traccar, the MySQL server user and password, and set track length to 12.  
  6. I changed a few test units from OpenGTS to Traccar config
  7. Tickets now takes a long time to load the situation screen and the unit locations never update. 

There is not Traccar GPS test under config, and I am not sure where to go from here to test.  Any help is appreciated. 

mdtayl...@gmail.com

unread,
Mar 7, 2019, 7:40:43 PM3/7/19
to Open Source CAD
Mike,

Traccar did an update that broke the traccar integration into Tickets, therefore the traccar code within 3.30 does not work.

Make a backup of your remotes.inc.php file and save it somewhere that you can find and restore it if necessary. I have attached the replacement remotes.inc.php file. Give it a try. You will have to rename it without the (1) to simply remotes.inc.php


Mark
remotes.inc(1).php

mike

unread,
May 7, 2019, 7:11:49 PM5/7/19
to Open Source CAD
That worked, thank you. 

Roberto Sanglay

unread,
Aug 28, 2019, 9:19:36 PM8/28/19
to Open Source CAD
Traccar supports REST API request.

I have created a script to test a Traccar  server using an API request.

Attached here is traccar.php. copy and drop it to your server install folder.
note:  
1. for the server url installed on the same tix server use "localhost:8082"
2. for userid, use the user that was used to create the devices.
3.  password used for the user above.

This in not a a direct db access so don't use the database user/password.

Check out the images.

traccar-credentials.png


traccar-results.png

traccar.php

Roberto Sanglay

unread,
Sep 4, 2019, 10:25:39 PM9/4/19
to Open Source CAD
Traccar with RES API based request (instead of dbase access) now fully tested.

The original Traccar script on remotes.inc.php requires access to Traccar server database.  The revised script which implements a REST API request to the Traccar server (very useful for Traccar servers installed on a different server - other than the tix server) is available for those who need it. give me a message and I'll send you the code.

Robert

Richard Pearce

unread,
Sep 6, 2019, 5:01:37 PM9/6/19
to Open Source CAD
Hi Roberto, 

After a bit of a break I'm about to get back to looking at this, and i have a traccar server installed on a different server. I'd appreciate a copy of the script please? 

Thanks
Richard

Roberto Sanglay

unread,
Sep 10, 2019, 2:20:40 AM9/10/19
to Open Source CAD
Richard,


Test Traccar connection.
1. Attached is the revised traccar test script (rename if yo want to retain the original script.
 
The Traccar function inside remotes.inc.php file.
1. Prep. the Tickets settings database.
    To provide for storage and retrieval of the connection variables:

a.  Create a new setting by applying the following sql in PHPmyAdmin  (I assume you're not using db_prefix.)
    "INSERT INTO `settings` (name,value) VALUES('Traccar_URL','')";
    "INSERT INTO `settings` (name,value) VALUES('Traccar_userid','')";
    "INSERT INTO `settings` (name,value) VALUES('Traccar_password','')";

b.  Then, when you next log into Tickets go to Config/Edit settings, you will be able to set these values.

c.  To retrieve these in the tracking script, it's
    $url = get_variable('Traccar_URL');
    $userid = get_variable('Traccar_userid');
    $password = get_variable('Traccar_password');

2.  open or edit /incs/remotes.inc.php 
     either put remarks or delete the "function do_traccar" portion.

     replace with the attached script.
traccar (1).php
traccar_function.txt

Roberto Sanglay

unread,
Sep 10, 2019, 10:16:28 PM9/10/19
to Open Source CAD
Richard,

Please take note of the changes I've made on the remotes.inc.php
(you can either comment it out or delete it)
1.  removed the error display for devices that has not posted locations yet. the device number will not have any entry in the REST API results and the Lat / Lng is still blank.

2.  I missed commenting out the echo line on the previous file.

Regards,

Robert

// if ( sane ( floatval ($lat), floatval ($lng), intval ($updated) ) ) {
   $where_clause = "WHERE `traccar` = 1 AND `callsign` = '{$callsign_in}'";
   $integerval = 0 *60;                              //  Set with intval(get_variable('delta_mins'))*60) if you have problems with time sync.

$now = date("Y-m-d H:i:s", time() - $integerval);

$query = "UPDATE `$GLOBALS[mysql_prefix]responder` SET `lat` = " . $lat . ", `lng` = " . $lng . " " . $where_clause;

$result = mysqli_query($tickets_connect, $query);
// removed error message               or do_error($query, 'mysql query failed', mysqli_error(), basename( __FILE__), __LINE__);

// any movement?
if ($result) {
//                  echo "The result status = " . $result . "\n";
$query = "UPDATE `$GLOBALS[mysql_prefix]responder` SET `updated` = '" . date("Y-m-d H:i:s", time()) . "' " . $where_clause;

$result_temp = mysqli_query($tickets_connect, $query) or do_error($query, 'mysql query failed', mysqli_error(), basename( __FILE__), __LINE__);
$our_hash = $callsign_in . (string) (abs($lat) + abs($lng)) ; // a hash - for dupe prevention

$query = "INSERT INTO `$GLOBALS[mysql_prefix]tracks` (
packet_id, source, latitude, longitude, speed, course, altitude, packet_date, updated) VALUES (
'{$our_hash}', '{$callsign_in}', '{$lat}', '{$lng}', '{$speed}', '{$course}', '{$altitude}', '{$p_d_timestamp}', '{$now}')";

                    $result = mysqli_query($tickets_connect, $query);
} // end if ($results is true)
// }                   // end if sane
    }                    // end while $row1
mysqli_close($tickets_connect);
}                         // end function do_traccar()


Regards,
Robert

On Saturday, March 2, 2019 at 5:00:41 AM UTC+8, mike wrote:

Richard Pearce

unread,
Sep 11, 2019, 2:18:09 AM9/11/19
to Open Source CAD
Thanks Robert. I’ll let you know how I get on

Regards
Richard

Richard Pearce

unread,
Sep 16, 2019, 3:47:23 AM9/16/19
to Open Source CAD
Hi Robert,

Just to let you know I installed the Traccar API over the weekend and it’s worked perfectly. Our Traccar install is on another server so this made everything very easy to set up.

Thanks for the hard work.
Richard

Roberto Sanglay

unread,
Sep 17, 2019, 1:45:39 AM9/17/19
to Open Source CAD
Richard,

Happy to hear that.

Robert

Roberto Sanglay

unread,
Sep 17, 2019, 1:56:53 AM9/17/19
to Open Source CAD
To everyone interested in implementing Traccar for the Tix.

The traccar.php (check the thread) I uploaded is a test script the you can run independently or call from the config script.  Either way, you have  a convenient way to check your traccar install (either on the same server as tix or on another server) and see the contents extracted from the database via REST API request.

Check out also the patch script for remotes.inc.php, which implements an API request instead of a MySQL DB access (to prevent router/firewall port closed/forward problems on port #3306)

Regards,

Robert

On Saturday, March 2, 2019 at 5:00:41 AM UTC+8, mike wrote:
Reply all
Reply to author
Forward
0 new messages