Class RFIDSensor

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, SensorConstants, SensorMode, SensorModes, SampleProvider

    public class RFIDSensor
    extends I2CSensor
    Support for the Codatex RFID Sensor. This device requires delays between various commands for them to function correctly, it also enters a sleep mode and requires to be woken up. The methods in this class fall into two categories. Basic commands These pretty much match one to one with the device command set. They do not incorporate any delays, or wake up code. They can be used by user programs but if they are then appropriate delays etc. must be used. They are provided to allow more sophisticated user programs access to the low level device. High level commands These provide higher level access to the device and are often implemented via several i2c commands. They do include delays and wake up logic.
    Author:
    andy
    • Constructor Detail

      • RFIDSensor

        public RFIDSensor​(I2CPort port)
        Create a class to provide access to the device. Perform device initialization.
        Parameters:
        port - The sensor port to use for this device.
      • RFIDSensor

        public RFIDSensor​(Port port)
        Create a class to provide access to the device. Perform device initialization.
        Parameters:
        port - The sensor port to use for this device.
    • Method Detail

      • wakeUp

        public void wakeUp()
        The sensor will go into a power save mode after a short time. This means that we will need to wake it up before issuing commands. Includes the required Delay.msDelay.
      • fetchString

        protected java.lang.String fetchString​(byte register,
                                               int len)
        We over-ride the default implementation to ensure that the device is awake before we talk to it.
        Overrides:
        fetchString in class I2CSensor
        Parameters:
        register - The register to read the string from.
        len -
        Returns:
        The requested string.
      • startFirmware

        public void startFirmware()
        Start the firmware on the RFID device. NOTES: It seems that you need to issue this command (or some other firmware command), prior to attempting to read the version number etc. Does not wake up the device or contain any delays.
      • startBootLoader

        public void startBootLoader()
        Enter boot loader mode. Does not wake up the device or include any delays.
      • getSerialNo

        public byte[] getSerialNo()
        Obtain the serial number of the RFID Sensor. NOTES: To obtain the serial number the device must be in boot loader mode. This function will switch into this mode and then return to normal mode on completion.
        Returns:
        the 12 byte serial number if ok or null if there is an error
      • getStatus

        public int getStatus()
        Read the status from the device. Does not wake up the device or include any delays.
        Returns:
        1 data available 0 no data < 0 error
      • startSingleRead

        public void startSingleRead()
        Start a single read from the device. Does not wake up the device or include any delays.
      • startContinuousRead

        public void startContinuousRead()
        Start continually reading from the device. Does not wake up the device or include any delays.
      • stop

        public void stop()
        Send a stop command to the device. Places the device into sleep mode.
      • readTransponder

        public byte[] readTransponder​(boolean continuous)
        Read a transponder id. Reads the transponder using either continuous or single shot mode. If using single shot mode the tag must me available now. If using continuous mode then after the first call, the tag can be presented at any time and a subsequent read will return the results.
        Parameters:
        continuous - Should we use continuous mode
        Returns:
        null if error or no data available, otherwise an array of five id bytes
      • readTransponderAsLong

        public long readTransponderAsLong​(boolean continuous)