writeBlock method

  1. @override
Future<void> writeBlock({
  1. required int blockNumber,
  2. required List<int> data,
})

Writes data to a specified block on an RFID tag.

Sends an APDU command to the RFID reader to write provided data into a specified block number on the RFID tag. This method is essential for storing data on RFID tags.

Parameters

  • blockNumber: The block number where the data will be written.
  • data: A list of integers (bytes) to write to the specified block.

Throws

  • Exceptions if the APDU command fails to transmit, if the data length exceeds the block size, or if the RFID tag responds with an error.

Example

await writeBlock(blockNumber: 4, data: [0x01, 0x02, 0x03, 0x04]);

Note: The size of the data list must not exceed the maximum block size of the RFID tag.

Implementation

@override
Future<void> writeBlock({
  required int blockNumber,
  required List<int> data,
}) async {
  await transmitApdu(
    ApduHeader(
      classNumber: 0xFF,
      instruction: 0xD6,
      p1: 0x00,
      p2: blockNumber,
    ),
    data: data,
  );
}