ntag2xxReadBlock method
Read a block of data from the card. Block number should be the block
to read.
Returns List<int>
of length 4 if the block is successfully read.
Implementation
List<int> ntag2xxReadBlock(Uint8 blockNumber) {
final List<int> parameters = [0x01, mifareCmdRead, blockNumber.value];
// The response length of NTAG2xx is same as Mifare's
// Send InDataExchange request to read block of MiFare data.
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}'");
}
// Although the response length of NTAG2xx is same as Mifare's,
// only the first 4 bytes are available
return readBlockResponse.sublist(1, ntag2XxBlockLength);
}