【发布时间】:2021-11-22 16:50:13
【问题描述】:
我正在尝试在 MC3300X 扫描仪上实现此 plugin。我能够获得条形码,但我的意图是将此扫描仪用于 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)) { // 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”中更改它。这可能是个问题吗?
-
我使用了您提供的链接,现在可以使用。看起来手动编辑数据楔形应用程序上的配置文件将不起作用。非常感谢您的帮助。