Spot Gen3 Satellite device support

ericharnisch8 years ago

I would like to know if you support the Spot Gen3 Satellite GPS tracker:

http://www.findmespot.com/en/index.php?cid=100

Anton Tananaev8 years ago

I couldn't find any information on how it communicates with the server and whether it's possible to change the server address.

jaimzj7 years ago

Hello,

I have communicated with the manufacturer/service providers earlier,.

These are satellite based Tracking devices so they do not provide device level configuration to point it to any other server/ip etc.

As these devices send data via satellite to a particular server (of the service provider such as "globalstar.com") they have the connectivity and link for the same. However they were not ready to allow device to point to any other server.

However they were willing to integrate or provide data push to any URL/IP as required by their client that is from their server to any other server such as (traccar0,.

So the best way to integrate I feel, is to reach out to the manufacturer/local service provider and get the device, and then ask them to push each packet from the device/their server to the Traccar Server IP. (this needs to be done by the buyer of device) and the buyer of device can share the osmand protocol details probably for their server with the service provider.

joepr6 years ago

Hello Jaimzj

Sorry for replying on this old post but searching on the forum I found your answer. The latest version of Traccar now support SPOT satellite devices. Did you where able to complete the integration?

Anton Tananaev6 years ago

What exactly do you mean by complete integration?

renaud6 years ago

I suppose he means find a way to make the SPOT tracker send the info to traccar.

joepr6 years ago

Yes! exactly what renaud says. Find a way to forward SPOT data to traccar.

Anton Tananaev6 years ago

You need to contact device vendor for more information about that. From Traccar side we just implemented protocol.

Anderle6 years ago

Hello,

Please excuse my answer to a relative old post in the forum.

There is a very simple solution to using a SpotGen3 tracker in traccar.
Just use the "SPOT Shared Page API" (https://faq.findmespot.com/index.php?action=showEntry&data=69).
The principle is simple. A PHP script is called by a cron job, it gets the data from the "Spot Api" and forwards it via OSMAND to its own traccar server.

Here is a very simple model of this script. It contains no security-relevant checks and no checks for plausibility. It's just a skeleton.

<?php
    //replace "YOUR-Personal-Feed-ID"
    $url='https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/YOUR-Personal-Feed-ID/latest.xml';
    
    $xml = simplexml_load_string(file_get_contents($url));
    $time=$xml->feedMessageResponse->messages->message->dateTime;
    $lat=$xml->feedMessageResponse->messages->message->latitude;
    $long=$xml->feedMessageResponse->messages->message->longitude;
    
    
    //create a new device in traccar
    //replace "SpotGen3" with your personal choice in traccar for uniqueid
    
    $id='SpotGen3';
    
    $Url="http://YOUR-TRACCAR-SERVER:5055/?id=".$id."&time=".$time."&lat=".$lat."&lon=".$long;
    file($Url);
        
    exit;
?>
Antonio Amaury5 years ago

I urgently need to integrate my Spot with the Traccar sheet, someone could do that.

What is the value of this service?

Craig5 years ago

Further to Anderle's great idea above I thought I would share the code that I have successfully imported tracking points (single Spot3 device only) to my server with the following php scripts on a Linux server (Centos 7). I haven't fully tested and implemented error handling and security checks but again likewise like Anderle's post, its just a skeleton.

Step 1.
Create a tracking device with its unique ID on your Traccar server.

Step 2.
Ensure you have php installed on your machine. Via command line on Centos it is "yum install php -y".

Step 3.
Create and save the following php files to your preferred directory. I saved both spot.php and temp.php to /opt/traccar/. Modify the spot.php file with your credentials.

spot.php

<?php

//Include variable from temp.php file located in the same directory.
include 'temp.php';

//Change these variables to user specific.
$traccar_id='Your Device ID Here';
$spot_feed_id="Your Feed ID Here";
$traccar_url="http://YourTraccarServer:8082";
date_default_timezone_set('Australia/Perth'); //Change to your timezone https://www.php.net/manual/en/timezones.php


//Fetch recent XML data from findmespot. 
$url='https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/' . $spot_feed_id . '/latest.xml';
$xml = simplexml_load_string(file_get_contents($url));


//Parse fetched XML data from findmespot and save to PHP variables
$lat=$xml->feedMessageResponse->messages->message->latitude;
$lon=$xml->feedMessageResponse->messages->message->longitude;
$alt=$xml->feedMessageResponse->messages->message->altitude;
$typ=$xml->feedMessageResponse->messages->message->messageType;
$det=$xml->feedMessageResponse->messages->message->messageDetail;
$mes=$xml->feedMessageResponse->messages->message->messageContent;
$nam=$xml->feedMessageResponse->messages->message->messengerName;
$bat=$xml->feedMessageResponse->messages->message->batteryState;
$mod=$xml->feedMessageResponse->messages->message->modelId;


//Convert fetched time from Unix to Traccar required format. For some reason it needs '20' between the date and time to work.
$time=$xml->feedMessageResponse->messages->message->unixTime;
$timestamp = date("Y-m-d%20H:i:s", "$time"); 

//Simple if statement - Check if the $lasttime variable (imported from the temp.php file) equals the current time variable.
//If it does, no update has occurred so exit the script, otherwise continue. This will stop the device always being online in Traccar.
if ($time == $lastime) {
    echo "No update since last fetch";
    exit;
} else {


//Use curl to post data to Traccar server.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$traccar_url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
          "id=$traccar_id&
          Latitude=$lat&
          longitude=$lon&
          Altitude=$alt&
          Message Type=$typ&
          Message Detail=$mes&
          Messenger Name=$nam&
          Battery State=$bat&
          Last Update=$timestamp&
          Model Type=$mod"
          );

// Receive server response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);

// Uncomment the following for debugging.
//$info = curl_getinfo($ch);
//print_r($info);

// End curl command
curl_close ($ch);

// Update Unix time stamp variable to temp.php
$var = "<?php\n\n\$lastime ='" . $time . "';\n\n?>";
file_put_contents('temp.php', $var);

}
?>


temp.php
<?php

$lastime ='1561616681';

?>

Step 4.
Create a cronjob to run the script every say every 4 minutes. Be careful not to exceed findmespots polling time specified here: https://faq.findmespot.com/index.php?action=showEntry&data=69

They don't want you to to exceed 2.5 minutes.

Example of setting up a cron via linux command line;

crontab -e
*/4 * * * * /usr/bin/php /opt/traccar/spot.php

Save the file - obviously some basic linux commands are to be assumed here.

Step 5.
Hopefully that's it. I have not implemented it with multiple devices, as I'm not sure how findmespot handles multiple devices. If it is the same feed id or different.. I haven't got two to test. Thanking Anton and his team for providing such a great application - and being open source is unreal!

Craig5 years ago

Apologies for the duplicate post, however this one is a bit easier to read with mark down. Feel free to delete my first post.

Further to Anderle's great idea above I thought I would share the code that I have successfully imported tracking points (single Spot3 device only) to my server with the following php scripts on a Linux server (Centos 7). I haven't fully tested and implemented error handling and security checks but again likewise like Anderle's post, its just a skeleton.

Step 1.
Create a tracking device with its unique ID on your Traccar server.

Step 2.
Ensure you have php installed on your machine. Via command line on Centos it is "yum install php -y".

Step 3.
Create and save the following php files to your preferred directory. I saved both spot.php and temp.php to /opt/traccar/. Modify the spot.php file with your credentials.

spot.php

<?php

//Include variable from temp.php file located in the same directory.
include 'temp.php';

//Change these variables to user specific.
$traccar_id='Your Device ID Here';
$spot_feed_id="Your Feed ID Here";
$traccar_url="http://YourTraccarServer:8082";
date_default_timezone_set('Australia/Perth'); //Change to your timezone https://www.php.net/manual/en/timezones.php


//Fetch recent XML data from findmespot. 
$url='https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/' . $spot_feed_id . '/latest.xml';
$xml = simplexml_load_string(file_get_contents($url));


//Parse fetched XML data from findmespot and save to PHP variables
$lat=$xml->feedMessageResponse->messages->message->latitude;
$lon=$xml->feedMessageResponse->messages->message->longitude;
$alt=$xml->feedMessageResponse->messages->message->altitude;
$typ=$xml->feedMessageResponse->messages->message->messageType;
$det=$xml->feedMessageResponse->messages->message->messageDetail;
$mes=$xml->feedMessageResponse->messages->message->messageContent;
$nam=$xml->feedMessageResponse->messages->message->messengerName;
$bat=$xml->feedMessageResponse->messages->message->batteryState;
$mod=$xml->feedMessageResponse->messages->message->modelId;


//Convert fetched time from Unix to Traccar required format. For some reason it needs '20' between the date and time to work.
$time=$xml->feedMessageResponse->messages->message->unixTime;
$timestamp = date("Y-m-d%20H:i:s", "$time"); 

//Simple if statement - Check if the $lasttime variable (imported from the temp.php file) equals the current time variable.
//If it does, no update has occurred so exit the script, otherwise continue. This will stop the device always being online in Traccar.
if ($time == $lastime) {
    echo "No update since last fetch";
    exit;
} else {


//Use curl to post data to Traccar server.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$traccar_url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
          "id=$traccar_id&
          Latitude=$lat&
          longitude=$lon&
          Altitude=$alt&
          Message Type=$typ&
          Message Detail=$mes&
          Messenger Name=$nam&
          Battery State=$bat&
          Last Update=$timestamp&
          Model Type=$mod"
          );

// Receive server response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);

// Uncomment the following for debugging.
//$info = curl_getinfo($ch);
//print_r($info);

// End curl command
curl_close ($ch);

// Update Unix time stamp variable to temp.php
$var = "<?php\n\n\$lastime ='" . $time . "';\n\n?>";
file_put_contents('temp.php', $var);

}
?>

temp.php

<?php

$lastime ='1561616681';

?>

Step 4.
Create a cronjob to run the script every say every 4 minutes. Be careful not to exceed findmespots polling time specified here: https://faq.findmespot.com/index.php?action=showEntry&data=69

They don't want you to to exceed 2.5 minutes.

Example of setting up a cron via linux command line;

crontab -e
*/4 * * * * /usr/bin/php /opt/traccar/spot.php

and then save the file - obviously some basic linux commands are to be assumed here.

Step 5.
Hopefully that's it. I have not implemented it with multiple devices, as I'm not sure how findmespot handles multiple devices. If it is the same feed id or different.. I haven't got two to test. Thanking Anton and his team for providing such a great application - and being open source is unreal!

Craig5 years ago

Correction in the above code. Please change the following in spot.php

curl_setopt($ch, CURLOPT_POSTFIELDS,
          "id=$traccar_id&
          Latitude=$lat&
          longitude=$lon&
          Altitude=$alt&
          Message Type=$typ&
          Message Detail=$mes&
          Messenger Name=$nam&
          Battery State=$bat&
          Last Update=$timestamp&
          Model Type=$mod"
          );

to

curl_setopt($ch, CURLOPT_POSTFIELDS,"id=$traccar_id&lat=$lat&lon=$lon&timestamp=$timestamp&altitude=$alt&Message%20Type=$typ&Message%20Detail=$mes&Messenger%20Name=$nam&Battery%20State=$bat&Model%20Type=$mod");
RICARDO14 days ago

Good morning, is there any device to test? I need the ID.