Skip to content

Latest commit

 

History

History
114 lines (70 loc) · 4.78 KB

ConfigureCargo.md

File metadata and controls

114 lines (70 loc) · 4.78 KB

Configure cargo

Cargo integration

Cargo is a tool from Helium to display real-time tracking device position on a map. This tool displays your position publicly but is really easy to use. As is also displayed the coverage map as an extra layer, it is a useful tool to find the hexagon not yet tested to complete the coverage map. In this tool, you will search your device by its name, the use of a unique name will help you to find it.

To make Cargo working with WioLoRaWANFieldTester, we need to create a decoding function to pass it the device coordinate in the right format.

Setup a decoding function

Create a decoding function from the Helium console dashboard. Click on the + button and select Add function

Helium create new function

Once in the Add function screen, you need to give it a name:

Helium create new function

Then you can type the decoder function. This function will proceed the payload received from the device and convert it in a structure the Cargo application is able to understand.

Helium create new decoder

Copy & Paste the following JS content into the decoder textarea:

function Decoder(bytes, port) { 
  var decoded = {};
  
  if ( port != 1 ) return decoded;
  
  var lonSign = (bytes[0]>>7) & 0x01 ? -1 : 1;
  var latSign = (bytes[0]>>6) & 0x01 ? -1 : 1;
  
  var encLat = ((bytes[0] & 0x3f)<<17)+
               (bytes[1]<<9)+
               (bytes[2]<<1)+
               (bytes[3]>>7);

  var encLon = ((bytes[3] & 0x7f)<<16)+
               (bytes[4]<<8)+
               bytes[5];
  
  var hdop = bytes[8]/10;
  var sats = bytes[9];
  
  const maxHdop = 2;
  const minSats = 5;
  
  if ((hdop < maxHdop) && (sats >= minSats)) {
    // Send only acceptable quality of position to mappers
    decoded.latitude = latSign * (encLat * 108 + 53) / 10000000;
    decoded.longitude = lonSign * (encLon * 215 + 107) / 10000000;  
    decoded.altitude = ((bytes[6]<<8)+bytes[7])-1000;
    decoded.accuracy = (hdop*5+5)/10
    decoded.hdop = hdop;
    decoded.sats = sats;
  } else {
    decoded.error = "Need more GPS precision (hdop must be <"+maxHdop+
      " & sats must be >= "+minSats+") current hdop: "+hdop+" & sats:"+sats;
  }

  return decoded;
}

Setup Cargo integration

Now you need to create an Integration with Cargo, for this, create a new integration

Helium create new integration

You need to select the type of integration, here it is Cargo:

Helium create new Cargo integration

Please read the warning about data privacy and accept it if you agree on the terms:

Helium create new Cargo integration

Now you can give a name to this integration:

Helium create new Cargo integration

As you can see, we do not need to give details about the integration endpoint, by selecting Cargo integration, the console automatically knows how to transfer the informations.

Setup Cargo flow

Now, you need to make the link between our Label, the created Function and the Cargo Integration. For this you, go the the Flow panel:

Helium create new flow

Once in it, you can extend the Node to access the different tabs:

Helium modify a flow

Then you need to insert the Function previously created by selecting the Function tab, then drag & drop the created function into the flow diagram:

Helium modify a flow

Then you need to do the same with the Cargo Integration. Select the Integration tab and drag & drop the Cargo integration you previously created.

Helium modify a flow

All these components, now, need to be linked together to create the flow. Click on the node's connectors and drag your mouse up to the destination.

Helium modify a flow

To make sure all these changes will be applied, don't forget to Save your changes:

Helium modify a flow

Your Cargo setup is DONE you can go back to installation page for the next steps