deserializePayload method

  1. @override
int deserializePayload(
  1. LblConfigBuilder 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.LblConfigBuilder builder, ByteData byteData,
    Endian endianness, int offset) {
  var byteOffset = offset;

  // field op
  builder.op = imc.LblConfigEnumOp(byteData.getUint8(byteOffset));
  byteOffset += 1;
  // field beacons
  var beaconsMMsgsNumber = byteData.getUint16(byteOffset, endianness);
  byteOffset += 2;
  builder.beacons = [];
  for (var i = 0; i < beaconsMMsgsNumber; i++) {
    var beaconsSId = byteData.getUint16(byteOffset, endianness);
    byteOffset += 2;
    if (beaconsSId != imc.ImcId.nullId) {
      var pMsgBuilder = imc.messagesBuilders[
              imc.idsToMessages[beaconsSId] ?? imc.ImcId.nullId.toString()]
          ?.call()
          .newInstance(builder);
      var pMsgSerializer = imc.messagesSerializers[
              imc.idsToMessages[beaconsSId] ?? imc.ImcId.nullId.toString()]
          ?.call();
      if (pMsgBuilder != null && pMsgSerializer != null) {
        var mPSize = pMsgSerializer.deserializePayload(
            pMsgBuilder, byteData, endianness, byteOffset);
        byteOffset += mPSize;
        builder.beacons.add(pMsgBuilder.build() as imc.LblBeacon);
      }
    }
  }

  return byteOffset - offset;
}