Traccar + SigFox

Peter Hanzlik8 years ago

Dear all,

I'm completely new to Traccar.

My intention is to visualize GPS data that are sent through SigFox network. I have a back-end system that receives data from SigFox and stores LAT, LON, ALT, TST + some other custom fields (signal strength, battery level, ...) into my SQL DB. Now I would like to use the Traccar API to POST these values. However in the API I see only GET methods for Positions so I'm not sure how to do this.

Is there any guide on how to use the API, some samples, tutorial?

Thank you
Peter

Anton Tananaev8 years ago

You can use OsmAnd protocol to post the data:

https://www.traccar.org/osmand/

Peter Hanzlik8 years ago

Hello Anton,

wonderful! I can even add custom attributes.

For reference, someone may find it useful:

http://ip:5055?id=XXXXXXXX&lat=48.12&lon=17.12&altitude=137&snr=31.39&avgSnr=45.40&duplicate=0&station=12DA&rssi=-120.00&seqNumber=66×tamp=2017-02-27T23:35:27

Thank you
Peter

Renan Salvador6 years ago

Hello Gents,
I'm a new user here!
I did the setup that you guided in the post above, but I have a problem with Sigfox + Tracker, could you please help me?

In log file (tracker-server.log) appear this error:

WARN: [23b1b635] error - Invalid token=EOF at (line no=1, column no=0, offset=-1). Expected tokens are: [CURLYOPEN, SQUAREOPEN] - JsonParsingException (... < SigfoxProtocolDecoder:49 < ExtendedObjectDecoder:51 < ... < WrapperContext:102 < ...)

Thanks!

Anton Tananaev6 years ago

Please provide more information from your logs, including HEX data.

Renan Salvador6 years ago

Hi Anton,

The Payload:

2018-09-05 16:26:05  INFO: [23b1b635] connected
2018-09-05 16:26:05 DEBUG: [23b1b635: 5154 < 185.110.97.11] HEX: 474554202f3f69643d343145353035266475706c696361746566616c73653d26736e723d362e33372673746174696f6e3d3741353426646174613d3032343030306666383030653933666565363938633126617667536e723d31322e3439266c61743d2d32332e30266c6e673d2d35312e3026727373693d2d3132392e3030267365714e756d6265723d3331303420485454502f312e310d0a686f73743a2074726163657061636b2e64646e732e6e65743a31303030300d0a6163636570742d6c616e67756167653a2066720d0a6163636570742d656e636f64696e673a20677a69702c6465666c6174650d0a757365722d6167656e743a20534947464f580d0a6163636570742d636861727365743a205554462d383b713d302e392c2a3b713d302e370d0a0d0a
2018-09-05 16:26:05  WARN: [23b1b635] error - Invalid token=EOF at (line no=1, column no=0, offset=-1). Expected tokens are: [CURLYOPEN, SQUAREOPEN] - JsonParsingException (... < SigfoxProtocolDecoder:49 < ExtendedObjectDecoder:51 < ... < WrapperContext:102 < ...)
2018-09-05 16:26:05  INFO: [23b1b635] disconnected

Thanks!

Anton Tananaev6 years ago

What your device sends doesn't conform to the implemented protocol. Do you have documentation?

Renan Salvador6 years ago

I configured the callback in the Sigfox backend like this:

http://tracepack-host/?id={device}&duplicate{duplicate}&snr={snr}&station={station}&data={data}&avgSnr={avgSnr}&lat={lat}&lng={lng}&rssi={rssi}&seqNumber={seqNumber}

Is there any other documentation for Traccar to receive Sigfox payloads?

Thanks!

Anton Tananaev6 years ago

Traccar expects POST request from SigFox. For your format you can try OsmAnd protocol (port 5055).

Renan Salvador6 years ago

Thanks Anton!
I'll try your sugestion.

Hi Anton ,I have the same problem regarding the structure of sigfox to configure in the backend.sigfox using the osmand protocol but I don't how to adapt it changing "lng" to "lon" because where I bought the gps devices they suggest to take this json structure

{ 
  "device" : "{device}", 
  "time" : "{time}", 
  "duplicate" : "{duplicate}", 
  "snr" : "{snr}", 
  "station" : "{station}", 
  "data" : "{data}", 
  "avgSnr" : "{avgSnr}", 
  "lat" : "{lat}", 
  "lng" : "{lng}", 
  "rssi" : "{rssi}", 
 "seqNumber" : "{seqNumber}" 
}

i tried to adjust to the osmand protocol like this

http://ip:5055?id=411485645&lat=20.1568&lon=-100.6548&altitude=1370&snr=31.50&avgSnr=45.40&duplicate=0&station=12DA&rssi=-120.00&seqNumber=66

I did tests with that structure sending the data as a post and it works in traccar but if I change "lon" to "lng" it doesn't work. thank you.

Anton Tananaev5 years ago

Sigfox protocol is supported natively. I'm not sure why you are trying to use OsmAnd.

thanks for your prompt response Anton,I supported me from the previous comments of people trying to connect sigfox with traccar in this forum. What structure should I configure to receive sigfox data on the traccar server? thank you in advance

Peter Hanzlik5 years ago

Hi Alfredo,
If I'm not mistaken, {lat} and {lng} fields from Sigfox backend are GPS coordinates of the nearest BTS station, that gives you very poor precision. You should either use the Sigfox callback that uses the geolocation service (paid one) that gives you precision about 10-20km, or use your GPS module on the device and send the GPS coordinates in {data} field. Then you will parse the {data} to get GPS coordinates from the device and then send it to Traccar. Example in PHP (note that fields $latitude[1], $longitude[1], $altitude[1] are parsed from the {data} Sigfox field):

$url = 'http://traccar.url:5055';
$myvars = 'id=' . $_device . '&lat=' . $latitude[1] . '&lon=' . $longitude[1] . '&altitude=' . $altitude[1] . '&snr=' . $_snr . '&avgSnr=' . $_avgSnr . '&duplicate=' . ($_duplicate?1:0) . '&station=' . $_station . '&rssi=' . $_rssi . '&seqNumber=' . $_seqNumber . '&timestamp=' . str_replace(' ', 'T', $_timestamp);
    
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec( $ch );

Best Regards
Peter

DeZ4 years ago

Hi

Have you an example to set up SIGFOX callback to send data to traccar server ?

https://drive.google.com/file/d/1e2Op_6VOEz42gTDAAyfxapnTY_LBoTWb/view?usp=sharing

Thanks