Class BrickletNFCRFID


  • public class BrickletNFCRFID
    extends Device
    Reads and writes NFC and RFID tags
    • Constructor Detail

      • BrickletNFCRFID

        public BrickletNFCRFID​(java.lang.String uid,
                               IPConnection ipcon)
        Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
    • Method Detail

      • requestTagID

        public void requestTagID​(short tagType)
                          throws TinkerforgeException
        To read or write a tag that is in proximity of the NFC/RFID Bricklet you first have to call this function with the expected tag type as parameter. It is no problem if you don't know the tag type. You can cycle through the available tag types until the tag gives an answer to the request. Currently the following tag types are supported: * Mifare Classic * NFC Forum Type 1 * NFC Forum Type 2 After you call requestTagID(short) the NFC/RFID Bricklet will try to read the tag ID from the tag. After this process is done the state will change. You can either register the BrickletNFCRFID.StateChangedListener listener or you can poll getState() to find out about the state change. If the state changes to *RequestTagIDError* it means that either there was no tag present or that the tag is of an incompatible type. If the state changes to *RequestTagIDReady* it means that a compatible tag was found and that the tag ID could be read out. You can now get the tag ID by calling getTagID(). If two tags are in the proximity of the NFC/RFID Bricklet, this function will cycle through the tags. To select a specific tag you have to call requestTagID(short) until the correct tag id is found. In case of any *Error* state the selection is lost and you have to start again by calling requestTagID(short).
        Throws:
        TinkerforgeException
      • getState

        public BrickletNFCRFID.State getState()
                                       throws TinkerforgeException
        Returns the current state of the NFC/RFID Bricklet. On startup the Bricklet will be in the *Initialization* state. The initialization will only take about 20ms. After that it changes to *Idle*. The functions of this Bricklet can be called in the *Idle* state and all of the *Ready* and *Error* states. Example: If you call requestPage(int), the state will change to *RequestPage* until the reading of the page is finished. Then it will change to either *RequestPageReady* if it worked or to *RequestPageError* if it didn't. If the request worked you can get the page by calling getPage(). The same approach is used analogously for the other API functions.
        Throws:
        TinkerforgeException
      • getIdentity

        public Device.Identity getIdentity()
                                    throws TinkerforgeException
        Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
        Specified by:
        getIdentity in class Device
        Throws:
        TinkerforgeException