public interface MifareUltralightCard extends MemoryCard
The original MIFARE Ultralight consists of a 64 byte EEPROM. The first 4 blocks are for the OTP area, manufacturer data, and locking bits. They are readable and some bits are writable. The final 12 blocks are the user read/write area. For more information see the NXP data sheet MF0ICU1.
The MIFARE Ultralight C consists of a 192 byte EEPROM. The first 4 blocks are for OTP, manufacturer data, and locking bits. The next 36 blocks are the user read/write area. The next 4 blocks are additional locking bits, counters and authentication configuration and are readable. The final 4 blocks are for the authentication key and are not readable. For more information see the NXP data sheet MF0ICU2.
PROTOCOL_RFCARD_TYPE_A, PROTOCOL_RFCARD_TYPE_B, PROTOCOL_T_0, PROTOCOL_T_1, PROTOCOL_UNKNOWN, STATUS_ABSENT, STATUS_CONNECTED, STATUS_DISCONNECTED
Modifier and Type | Method and Description |
---|---|
byte[] |
read(int blockIndex)
Read 4 blocks (16 bytes).
|
byte[] |
transmit(byte[] apdu,
int operation)
Transmit command of level 3 and get the response.
|
boolean |
verifyKey(byte[] key)
Authenticates with key.
|
void |
write(int blockIndex,
byte[] data)
Write 1 block (4 bytes).
|
getCardStatus, getID, getIDInfo, getProtocol
byte[] read(int blockIndex) throws DeviceException
The MIFARE Ultralight protocol always reads 4 blocks at a time, to reduce the number of commands required to read an entire tag. If a read spans past the last readable block, then the tag will return pages that have been wrapped back to the first blocks. MIFARE Ultralight tags have readable blocks 0x00 through 0x0F. So a read to block offset 0x0E would return blocks 0x0E, 0x0F, 0x00, 0x01. MIFARE Ultralight C tags have readable blocks 0x00 through 0x2B. So a read to block 0x2A would return blocks 0x2A, 0x2B, 0x00, 0x01.
blockIndex
- the block index.DeviceException
- for the standard reasons that are documented in
DeviceException
.void write(int blockIndex, byte[] data) throws DeviceException
blockIndex
- the block index .data
- the data buffer.DeviceException
- for the standard reasons that are documented in
DeviceException
.boolean verifyKey(byte[] key) throws DeviceException
This is an I/O operation and will block until complete. It must not be called from the main application thread. A blocked call will be canceled with IOException if close() is called from another thread.
key
- 16-byte authentication keytrue
Authenticates success,false
Authenticates fail.DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] transmit(byte[] apdu, int operation) throws DeviceException
apdu
- data buffer to be transmitted.operation
- default is 0, if need disable CRC and parity, please set to 16.DeviceException
- for the standard reasons that are documented in
DeviceException
and also:
ON