Cargo Payload Format

Cargo is an internal application developed by the Helium team for doing basic location tracking of LongFi-enabled devices. Here’s a (slightly dated) example of the Cargo UI here:

Also here:

Helium is in the process of making Cargo open to the community (details to come on this soon). Before that happens, if you want to plan for using Cargo with your LongFi-enabled location sensors, here’s the program you can use to properly define the payload and send data.

#include <Arduino.h>
#include <SPI.h>
#include "LongFi.h"
#include <Adafruit_GPS.h>
// set OUI and device_id to work with LongFi routing
const uint32_t oui = CHANGE_THESE_WITH_VALUES_FROM_CONSOLE;
const uint16_t device_id = CHANGE_THESE_WITH_VALUES_FROM_CONSOLE;
const uint8_t preshared_key[16] = CHANGE_THESE_WITH_VALUES_FROM_CONSOLE;
uint32_t timer = millis();
// Discovery L072CZ-LRWAN1
const uint8_t RADIO_RESET_PIN = RADIO_RESET_PORT;
const uint8_t RADIO_DIO_0_PIN = RADIO_DIO_0_PORT;
const uint8_t RADIO_MOSI_PIN  = RADIO_MOSI_PORT;
const uint8_t RADIO_MISO_PIN  = RADIO_MISO_PORT;
const uint8_t RADIO_SCLK_PIN  = RADIO_SCLK_PORT;
const uint8_t RADIO_SS_PIN    = RADIO_NSS_PORT;
const uint8_t LED             = LED_BLUE; 
LongFi LongFi(LongFi::RadioType::SX1276, RADIO_RESET_PIN, RADIO_SS_PIN, RADIO_DIO_0_PIN);
HardwareSerial Serial1(PA_10, PA_9);
#define GPSSerial Serial1
Adafruit_GPS GPS(&GPSSerial);
void setup() {
  Serial.begin(9600);
  Serial.println("Setup Start");
  pinMode(LED, OUTPUT);
  SPI.setMOSI(RADIO_MOSI_PIN);
  SPI.setMISO(RADIO_MISO_PIN);
  SPI.setSCLK(RADIO_SCLK_PIN);
  SPI.setSSEL(RADIO_SS_PIN);
  SPI.begin();
  LongFi.init(oui, device_id, preshared_key);
  //Setup Adafruit GPS
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
  GPS.sendCommand(PGCMD_ANTENNA);
  
  Serial.println("Setup Complete");
}
void transmitCallback(void) {
  static uint8_t payload[32];
  uint8_t idx = 0;
  uint32_t data;
  if (GPS.fix) {
    Serial.println("Got a fix!");
    data = (uint32_t)(GPS.latitudeDegrees * 1E7);
    payload[idx++] = data >> 24;
    payload[idx++] = data >> 16;
    payload[idx++] = data >> 8;
    payload[idx++] = data;
    data = (uint32_t)(GPS.longitudeDegrees * 1E7);
    payload[idx++] = data >> 24;    
    payload[idx++] = data >> 16;
    payload[idx++] = data >> 8;
    payload[idx++] = data;
    data = (int)(GPS.altitude);
    payload[idx++] = data >> 8;
    payload[idx++] = data;    
    data = (int)(GPS.speed);
    payload[idx++] = data >> 8;
    payload[idx++] = data;    
  } else {
    payload[idx++] = 0;
  }
  digitalWrite(LED, HIGH);
  LongFi.send(payload, idx);
  Serial.println("Sending packet");    
  digitalWrite(LED, LOW);
}
void loop() {
  GPS.read();
  if (GPS.newNMEAreceived()) {
    GPS.parse(GPS.lastNMEA());
  }
  if (timer > millis()) timer = millis();
  if (millis() - timer > 5000) {
    timer = millis();
    transmitCallback();
  }
}

Glad to see this is about to be released. It simplifies the most common use case for longfi enabled devices. How long until Cargo will be available?

I’ve added the code to my project, but receiving an error. Any tips on how to fix this compile error?

TransmitPacket_Success1:73:7: error: ‘GPS’ was not declared in this scope
73 | if (GPS.fix) {
| ^~~

@zootsewt Do you mind sharing what hardware you’re using? You’ll need to add the GPS defines based on whichever module you’re using.

For example - for the Discovery BL072Z board and Adafruit GPS shield:

HardwareSerial Serial1(PA_10, PA_9);
#define GPSSerial Serial1
Adafruit_GPS GPS(&GPSSerial);

@jeff.helium I’m using a ST B-L072Z-LRWAN1 Discovery board with an ST X-NUCLEO-GNSS1A1 expansion board. I also have an ST X-NUCLEO-IKS01A2 motion and environment sensor board in the mix.