java.lang.Object
com.pi4j.crowpi.components.internal.rfid.RfidCard
com.pi4j.crowpi.components.internal.rfid.Mifare1K

public final class Mifare1K extends RfidCard
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.
  • 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 class RfidCard
      Returns:
      Maximum capacity in bytes
    • readBytes

      protected byte[] readBytes() throws RfidException
      Reads all available blocks from the card and returns a byte array. This method targets the same blocks as RfidCard.writeBytes(byte[]) does.
      Specified by:
      readBytes in class RfidCard
      Returns:
      Byte array of available data on card
      Throws:
      RfidException - Reading data from card failed
    • writeBytes

      protected void writeBytes(byte[] data) throws RfidException, IllegalArgumentException
      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 class RfidCard
      Parameters:
      data - Data to write to the card
      Throws:
      RfidException - Writing data to card failed
      IllegalArgumentException - Given data exceeds card capacity