parser property

  1. @override
BleResponseParser<FirmwareUpdateSetupReply> get parser
override

Implementation

@override
BleResponseParser<FirmwareUpdateSetupReply> get parser =>
    EnvelopeBleResponseParser<FirmwareUpdateSetupReply>(
      (responseEnvelope) {
        final response = responseEnvelope.responseArgs ?? const <dynamic>[];
        final errors = _toIntList(responseEnvelope.errors);
        final thirdArg = response.elementAtOrNull(2);
        final fourthArg = response.elementAtOrNull(3);
        final hasFourthArg = fourthArg != null;

        final parsedDestination =
            hasFourthArg ? _toStringValue(thirdArg) : null;
        final payloadCrc32 =
            hasFourthArg ? _toInt(fourthArg) : _toInt(thirdArg);

        return FirmwareUpdateSetupReply(
          txType: _toInt(response.elementAtOrNull(0)) ?? txType.value,
          totalSizeBytes:
              _toInt(response.elementAtOrNull(1)) ?? totalSizeBytes,
          destination:
              parsedDestination?.isEmpty == true ? null : parsedDestination,
          payloadCrc32: payloadCrc32,
          errorCodes: errors,
        );
      },
    );