Skip to content

spoZebra/zebra-rfid-sled-sdk-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zebra RFID Sled SDK sample

Sample app that shows how to use properly our Zebra SDK to control both RFID antenna and scanner of Zebra RFID Sleds. If your RFID sled does not have the embedded scanner (available on premium versions only) and you're using a Zebra device connected thru eConnex, you could trigger the scan from the device directly from the gun button - See this link as a reference: https://techdocs.zebra.com/dcs/rfid/android/2-0-2-94/tutorials/triggerremapping/

Right now, DataWedge does not support embedded scan engine of RFD90, therefore you should use the scanner module of Zebra RFID SDK to make it run. We expect to include this funcionnality in DataWedge by the end of 2023

Hardware Requirements

  • Zebra RFD90
  • A device running A8 or above

Demo

Untitled.mp4

Code snippets

  • Use embedded scan engine of RFID Sled. This can be achieve by importing the library com.zebra.scannercontrol available within the RFID SDK.

    fun connect(context : Context) : Boolean {
    if(sdkHandler == null)
    sdkHandler = SDKHandler(context)
    sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_BT_NORMAL)
    sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_BT_LE)
    sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_USB_CDC)
    sdkHandler!!.dcssdkSetDelegate(this);
    var notifications_mask = 0
    notifications_mask = notifications_mask or (DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SCANNER_APPEARANCE.value or
    DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SCANNER_DISAPPEARANCE.value)
    notifications_mask = notifications_mask or (DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SESSION_ESTABLISHMENT.value or
    DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_SESSION_TERMINATION.value)
    notifications_mask = notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
    // subscribe to events set in notification mask
    sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
    sdkHandler!!.dcssdkEnableAvailableScannersDetection(true)
    val scannerInfoList : ArrayList<DCSScannerInfo> = ArrayList()
    sdkHandler!!.dcssdkGetAvailableScannersList(scannerInfoList)
    try {
    val scanner = scannerInfoList[0]
    if(scanner.isActive)
    return true
    // Connect
    var result = sdkHandler!!.dcssdkEstablishCommunicationSession(scanner.scannerID)
    return result == DCSSDKDefs.DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS
    } catch (e: Exception) {
    return false
    }
    }

  • Use Zebra device scan engine. This can be achieved by modifing trigger settings with our RFID SDK and creating a DataWedge profile to receive barcodes via intent. RFID SDK setup:

    if(scanConnectionMode == ScanConnectionEnum.TerminalScan)
    reader.Config.setKeylayoutType(ENUM_KEYLAYOUT_TYPE.UPPER_TRIGGER_FOR_SCAN)
    DataWedge profile setup:
    fun configure(){
    val packageName = context.packageName
    // Send DataWedge intent with extra to create profile
    // Use CREATE_PROFILE: http://techdocs.zebra.com/datawedge/latest/guide/api/createprofile/
    sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE, EXTRA_CREATE_PROFILE, EXTRA_PROFILENAME)
    // Configure created profile to apply to this app
    val profileConfig = Bundle()
    // Configure barcode input plugin
    profileConfig.putString("PROFILE_NAME", EXTRA_PROFILENAME)
    profileConfig.putString("PROFILE_ENABLED", "true")
    profileConfig.putString("CONFIG_MODE", "UPDATE") // Update specified settings in profile
    // PLUGIN_CONFIG bundle properties
    val rfidConfig = Bundle()
    rfidConfig.putString("PLUGIN_NAME", "RFID")
    rfidConfig.putString("RESET_CONFIG", "true")
    // PARAM_LIST bundle properties
    val rfidProps = Bundle()
    rfidProps.putString("rfid_input_enabled", "false")
    rfidConfig.putBundle("PARAM_LIST", rfidProps)
    profileConfig.putBundle("PLUGIN_CONFIG", rfidConfig)
    // Apply configs
    // Use SET_CONFIG: http://techdocs.zebra.com/datawedge/latest/guide/api/setconfig/
    sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig)
    // Configure intent output for captured data to be sent to this app
    val intentConfig = Bundle()
    intentConfig.putString("PLUGIN_NAME", "INTENT")
    intentConfig.putString("RESET_CONFIG", "true")
    val intentProps = Bundle()
    intentProps.putString("intent_output_enabled", "true")
    intentProps.putString("intent_action", "$packageName.ACTION")
    intentProps.putString("intent_delivery", "2")
    intentConfig.putBundle("PARAM_LIST", intentProps)
    profileConfig.putBundle("PLUGIN_CONFIG", intentConfig)
    sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig)
    val appConfig = Bundle()
    appConfig.putString("PACKAGE_NAME", packageName) // Associate the profile with this app
    appConfig.putStringArray("ACTIVITY_LIST", arrayOf("*"))
    profileConfig.putParcelableArray("APP_LIST", arrayOf(appConfig))
    sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig)
    }

  • Configure RFID. Standard configuration to read RFID tags. Configuration:

    fun connect(context: Context, scanConnectionMode : ScanConnectionEnum): Boolean {
    // Init
    readers = Readers(context, ENUM_TRANSPORT.ALL)
    try {
    if (readers != null) {
    availableRFIDReaderList = readers.GetAvailableRFIDReaderList()
    if (availableRFIDReaderList != null && availableRFIDReaderList!!.size != 0) {
    // get first reader from list
    readerDevice = availableRFIDReaderList!![0]
    reader = readerDevice!!.rfidReader
    if (!reader!!.isConnected) {
    Log.d(TAG, "RFID Reader Connecting...")
    reader!!.connect()
    configureReader(scanConnectionMode)
    Log.d(TAG, "RFID Reader Connected!")
    return true
    }
    }
    }
    } catch (e: InvalidUsageException) {
    e.printStackTrace()
    } catch (e: OperationFailureException) {
    e.printStackTrace()
    } catch (e: OperationFailureException) {
    e.printStackTrace()
    } catch (e: InvalidUsageException) {
    e.printStackTrace()
    }
    Log.d(TAG, "RFID Reader connection error!")
    return false
    }
    private fun configureReader(scanConnectionMode : ScanConnectionEnum) {
    if (reader.isConnected) {
    val triggerInfo = TriggerInfo()
    triggerInfo.StartTrigger.triggerType = START_TRIGGER_TYPE.START_TRIGGER_TYPE_IMMEDIATE
    triggerInfo.StopTrigger.triggerType = STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_IMMEDIATE
    try {
    // receive events from reader
    reader.Events.addEventsListener(this)
    // HH event
    reader.Events.setHandheldEvent(true)
    // tag event with tag data
    reader.Events.setTagReadEvent(true)
    // application will collect tag using getReadTags API
    reader.Events.setAttachTagDataWithReadEvent(false)
    // set start and stop triggers
    reader.Config.startTrigger = triggerInfo.StartTrigger
    reader.Config.stopTrigger = triggerInfo.StopTrigger
    // Terminal scan, use trigger for scanning!
    if(scanConnectionMode == ScanConnectionEnum.TerminalScan)
    reader.Config.setKeylayoutType(ENUM_KEYLAYOUT_TYPE.UPPER_TRIGGER_FOR_SCAN)
    else
    reader.Config.setKeylayoutType(ENUM_KEYLAYOUT_TYPE.UPPER_TRIGGER_FOR_SLED_SCAN)
    } catch (e: InvalidUsageException) {
    e.printStackTrace()
    } catch (e: OperationFailureException) {
    e.printStackTrace()
    }
    }
    }
    Read tags:
    override fun eventReadNotify(e: RfidReadEvents) {
    // Recommended to use new method getReadTagsEx for better performance in case of large tag population
    val myTags: Array<TagData> = reader.Actions.getReadTags(100)
    if (myTags != null) {
    for (tag in myTags) {
    listener.newTagRead(tag.tagID)
    }
    }
    }

Zebra RFID SDK Full documentation

https://techdocs.zebra.com/dcs/rfid/

About

Sample app that shows how to use properly Zebra SDK to control both RFID antenna and embedded scanner of Zebra RFID Sleds

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages