Radius Networks库随机停止工作

时间:2014-07-09 14:12:15

标签: ibeacon ibeacon-android

我使用的是Radius Networks开源Android iBeacon库,由于某些原因,它有时会停止工作,也就是说,它工作正常,然后没有任何明显的理由它停止测距或在至少它看起来是怎么回事。我在iBeacon Locate应用程序中遇到过相同的行为。

出现此问题时,关闭并打开应用程序并不起作用。为了让应用程序再次正常工作,我必须关闭应用程序,禁用蓝牙,打开应用程序(因此应用程序抱怨蓝牙被禁用),启用蓝牙,然后再次打开应用程序。

我已经在应用程序启动并正常工作时捕获了LogCat,并且当它没有时,我注意到它们之间存在一些差异,可能提供了发生了什么的线索。

启动并正常工作时的LogCat:

07-07 19:51:54.519: D/IBeaconManager(1490): we have a connection to the service now
07-07 19:51:54.629: I/IBeaconService(1490): start ranging received
07-07 19:51:54.629: I/ActivityManager(592): Displayed com.core.vordrawer/.MainActivity: +654ms (total +999ms)
07-07 19:51:54.629: D/BluetoothAdapter(1490): startLeScan(): null
07-07 19:51:54.669: D/BtGatt.GattService(11998): registerClient() - UUID=2c657179-3c94-4f2f-9c0b-2035f646b8a4
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_register_app
07-07 19:51:54.669: D/BtGatt.btif(11998): btgattc_handle_event: Event 1000
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 0
07-07 19:51:54.669: D/BtGatt.GattService(11998): onClientRegistered() - UUID=2c657179-3c94-4f2f-9c0b-2035f646b8a4, clientIf=5
07-07 19:51:54.669: D/BluetoothAdapter(1490): onClientRegistered() - status=0 clientIf=5
07-07 19:51:54.669: D/BtGatt.GattService(11998): startScan() - queue=0
07-07 19:51:54.669: D/BtGatt.GattService(11998): startScan() - adding client=5
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_scan
07-07 19:51:54.669: D/BtGatt.btif(11998): btgattc_handle_event: Event 1002
07-07 19:51:54.689: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.689: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.689: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.689: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.699: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.699: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.699: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 4096
07-07 19:51:54.699: D/BtGatt.btif(11998): btif_gattc_add_remote_bdaddr device added idx=0
...

启动时的LogCat和DOESN' T正常工作:

07-07 19:58:48.270: D/IBeaconManager(4630): we have a connection to the service now
07-07 19:58:48.380: I/IBeaconService(4630): start ranging received
07-07 19:58:48.380: D/BluetoothAdapter(4630): startLeScan(): null
07-07 19:58:48.390: I/ActivityManager(592): Displayed com.core.vordrawer/.MainActivity: +644ms (total +846ms)
07-07 19:58:48.420: D/BtGatt.GattService(11998): registerClient() - UUID=33ecc2dc-ee8f-4bb1-b306-e5a2b82a1cba
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_register_app
07-07 19:58:48.420: D/BtGatt.btif(11998): btgattc_handle_event: Event 1000
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 0
07-07 19:58:48.420: D/BtGatt.GattService(11998): onClientRegistered() - UUID=33ecc2dc-ee8f-4bb1-b306-e5a2b82a1cba, clientIf=7
07-07 19:58:48.420: D/BluetoothAdapter(4630): onClientRegistered() - status=0 clientIf=7
07-07 19:58:48.420: D/BtGatt.GattService(11998): startScan() - queue=0
07-07 19:58:48.420: D/BtGatt.GattService(11998): startScan() - adding client=7
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_scan
07-07 19:58:48.420: D/BtGatt.btif(11998): btgattc_handle_event: Event 1002
07-07 19:58:48.420: I/IBeaconService(4630): Adjusted scanStopTime to be Mon Jul 07 19:58:49 GMT-04:30 2014
07-07 19:58:48.570: D/dalvikvm(20228): GC_EXPLICIT freed 2477K, 19% free 28473K/35068K, paused 2ms+7ms, total 41ms
07-07 19:58:48.831: D/dalvikvm(592): GC_EXPLICIT freed 523K, 22% free 26548K/33668K, paused 7ms+9ms, total 150ms
07-07 19:58:49.031: D/dalvikvm(21666): GC_EXPLICIT freed 257K, 7% free 9474K/10172K, paused 2ms+4ms, total 23ms
07-07 19:58:49.521: D/Callback(4630): attempting callback via intent: ComponentInfo{com.core.vordrawer/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
...

在最后一个LogCat中,我相信有用的消息可能是:

  • I / IBeaconService(4630):调整后的scanStopTime为Mon Jul 07 19:58:49 GMT-04:30 2014

  • D / Callback(4630):尝试通过意图回调:ComponentInfo {com.core.vordrawer / com.radiusnetworks.ibeacon.IBeaconIntentProcessor}

但我不知道该怎么办......

感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

看起来这是您的蓝牙硬件或驱动程序的低级问题。在第二个日志片段中,您看不到任何行:

07-07 19:51:54.699: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.689: I/bt-hci(11998): btu_ble_process_adv_pkt

这些日志行表明您的Android设备正在检测来自您的信标的蓝牙广告数据包。根据您的描述,听起来您的蓝牙硬件处于不良状态并关闭蓝牙并将其重新打开以清除状况。

您可以尝试查看导致此问题的原因:

  1. 关闭wifi。在某些Android手机型号上,wifi和蓝牙共用一个芯片或天线,并且不能同时工作。

  2. 关闭可能干扰蓝牙的任何其他应用。执行此操作的最佳方法是重新启动手机,查看应用是否正常运行,而无需运行任何其他应用。 (您可能还需要进入设置并卸载任何可能使用蓝牙的自动启动应用程序。)

  3. 如果您有可用的设备,请尝试使用其他Android设备。