Package com.metratec.lib.rfidreader.mf
Class MFReader
- java.lang.Object
-
- com.metratec.lib.rfidreader.MetratecReader<T>
-
- com.metratec.lib.rfidreader.MetratecReaderGen1<MfTag>
-
- com.metratec.lib.rfidreader.mf.MFReader
-
-
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.MetratecReader
STATE_CONFIGURING, STATE_CONNECTING, STATE_RUNNING, STATE_STOPPED, STATE_WAITING_FOR_RECONNECT
-
-
Constructor Summary
Constructors Constructor Description MFReader(java.lang.String identifier, java.lang.String usbDeviceSerialNumber)
Deprecated.MFReader(java.lang.String identifier, java.lang.String ipAddress, int port)
Deprecated.MFReader(java.lang.String identifier, java.lang.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, java.lang.String key, java.lang.String type)
authenticate a MiFare sectorvoid
close()
Deprecated.void
disableRF()
Disbale the RF Fieldvoid
enableRF()
Enable the RF Fieldjava.util.List<MfTag>
getInventory()
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are in the read range of the reader.java.util.List<MfTag>
getInventoryOnlyNewTags()
returns all UIDs from ISO/IEC 14443-1 to 3 compatible transponders, which are new in the read range of the reader.java.lang.String
getTagData(int blockNumber)
Reads data from a tagjava.lang.String
getTagData(int firstBlock, int numberOfFollowingBlocks)
Reads data from the given tagjava.lang.String
getTagData(int firstBlock, int numberOfFollowingBlocks, java.lang.String TagID)
Reads data from the given tag and authenticated automaticallyjava.lang.String
getTagData(int blockNumber, java.lang.String TagID)
Reads data from the given tag and authenticated automaticallyvoid
scanInventory()
Looks for all tags in range of the reader and call events with founded tags.void
scanInventory(boolean onlyNewTags)
Looks for all tags in range of the reader and call events with founded tags.int
selectCard(java.lang.String cardUID)
select a specific transpondervoid
setAntennaPort(int port)
Set the antenna port.void
setKeyToUse(java.lang.String type, java.lang.String key)
set the key to use for authenticationvoid
setMultiplexAntennas(int numberOfAntennas)
In case you want to automatically switch between multiple antennas (e.g.void
setPower(int power)
void
setTagData(int blocknumber, java.lang.String data, java.lang.String TagID)
Write Data to the Tagjava.util.List<MfTag>
stopInventory()
Stops the current continues inventory-
Methods inherited from class com.metratec.lib.rfidreader.MetratecReaderGen1
getCRCState, getEndOfFrameState, getFirmwareRevision, getHardwareRevision, getInput, getReaderType, getRevision, getSerialNumber, ping, reset, scanInventory, setOutput, standby, startInventory, stop, wakeUp
-
Methods inherited from class com.metratec.lib.rfidreader.MetratecReader
connect, connect, disconnect, getIdentifier, getInputDebounceTime, getReceiveTimeout, isConnected, setIdentifier, setInputDebounceTime, setMaxReconnectWaitTime, setMinReconnectWaitTime, setReaderEventListener, setReceiveTimeout, setTagEventListener, start, start, startAndWait, startAndWait, startInventory
-
-
-
-
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
@Deprecated public MFReader(java.lang.String identifier, java.lang.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(java.lang.String identifier, java.lang.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(java.lang.String identifier, java.lang.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.UseMetratecReaderGen1.stop()
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 java.util.List<MfTag> 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 classMetratecReader<MfTag>
- 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 java.util.List<MfTag> 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 java.lang.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_RESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public java.lang.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_RESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public java.lang.String getTagData(int blockNumber, java.lang.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_RESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
getTagData
public java.lang.String getTagData(int firstBlock, int numberOfFollowingBlocks, java.lang.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_RESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
setTagData
public void setTagData(int blocknumber, java.lang.String data, java.lang.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_RESPONSE
- NOT_EXPECTED_RESPONSE
- WRONG_PARAMETER
CommConnectionException
- possible Error codes:- NOT_INITIALISE
- CONNECTION_LOST
- RECV_TIMEOUT
- UNHANDLED_ERROR
-
selectCard
public int selectCard(java.lang.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(java.lang.String type, java.lang.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, java.lang.String key, java.lang.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
-
scanInventory
public void scanInventory(boolean onlyNewTags) throws CommConnectionException, RFIDReaderException
Looks for all tags in range of the reader and call events with founded tags.- Parameters:
onlyNewTags
- if true only new tags in the field are returned- Throws:
CommConnectionException
- if an communication error occursRFIDReaderException
- if an reader error occurs
-
scanInventory
public void scanInventory() throws CommConnectionException, RFIDReaderException
Description copied from class:MetratecReaderGen1
Looks for all tags in range of the reader and call events with founded tags.- Specified by:
scanInventory
in classMetratecReaderGen1<MfTag>
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
stopInventory
public java.util.List<MfTag> stopInventory() throws CommConnectionException, RFIDReaderException
Description copied from class:MetratecReader
Stops the current continues inventory- Overrides:
stopInventory
in classMetratecReaderGen1<MfTag>
- Returns:
- the current inventory
- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs
-
setAntennaPort
public void setAntennaPort(int port) throws CommConnectionException, RFIDReaderException
Description copied from class:MetratecReader
Set the antenna port.- Specified by:
setAntennaPort
in classMetratecReader<MfTag>
- Parameters:
port
- antenna port for the connected multiplexer [0..15]- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
setPower
public void setPower(int power) throws CommConnectionException, RFIDReaderException
- Specified by:
setPower
in classMetratecReaderGen1<MfTag>
- Parameters:
power
- reader power value- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
setMultiplexAntennas
public void setMultiplexAntennas(int numberOfAntennas) throws CommConnectionException, RFIDReaderException
Description copied from class:MetratecReader
In case you want to automatically switch between multiple antennas (e.g. trying to find all tags in a search area that can only be searched using multiple antennas) you can use this automatic switching mode.
Switching always starts with the lowest antenna port (0). Switching to the next antenna port oc- curs automatically with the start of every tag manipulation command. No pin state is changed until the first tag manipulation command.- Specified by:
setMultiplexAntennas
in classMetratecReader<MfTag>
- Parameters:
numberOfAntennas
- number of antennas [1..16], 0 for disable; Please note that for this parameter the number given is the counted number of participating antennas, not the antenna port numbers, thus stating a number "X" would stand for "X antennas participating".- Throws:
CommConnectionException
- if an communication exception occursRFIDReaderException
- if an protocol exception occurs (e.g. CRC error, value out of range, ..)
-
-