使用颤振进行 RFID 扫描 - Zebra 设备

Posted

技术标签:

【中文标题】使用颤振进行 RFID 扫描 - Zebra 设备【英文标题】:Getting RFID scan with flutter - Zebra device 【发布时间】:2021-11-22 16:50:13 【问题描述】:

我正在尝试在 MC3300X 扫描仪上实现此 plugin。我能够获得条形码,但我的意图是将此扫描仪用于 RFID。建议我更改 createDataWedgeProfile 以启用 RFID 插件,并修改 createDataWedgeBroadcastReceiver 以反映接收到的 Intent 的格式。问题是我在 Zebra 网站上找不到任何与 RFID 相关的示例代码,所以我不确定要使用哪种解码模式。我为scanData 尝试了smart_decode_typedecode_data 模式,但结果都返回null。大家觉得这可能吗?我现在该怎么办?

private fun createDataWedgeBroadcastReceiver(events: EventSink?): BroadcastReceiver? 
    return object : BroadcastReceiver() 
        override fun onReceive(context: Context, intent: Intent) 
            if (intent.action.equals(PROFILE_INTENT_ACTION))
            
                //  A barcode has been scanned

                var scanData =intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_DATA_STRING)

                var symbology = intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_LABEL_TYPE)
                var date = Calendar.getInstance().getTime()
                var df = SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
                var dateTimeString = df.format(date)
                var currentScan = Scan(scanData,   symbology, dateTimeString);
                events?.success(currentScan.toJson())
            
            //  Could handle return values from DW here such as RETURN_GET_ACTIVE_PROFILE
            //  or RETURN_ENUMERATE_SCANNERS
        
    


private fun createDataWedgeProfile(profileName: String) 
    //  Create and configure the DataWedge profile associated with this application
    //  For readability's sake, I have not defined each of the keys in the DWInterface file
    dwInterface.sendCommandString(this, DWInterface.DATAWEDGE_SEND_CREATE_PROFILE, profileName)
    val profileConfig = Bundle()
    profileConfig.putString("PROFILE_NAME", profileName)
    profileConfig.putString("PROFILE_ENABLED", "true") //  These are all strings
    profileConfig.putString("CONFIG_MODE", "UPDATE")
    val barcodeConfig = Bundle()
    barcodeConfig.putString("PLUGIN_NAME", "BARCODE")
    barcodeConfig.putString("RESET_CONFIG", "true") //  This is the default but never hurts to specify
    val barcodeProps = Bundle()
    barcodeConfig.putBundle("PARAM_LIST", barcodeProps)
    profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig)
    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))
    dwInterface.sendCommandBundle(this, DWInterface.DATAWEDGE_SEND_SET_CONFIG, profileConfig)
    //  You can only configure one plugin at a time in some versions of DW, now do the intent output
    profileConfig.remove("PLUGIN_CONFIG")
    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", PROFILE_INTENT_ACTION)
    intentProps.putString("intent_delivery", PROFILE_INTENT_BROADCAST)  //  "2"
    intentConfig.putBundle("PARAM_LIST", intentProps)
    profileConfig.putBundle("PLUGIN_CONFIG", intentConfig)
    dwInterface.sendCommandBundle(this, DWInterface.DATAWEDGE_SEND_SET_CONFIG, profileConfig)

更新:对于面临相同问题的任何人,仅通过 DataWedge 应用程序编辑配置文件将不起作用。我所做的是将这些添加到 createDataWedgeProfile 以启用 RFID 插件。

    val rfidConfigParamList = Bundle()
    rfidConfigParamList.putString("rfid_input_enabled", "true")
    rfidConfigParamList.putString("rfid_beeper_enable", "true")
    rfidConfigParamList.putString("rfid_led_enable", "true")
    rfidConfigParamList.putString("rfid_antenna_transmit_power", "30")
    rfidConfigParamList.putString("rfid_memory_bank", "2")
    rfidConfigParamList.putString("rfid_session", "1")
    rfidConfigParamList.putString("rfid_trigger_mode", "1")
    rfidConfigParamList.putString("rfid_filter_duplicate_tags", "true")
    rfidConfigParamList.putString("rfid_hardware_trigger_enabled", "true")
    rfidConfigParamList.putString("rfid_tag_read_duration", "250")


    val rfidConfigBundle = Bundle()
    rfidConfigBundle.putString("PLUGIN_NAME", "RFID")
    rfidConfigBundle.putString("RESET_CONFIG", "true")
    rfidConfigBundle.putBundle("PARAM_LIST", rfidConfigParamList)
    profileConfig.putBundle("PLUGIN_CONFIG", rfidConfigParamList)

【问题讨论】:

插件作者在这里:我以为输出在data_string中,你试过吗?我也找不到任何输出示例,恐怕我自己也没有硬件。让我在内部问。如需指定输入参数,请参见此处:techdocs.zebra.com/datawedge/11-0/guide/api/setconfig/… 谢谢,条形码的输出在 data_string 中。但是,在扫描 RFID 标签时,我无法检索任何输出。这就是为什么我认为它可能是另一种格式。我手动启用了 datawedge 应用程序中的 RFID 输入,因为我不知道如何在“createDataWedgeProfile”中更改它。这可能是个问题吗? 我使用了您提供的链接,现在可以使用。看起来手动编辑数据楔形应用程序上的配置文件将不起作用。非常感谢您的帮助。 【参考方案1】:

数据将作为字符串传递。如果读取了多个标签,它们将被连接起来并在一个意图中发送。

https://techdocs.zebra.com/datawedge/11-0/guide/output/intent/

标签:DATA_STRING_TAG

类型:[字符串]

名称:“com.symbol.datawedge.data_string”

内容:获取的条码字符

示例:“abcde12345”

【讨论】:

以上是关于使用颤振进行 RFID 扫描 - Zebra 设备的主要内容,如果未能解决你的问题,请参考以下文章

Zebra 设备-TC75x-Android 8.1-条形码扫描问题

我应该使用 <keypress> 和 <keyrelease>(或 <Return>)进行 RFID 扫描吗?

我可以在 React Native 中将 Zebra 扫描仪包与 Expo 项目一起使用吗?

暂停 Zebra TC51 中的条码扫描器

使用 Raspberry 和 python 读取 USB RFID

Zebra 条形码打印,但不扫描