Package com.metratec.lib.rfidreader.mf
Class MFReader
- java.lang.Object
-
- com.metratec.lib.rfidreader.ConnectableDevice
-
- com.metratec.lib.rfidreader.StandardReader
-
- com.metratec.lib.rfidreader.mf.MFReader
-
public class MFReader extends StandardReader
Class for the metraTec mifare reader- Author:
- Matthias Neumann (neumann@metratec.com)
-
-
Field Summary
Fields Modifier and Type Field Description static int
CARD_TYPE_MIFARE_1K
Card type mifare 1kstatic int
CARD_TYPE_MIFARE_4K
Card type mifare 4kstatic int
CARD_TYPE_MIFARE_DESFIRE
Card type mifare desfirestatic int
CARD_TYPE_MIFARE_ULTRALIGHT
Card type mifare ultralight-
Fields inherited from class com.metratec.lib.rfidreader.StandardReader
RESPONSE_ERROR_CER, RESPONSE_ERROR_LENGHT, RESPONSE_ERROR_NSS, RESPONSE_ERROR_TCE, RESPONSE_ERROR_TOE, RESPONSE_ERROR_TOR, RESPONSE_OK
-
Fields inherited from class com.metratec.lib.rfidreader.ConnectableDevice
STATE_CONFIGURING, STATE_CONNECTING, STATE_RUNNING, STATE_STOPPED, STATE_WAITING_FOR_RECONNECT
-
-
Constructor Summary
Constructors Constructor Description MFReader(String identifier, ICommConnection connection, String... minReaderRevision)
Creates a new MifareReader with the specified connectionMFReader(String identifier, String usbDeviceSerialNumber)
Deprecated.MFReader(String identifier, String ipAddress, int port)
Deprecated.MFReader(String identifier, String portName, int baudrate, int dataBit, int stopBit, int parity, int flowControl)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
authenticatedSector(int sector)
authenticate a Mifare sectorvoid
authenticatedSector(int sector, String key, String type)
authenticate a MiFare sectorvoid
close()
Deprecated.void
disableRF()
Disbale the RF Fieldvoid
enableRF()
Enable the RF FieldList<String>
getInventory()
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are in the read range of the reader.List<String>
getInventoryOnlyNewTags()
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are new in the read range of the reader.String
getTagData(int blockNumber)
Reads data from a tagString
getTagData(int firstBlock, int numberOfFollowingBlocks)
Reads data from the given tagString
getTagData(int firstBlock, int numberOfFollowingBlocks, String TagID)
Reads data from the given tag and authenticated automaticallyString
getTagData(int blockNumber, String TagID)
Reads data from the given tag and authenticated automaticallyint
selectCard(String cardUID)
select a specific transpondervoid
setKeyToUse(String type, String key)
set the key to use for authenticationvoid
setTagData(int blocknumber, String data, String TagID)
Write Data to the Tag-
Methods inherited from class com.metratec.lib.rfidreader.StandardReader
disconnect, getCRCState, getEndOfFrameState, getFirmwareRevision, getHardwareRevision, getInput, getInputDebounceTime, getReaderType, getRevision, getSerialNumber, ping, reset, setAntennaPort, setEventListener, setInputDebounceTime, setOutput, standby, switchAntennas, wakeUp
-
Methods inherited from class com.metratec.lib.rfidreader.ConnectableDevice
connect, connect, getIdentifier, getReceiveTimeout, isConnected, setIdentifier, setMaxReconnectWaitTime, setMinReconnectWaitTime, setReceiveTimeout, start, start, stop
-
-
-
-
Field Detail
-
CARD_TYPE_MIFARE_1K
public static final int CARD_TYPE_MIFARE_1K
Card type mifare 1k- See Also:
- Constant Field Values
-
CARD_TYPE_MIFARE_4K
public static final int CARD_TYPE_MIFARE_4K
Card type mifare 4k- See Also:
- Constant Field Values
-
CARD_TYPE_MIFARE_DESFIRE
public static final int CARD_TYPE_MIFARE_DESFIRE
Card type mifare desfire- See Also:
- Constant Field Values
-
CARD_TYPE_MIFARE_ULTRALIGHT
public static final int CARD_TYPE_MIFARE_ULTRALIGHT
Card type mifare ultralight- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MFReader
public MFReader(String identifier, ICommConnection connection, String... minReaderRevision)
Creates a new MifareReader with the specified connection- Parameters:
identifier
- reader identifierconnection
- connectionminReaderRevision
- min reader revision
-
MFReader
@Deprecated public MFReader(String identifier, String usbDeviceSerialNumber)
Deprecated.Use the reader classes (QuasarMF
,DeskID_MF
,Dwarf14
,QR14
) for instantiate the reader
Creates a new MifareReader class for communicate with the specified metraTec usb mifare reader- Parameters:
identifier
- reader identifierusbDeviceSerialNumber
- serial number of the usb mifare reader
-
MFReader
@Deprecated public MFReader(String identifier, String ipAddress, int port)
Deprecated.Use the reader classes (QuasarMF
,DeskID_MF
,Dwarf14
,QR14
) for instantiate the reader
Creates a new UHFReader class for communicate with the specified metraTec ethernet mifare reader- Parameters:
identifier
- reader identifieripAddress
- ip address of the ethernet mifare readerport
- port of the ethernet uhf reader
-
MFReader
@Deprecated public MFReader(String identifier, String portName, int baudrate, int dataBit, int stopBit, int parity, int flowControl)
Deprecated.Use the reader classes (QuasarMF
,DeskID_MF
,Dwarf14
,QR14
) for instantiate the reader
Creates a new UHFReader class for communicate with the specified metraTec ethernet mifare reader- Parameters:
identifier
- reader identifierportName
- port on which the rs232 mifare reader is connectedbaudrate
- baudrate of the rs232 mifare readerdataBit
- rs232 databitsstopBit
- rs232 stopbitparity
- rs232 parityflowControl
- rs232 flowcontrol
-
-
Method Detail
-
close
@Deprecated public void close() throws CommConnectionException
Deprecated.UseStandardReader.disconnect()
for close the connection- Throws:
CommConnectionException
- possible ICommConnection Error codes:- UNHANDLED_ERROR
-
enableRF
public void enableRF() throws CommConnectionException, RFIDReaderException
Enable the RF Field- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an reader exception occurs
-
disableRF
public void disableRF() throws CommConnectionException, RFIDReaderException
Disbale the RF Field- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an reader exception occurs
-
getInventory
public List<String> getInventory() throws RFIDReaderException, CommConnectionException
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are in the read range of the reader.- Specified by:
getInventory
in classStandardReader
- Returns:
- List with the tag UIDs
- Throws:
RFIDReaderException
- possible RFIDErrorCodes:- CCE, CRC communication error
- NER, not expected response
CommConnectionException
- possible ICommConnection Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getInventoryOnlyNewTags
public List<String> getInventoryOnlyNewTags() throws RFIDReaderException, CommConnectionException
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are new in the read range of the reader.- Returns:
- List with the tag UIDs
- Throws:
RFIDReaderException
- possible RFIDErrorCodes:- CCE, CRC communication error
- NER, not expected response
CommConnectionException
- possible ICommConnection Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public String getTagData(int blockNumber) throws RFIDReaderException, CommConnectionException
Reads data from a tag- Parameters:
blockNumber
- blocknumber- Returns:
- tag data
- Throws:
RFIDReaderException
- possible Error codes:- AUTHENTICATION_ERROR
- CARD_NOT_AUTHENTICATED
- BLOCK_NOT_AUTHENTICATED
- NO_KEY_SELECTED
- TAG_NOT_RRESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public String getTagData(int firstBlock, int numberOfFollowingBlocks) throws RFIDReaderException, CommConnectionException
Reads data from the given tag- Parameters:
firstBlock
- first blocknumberOfFollowingBlocks
- number of following blocks- Returns:
- tag data
- Throws:
RFIDReaderException
- possible Error codes:- AUTHENTICATION_ERROR
- CARD_NOT_AUTHENTICATED
- BLOCK_NOT_AUTHENTICATED
- NO_KEY_SELECTED
- TAG_NOT_RRESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public String getTagData(int blockNumber, String TagID) throws RFIDReaderException, CommConnectionException
Reads data from the given tag and authenticated automatically- Parameters:
blockNumber
- blocknumberTagID
- tag id- Returns:
- tag data
- Throws:
RFIDReaderException
- possible Error codes:- AUTHENTICATION_ERROR
- CARD_NOT_AUTHENTICATED
- BLOCK_NOT_AUTHENTICATED
- NO_KEY_SELECTED
- TAG_NOT_RRESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public String getTagData(int firstBlock, int numberOfFollowingBlocks, String TagID) throws RFIDReaderException, CommConnectionException
Reads data from the given tag and authenticated automatically- Parameters:
firstBlock
- first blocknumberOfFollowingBlocks
- number of following blocksTagID
- tag id- Returns:
- tag data
- Throws:
RFIDReaderException
- possible Error codes:- AUTHENTICATION_ERROR
- CARD_NOT_AUTHENTICATED
- BLOCK_NOT_AUTHENTICATED
- NO_KEY_SELECTED
- TAG_NOT_RRESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
setTagData
public void setTagData(int blocknumber, String data, String TagID) throws RFIDReaderException, CommConnectionException
Write Data to the Tag- Parameters:
blocknumber
- block numberdata
- dataTagID
- tag id- Throws:
RFIDReaderException
- possible Error codes:- NO_KEY_SELECTED
- NO_CARD_SELECTED
- BLOCK_NOT_AUTHENTICATED
- CARD_NOT_AUTHENTICATED
- TAG_NOT_RRESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
selectCard
public int selectCard(String cardUID) throws CommConnectionException, RFIDReaderException
select a specific transponder- Parameters:
cardUID
- card id- Returns:
- Card type (SAK Code, SAK length is 1 byte for short UIDs (4Bytes) and 2 bytes for double length UID (7 bytes))
- Throws:
RFIDReaderException
- possible RFIDErrorCodes:- TNR, tag not responding
- EHX, hex expected
- CCE, CRC communication error
- NER, not expected response
CommConnectionException
- possible ICommConnection Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
setKeyToUse
public void setKeyToUse(String type, String key) throws CommConnectionException, RFIDReaderException
set the key to use for authentication- Parameters:
key
- key to usetype
- key type (A or B)- Throws:
RFIDReaderException
- possible Error codes:- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
authenticatedSector
public void authenticatedSector(int sector, String key, String type) throws CommConnectionException, RFIDReaderException
authenticate a MiFare sector- Parameters:
sector
- MiFare sectorkey
- key to usetype
- key type (A or B)- Throws:
RFIDReaderException
- possible RFIDErrorCodes:- BIH, Block is too high
- ATE, Authentication Error
- NKS, No Key Selected
- CNS, Card is not selected
- TNR, Tag not responding
- CCE, CRC communication error
- NER, no expected response
CommConnectionException
- possible ICommConnection Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
authenticatedSector
public void authenticatedSector(int sector) throws CommConnectionException, RFIDReaderException
authenticate a Mifare sector- Parameters:
sector
- Mifare sector- Throws:
RFIDReaderException
- possible RFIDErrorCodes:- BIH, Block is too high
- ATE, Authentication Error
- NKS, No Key Selected
- CNS, Card is not selected
- TNR, Tag Not Responding
- CCE, CRC communication error
- NER, no expected response
CommConnectionException
- possible ICommConnection Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
-