deserializePayload method

  1. @override
int deserializePayload(
  1. TakeoffBuilder builder,
  2. ByteData byteData,
  3. Endian endianness,
  4. int offset,
)
override

Call to deserialize only the payload, no header. The Builder is to allow passing the message to build into. returns a int with a serialized size

Implementation

@override
int deserializePayload(imc.TakeoffBuilder builder, ByteData byteData,
    Endian endianness, int offset) {
  var byteOffset = offset;

  // field lat
  builder.lat = byteData.getFloat64(byteOffset, endianness);
  byteOffset += 8;
  // field lon
  builder.lon = byteData.getFloat64(byteOffset, endianness);
  byteOffset += 8;
  // field z
  builder.z = byteData.getFloat32(byteOffset, endianness);
  byteOffset += 4;
  // field zUnits
  builder.zUnits = imc.ZUnitsEnum(byteData.getUint8(byteOffset));
  byteOffset += 1;
  // field speed
  builder.speed = byteData.getFloat32(byteOffset, endianness);
  byteOffset += 4;
  // field speedUnits
  builder.speedUnits = imc.SpeedUnitsEnum(byteData.getUint8(byteOffset));
  byteOffset += 1;
  // field takeoffPitch
  builder.takeoffPitch = byteData.getFloat32(byteOffset, endianness);
  byteOffset += 4;
  // field custom
  var customSSize = byteData.getUint16(byteOffset, endianness);
  byteOffset += 2;
  var customDData = List.filled(customSSize, 0);
  for (var i = 0; i < customSSize; i++) {
    customDData[i] = byteData.getUint8(byteOffset++);
  }
  var customDecoded = utf8.decode(customDData);
  builder.custom = customDecoded;

  return byteOffset - offset;
}