mifareClassicReadBlock method

List<int> mifareClassicReadBlock(
  1. Uint8 blockNumber
)

Read a block of data from the card. Block number should be the block to read.

Implementation

List<int> mifareClassicReadBlock(Uint8 blockNumber) {
  final List<int> parameters = [0x01, mifareCmdRead, blockNumber.value];

  final List<int> readBlockResponse = callPN532Function(
      pn532CommandInDataExchange,
      parameters: parameters,
      responseLength: mifareBlockLength + 1);

  // Check first response is 0x00 to show success.
  if (readBlockResponse.first != pn532ErrorNone) {
    throw PN532BadResponseException(
        response: readBlockResponse,
        additionalInformation:
            "The first byte should be '$pn532ErrorNone' but it was '${readBlockResponse.first}'");
  }

  return readBlockResponse.sublist(1, mifareBlockLength + 1);
}