Packed Binary Data Format

From device to AWS IoT, data is sent in binary format over MQTT.

So far there are 3 sub-packet types: MEMS, GPS, OBD.

The table below show the contents of each byte

Packet Structure

All packet types have the following structure.

  • Packet Size: 2 Byte int representing size of packet between byte 2 and n
  • Timestamp: 8 Bytes. First 4 bytes represent unix epoch. Last 4 bytes represent fraction of second.
  • Data: variable bytes. All data will be of the same sub-packet type. Multiple sub-packets can be contained in data one after the other. Sub-packet type is known by the MQTT Topic packet is sent over.
  • CRC: A 4 byte CRC number used to check packet integrity.
0 1 2 3 4 5 6 7 8 9 ... ... ... ...n n+1 n+2 n+3 n+4
Packet Size Time Stamp Data CRC

MEMS Packets

In the future, MEMS may need expanding. More info can be detected by MEMS than is currently sent.

  • TimeStamp: See Above
  • Acceleration 12 Bytes. 4 float values.
  • Pitch: Float
  • Roll: Float
  • Yaw: Float
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Time Stamp Acceleration X Acceleration Y Acceleration Z Pitch Yaw Roll

OBD Packets

The value section may need to be bigger. PIDs have variable response sizes.

  • TimeStamp: See Above
  • Mode Byte. 0 - 9
  • PID Byte. 0 - 255
  • Value: 4 Bytes. Varies by PID
0 1 2 3 4 5 6 7 8 9 10 11 12 13
Time Stamp Mode PID Value

GPS Packets

  • TimeStamp: See Above
  • Latitude 4 Bytes.
  • Longditude 4 Bytes.
  • Alt 2 Bytes.
  • Speed 1 Bytes.
  • Satellites 1 Bytes.
  • Heading 2 Bytes.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Time Stamp Latitude Longditude Alt Speed Sat Heading