mifareClassicWriteBlock method
Write a block of data to the card. Block number should be the block to write and data should be a byte array of length 16 with the data to write.
Implementation
void mifareClassicWriteBlock(Uint8 blockNumber, List<int> data) {
List<int> parameters = List.generate(mifareBlockLength + 3, (index) => 0);
parameters[0] = 0x01; // Max card numbers
parameters[1] = mifareCmdWrite;
parameters[2] = blockNumber.value;
for (int i = 0; i < mifareBlockLength; i++) {
parameters[3 + i] = data[i];
}
final List<int> responseCode = callPN532Function(pn532CommandInDataExchange,
parameters: parameters, responseLength: 1);
if (responseCode.first != pn532ErrorNone) {
throw PN532BadResponseException(
response: responseCode,
additionalInformation:
"The first byte should be '$pn532ErrorNone' but it was '${responseCode.first}'");
}
}