java.lang.Object
com.pi4j.crowpi.components.internal.rfid.RfidCard
com.pi4j.crowpi.components.internal.rfid.Mifare1K
Implementation of MIFARE Classic 1K cards with 16 sectors with 4 blocks (16 bytes) each.
First sector with manufacturer block and sector trailers are explicitly hidden from the user.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the maximum capacity in bytes this card can store.protected byte[]Reads all available blocks from the card and returns a byte array.protected voidwriteBytes(byte[] data) Writes the given data to the card, using as many blocks as needed.Methods inherited from class com.pi4j.crowpi.components.internal.rfid.RfidCard
getSerial, getUid, readObject, readObject, writeObject
-
Method Details
-
getCapacity
public int getCapacity()Returns the maximum capacity in bytes this card can store. This method should already subtract all unavailable blocks / sectors, e.g. trailer blocks.- Specified by:
getCapacityin classRfidCard- Returns:
- Maximum capacity in bytes
-
readBytes
Reads all available blocks from the card and returns a byte array. This method targets the same blocks asRfidCard.writeBytes(byte[])does.- Specified by:
readBytesin classRfidCard- Returns:
- Byte array of available data on card
- Throws:
RfidException- Reading data from card failed
-
writeBytes
Writes the given data to the card, using as many blocks as needed. This method will only write to safe blocks and does not overwrite any internal blocks.- Specified by:
writeBytesin classRfidCard- Parameters:
data- Data to write to the card- Throws:
RfidException- Writing data to card failedIllegalArgumentException- Given data exceeds card capacity
-