public final class UniversalReader.MifareReader
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
int |
anticollision()
Returns the serial number of one of requested Mifare cards.
|
void |
authenticate(int sn,
int block,
int type,
byte[] key)
Authenticates Mifare card for operation.
|
void |
authenticate(int sn,
int block,
int type,
int selector)
Authenticates Mifare card for operation with key stored into Mifare
reader EEPROM memory.
|
void |
config()
Configures Mifare card reader.
|
void |
decrement(int src,
int dst,
int value)
Performs value decrement operation in Mifare card.
|
int |
getSerialNumber()
Gets the serial number of Mifare reader.
|
void |
halt()
Puts the selected Mifare card into 'idle' state.
|
void |
increment(int src,
int dst,
int value)
Performs value increment operation in Mifare card.
|
void |
loadKey(int selector,
byte[] key)
Stores key into Mifare reader EEPROM.
|
byte[] |
read(int block)
Reads block from Mifare card.
|
byte[] |
readEeprom(int address,
int length)
Reads data from Mifare reader EEPROM memory.
|
int |
request(boolean all)
Requests for Mifare cards.
|
void |
restore(int src,
int dst,
int value)
Performs value restore operation in Mifare card.
|
int |
select(int sn)
Selects a Mifare card.
|
void |
setPower(boolean on)
Powers on/off Mifare card reader.
|
void |
write(int block,
byte[] data)
Writes block to Mifare card.
|
void |
write(int block,
int data)
Writes data to Mifare card.
|
void |
writeEeprom(int address,
byte[] data)
Writes data to Mifare reader EEPROM memory.
|
public void setPower(boolean on) throws java.io.IOException, UniversalReaderException
on
- the flag indicates where to power on/off the reader.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void config() throws java.io.IOException, UniversalReaderException
This command must be execute right after power on the reader.
java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public int request(boolean all) throws java.io.IOException, UniversalReaderException
all
- the flag indicates where the request processes over all
cards in range or only over idle state cards.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public int anticollision() throws java.io.IOException, UniversalReaderException
java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public int select(int sn) throws java.io.IOException, UniversalReaderException
sn
- the serial number of Mifare card.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void authenticate(int sn, int block, int type, byte[] key) throws java.io.IOException, UniversalReaderException
If key
is null
, a
NullPointerException
is thrown.
If key.length != 6
, a
IllegalArgumentException
is thrown.
sn
- the serial number of Mifare card.block
- the block number of Mifare card requested for
authentication.type
- the key type of authentication, where 0x60 is type A and
0x61 is type B.key
- the byte array contains 6 bytes authentication key.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public byte[] read(int block) throws java.io.IOException, UniversalReaderException
block
- the block number.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void write(int block, byte[] data) throws java.io.IOException, UniversalReaderException
If data
is null
, a
NullPointerException
is thrown.
If data.length != 16
, a
IllegalArgumentException
is thrown.
block
- the block number.data
- the byte array contains 16 bytes data to write.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void increment(int src, int dst, int value) throws java.io.IOException, UniversalReaderException
src
- the source block number.dst
- the destination block number.value
- the value to increments with.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void decrement(int src, int dst, int value) throws java.io.IOException, UniversalReaderException
src
- the source block number.dst
- the destination block number.value
- the value to decrement with.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void restore(int src, int dst, int value) throws java.io.IOException, UniversalReaderException
src
- the source block number.dst
- the destination block number.value
- the value to restore with.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void halt() throws java.io.IOException, UniversalReaderException
java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public int getSerialNumber() throws java.io.IOException, UniversalReaderException
java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void writeEeprom(int address, byte[] data) throws java.io.IOException, UniversalReaderException
If data
is null
, a
NullPointerException
is thrown.
address
- the address in EEPROM memory.data
- the data.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void write(int block, int data) throws java.io.IOException, UniversalReaderException
block
- the block number.data
- the data.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void loadKey(int selector, byte[] key) throws java.io.IOException, UniversalReaderException
If key
is null
, a
NullPointerException
is thrown.
If key.length != 6
, a
IllegalArgumentException
is thrown.
selector
- the key selector number.key
- the byte array contains 6 bytes authentication key.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public void authenticate(int sn, int block, int type, int selector) throws java.io.IOException, UniversalReaderException
sn
- the serial number of Mifare card.block
- the block number of Mifare card requested for
authentication.type
- the key type of authentication, where 0x60 is type A and
0x61 is type B.selector
- the number of key selector.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.public byte[] readEeprom(int address, int length) throws java.io.IOException, UniversalReaderException
address
- the EEPROM memory address.length
- the length of data requested for reading.java.io.IOException
- if an I/O error occurs.UniversalReaderException
- if an error occurs during execution.