How to connect fixed FX9600 RFID Reader to Normal Android Tablet via USB to read Tags?

// Expert user has replied.
P Prakash Barik 1 month 4 weeks ago
65 7 0

Hi All, 

I would like to highlight the process to connect programmatically any android tablet to RFID reader and read tags. SO basically what i did, Downloaded latest RFID SDK (2.0.3.162) and unzip it and added inside Lib folder of android studio(Ladybug) and build gradle(8.7) Added code in my kotlin project to connect reader, where my RFID Reader is FX9600.

Source Code:



import android.os.Bundle
import android.os.StrictMode
import android.os.StrictMode.ThreadPolicy
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.dcs.sanitrader.R
import com.dcs.sanitrader.databinding.ActivityRfidScanBinding
import com.dcs.sanitrader.databinding.HomepageBinding
import com.zebra.rfid.api3.ENUM_TRANSPORT
import com.zebra.rfid.api3.InvalidUsageException
import com.zebra.rfid.api3.OperationFailureException
import com.zebra.rfid.api3.RFIDReader
import com.zebra.rfid.api3.ReaderDevice
import com.zebra.rfid.api3.Readers
import com.zebra.rfid.api3.RfidEventsListener
import com.zebra.rfid.api3.RfidReadEvents
import com.zebra.rfid.api3.RfidStatusEvents


class RFIDActivity : AppCompatActivity() {

    private var rfidReader: RFIDReader? = null
    private var readersList: Readers? = null
    private var readerDevice: ReaderDevice? = null
    private lateinit var connectionEventHandler: EventHandler
    private lateinit var binding: ActivityRfidScanBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityRfidScanBinding.inflate(layoutInflater)
        setContentView(binding.root)
        enableEdgeToEdge()

        val policy = ThreadPolicy.Builder().permitAll().build()
        StrictMode.setThreadPolicy(policy)

        // Initialize the RFID reader

        binding.startScanButton.setOnClickListener { initializeRFIDReader() }
    }

    private fun initializeRFIDReader() {
        try {
            // Initialize readers
            readersList = Readers(this, ENUM_TRANSPORT.SERVICE_USB)
            //binding.tagDataTextview.text = "RFID Reader is connecting by SERVICE_USB"
            val availableRFIDReaderList = readersList?.GetAvailableRFIDReaderList()
            if (!availableRFIDReaderList.isNullOrEmpty()) {
                readerDevice = availableRFIDReaderList[0]
                rfidReader = readerDevice?.rfidReader
                connectToRFIDReader()
            } else {
                //binding.tagDataTextview.text = "RFID Reader is not connected"
                Toast.makeText(this, "No RFID readers available", Toast.LENGTH_SHORT).show()
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    private fun connectToRFIDReader() {
        try {
            if (rfidReader != null && !rfidReader!!.isConnected) {
                // Connect to the RFID reader
                rfidReader?.connect()
                //binding.tagDataTextview.text = "RFID Reader is connected"
                Toast.makeText(this, "RFID Reader connected", Toast.LENGTH_SHORT).show()
                // Set up the RFID tag event handler
                setupReaderHandlers()
                // Enable tag reading (once connected)
                rfidReader?.Actions?.Inventory?.perform()
            }
        } catch (e: InvalidUsageException) {
            e.printStackTrace()
            //binding.tagDataTextview.text = "RFID Reader error: ${e.printStackTrace()}"
        } catch (e: OperationFailureException) {
            e.printStackTrace()
            //binding.tagDataTextview.text = "RFID Reader error ${e.printStackTrace()}"
        }
    }

    private fun setupReaderHandlers() {
        // Set up event handler for tag data
        rfidReader?.Events?.addEventsListener(connectionEventHandler)

        // Configure event notifications (enable RFID data capture)
        rfidReader?.Events?.apply {
            setInventoryStartEvent(true)
            setInventoryStopEvent(true)
            setTagReadEvent(true)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        // Clean up and disconnect when done
        try {
            rfidReader?.disconnect()
        } catch (e: InvalidUsageException) {
            e.printStackTrace()
        } catch (e: OperationFailureException) {
            e.printStackTrace()
        }
    }

    // Define your event handler to capture tag data
    private inner class EventHandler : RfidEventsListener {
        override fun eventReadNotify(e: RfidReadEvents) {
            // This function is called when a tag is read
            val tags = rfidReader?.Actions?.getReadTags(100)//e.readEventData.tagData//rfidReader?.readerCapabilities?.rfidOptions?.rfidTags
            tags?.forEach { tag ->
                runOnUiThread {
                    Toast.makeText(
                        this@RFIDActivity,
                        "Tag scanned: ${tag.tagID}",
                        Toast.LENGTH_SHORT
                    ).show()
                }
                println("Tag read: ${tag.tagID}")
            }
        }

        override fun eventStatusNotify(e: RfidStatusEvents?) {
            // Handle reader status events here
        }
    }
}

 Error:

 The error am getting is as, Operation Failed: Connection error, no RFID reader available

I don't know where am i wrong? and what should be the better approach to connect the reader from tablet? I am also using same network in reader and tablet. Let me know what should i do?

 

Please Register or Login to post a reply

7 Replies

I Ian Hatton

As per the release notes, the RFID SDK for Android supports Zebra mobile readers only - it is not compatible with fixed readers such as the FX9600. The method recommended to interface to the FX9600 from an Android tablet would be to connect both to a WiFi network and then configure one of the IOT Connector protocol options to send data between the two e.g. MQTT . 

S Sean Kennedy

There is also an alternative:
The up-to-date RFID SDK for Android Studio - does contain the "ZIOTCSampleApp" project - this is designed to allow the Android Device to connect to either the Fixed "FX-Series" readers via LLRP-Based RFID SDK, as well as the Fixed "FXR-Series" FXR90 using the ZIOTC support to the FXR.  You do need to have V2.0.3.148++ of the RFID SDK for Android Studio to try these demo apps out.

NOTE: The ZIOTC uses the IoT connection that the FXR90 is setup with by Default - if you have configured a spearate MQTT endpoint on the FXR90 - you will not be able to connect to it with this demo app. ( I would suggest to backup your settings - and "enterprise" reset the FXR90 settings to defaults before you begin testing.)

A Alex Lavie

the code you are using is trying to connect via USB as if it where a mobile reader.

there is a possibility to connect to fixed readers from android sdk but you need to follow the below (where the method for fixed readers is slightly different):

https://techdocs.zebra.com/dcs/rfid/android/2-0-3-162/guide/connection/

more useful info here to do some other operations:

https://techdocs.zebra.com/dcs/rfid/android/2-0-3-162/tutorials/

 

A Alex Lavie

https://techdocs.zebra.com/dcs/rfid/android/2-0-3-162/samples/fx_hellorfid/

P Prakash Barik

Hi All,

Thanks to all of you for the positive responses. Still i'm unable to connect to my fixed reader FX9600 in normal Tablet.

The process which i'm following to connect the reader such as,

  1. Samsung Galaxy Tab A8 with Android Version 14
  2. Fixed RFID reader is FX96000
  3. RFID SDK Version is 1.0.2.116
  4. Type C with Ethernet Adapter to connect Reader

 

The Reader is able to connect with my Windows 11 machine via USB Type C with the Ethernet port of the Fixed Reader. But the same approach does not work when i connect the fixed Reader with Galaxy Tab A8. Not sure if i am missing any configurations needed to connect the Fixed reader with the Android Tablet.

Appreciate for the prompt response.

P Prakash Barik

Hi All,

Thanks to all of you for the positive responses. Still i'm unable to connect to my fixed reader FX9600 in normal Tablet.

The process which i'm following to connect the reader such as,

  1. Samsung Galaxy Tab A8 with Android Version 14
  2. Fixed RFID reader is FX96000
  3. RFID SDK Version is 1.0.2.116
  4. Type C with Ethernet Adapter to connect Reader

Instead of IP address, could it possible to connect directly via ethernet or USB from tablet to reader?

Is there required any third party software to download in Tablet to connect or anything am missing to connect via code?

Awaiting for positive responses!

S Sean Kennedy

Two Points:
1) The reader needs to be on a network - that is both routeable and the Mobile Device can connect to the Wireless LAN to also get the similar networking to get to / see the reader.  If you are unable to get to the reader with Chrome on the Table via "https://{reader-ip} - then the Sample Apps will not be able to either.  (One uses Web Sockets (Port 80/443) the other uses LLRP on Port 5084)
2) Your the up-to-date RFID SDK - V116 is badly out of date - the newer Android Studio Sample App on V148 and on V162 - both work on the Samsung Galaxy 7 Tablet I use.  

CONTACT
Can’t find what you’re looking for?