You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter接入Zebra MC3300X设备实现RFID扫描功能问题咨询

MC3300X扫描设备通过DataWedge实现RFID扫描问题

我正在尝试在MC3300X扫描设备上接入DataWedge Flutter插件,目前已经可以正常获取条码扫描结果,但我的核心需求是使用该设备进行RFID扫描。我收到的建议是修改createDataWedgeProfile方法以启用RFID插件,同时修改createDataWedgeBroadcastReceiver方法适配接收到的Intent格式。
目前遇到的问题是Zebra官方网站没有找到相关的RFID示例代码,不确定应该使用哪种解码模式。我尝试给scanData使用smart_decode_type和decode_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))
            {
                //  已扫描到条码

                var scanData =intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_DATA_STRING)

                var symbology = intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_LABEL_TYPE)
                var date = Calendar.getInstance().time
                var df = SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
                var dateTimeString = df.format(date)
                var currentScan = Scan(scanData, symbology, dateTimeString);
                events?.success(currentScan.toJson())
            }
            //  可在此处处理DW返回值,例如RETURN_GET_ACTIVE_PROFILE或RETURN_ENUMERATE_SCANNERS
        }
    }
}

private fun createDataWedgeProfile(profileName: String) {
    //  创建并配置与当前应用关联的DataWedge配置文件
    //  为保证可读性,我没有在DWInterface文件中定义所有键名
    dwInterface.sendCommandString(this, DWInterface.DATAWEDGE_SEND_CREATE_PROFILE, profileName)
    val profileConfig = Bundle()
    profileConfig.putString("PROFILE_NAME", profileName)
    profileConfig.putString("PROFILE_ENABLED", "true") //  以上参数值均为字符串类型
    profileConfig.putString("CONFIG_MODE", "UPDATE")
    val barcodeConfig = Bundle()
    barcodeConfig.putString("PLUGIN_NAME", "BARCODE")
    barcodeConfig.putString("RESET_CONFIG", "true") //  该项为默认值,显式指定可避免异常
    val barcodeProps = Bundle()
    barcodeConfig.putBundle("PARAM_LIST", barcodeProps)
    profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig)
    val appConfig = Bundle()
    appConfig.putString("PACKAGE_NAME", packageName)      //  将配置文件与当前应用绑定
    appConfig.putStringArray("ACTIVITY_LIST", arrayOf("*"))
    profileConfig.putParcelableArray("APP_LIST", arrayOf(appConfig))
    dwInterface.sendCommandBundle(this, DWInterface.DATAWEDGE_SEND_SET_CONFIG, profileConfig)
    //  部分版本的DW一次只能配置一个插件,此处单独配置意图输出
    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)

内容的提问来源于stack exchange,提问作者Dat Tran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 17:06:04