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 TypeMethodDescriptionint
Returns the maximum capacity in bytes this card can store.protected byte[]
Reads all available blocks from the card and returns a byte array.protected void
writeBytes
(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:
getCapacity
in 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:
readBytes
in 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:
writeBytes
in classRfidCard
- Parameters:
data
- Data to write to the card- Throws:
RfidException
- Writing data to card failedIllegalArgumentException
- Given data exceeds card capacity
-