mac*_*ach 4 android bluetooth-lowenergy android-bluetooth
我有连接到的代码,然后尝试发现自定义BLE服务器设备广告自定义服务提供的所有服务.
代码可以使用
代码不工作的
在发生故障的设备上,它经常发现在一个(两个)广告相同BLE服务的设备上的所有BLE服务.重新启动Android设备和/或摆弄wifi/bt使其发现其他BLE设备上的所有服务但不是第一个(!).
有人知道三星设备有关BLE服务发现的突出问题吗?
有所有服务:
04-16 13:28:00.999: V/ScanningState(9741): onServicesDiscovered()
04-16 13:28:00.999: I/ScanningState(9741): The device has service 00001800-0000-1000-8000-00805f9b34fb
04-16 13:28:00.999: I/ScanningState(9741): The device has service 0000180a-0000-1000-8000-00805f9b34fb
04-16 13:28:00.999: I/ScanningState(9741): The device has service 0000180f-0000-1000-8000-00805f9b34fb
04-16 13:28:00.999: I/ScanningState(9741): The device has service f0ba0000-c6b5-11e2-8b8b-0800200c9a66
04-16 13:28:00.999: I/ScanningState(9741): The device has service f0ba0100-c6b5-11e2-8b8b-0800200c9a66
04-16 13:28:00.999: I/ScanningState(9741): The device has service f0ba1100-c6b5-11e2-8b8b-0800200c9a66
Run Code Online (Sandbox Code Playgroud)
缺少服务:
04-16 14:05:31.179: V/ScanningState(10710): onServicesDiscovered()
04-16 14:05:31.179: I/ScanningState(10710): The device has service 00001800-0000-1000-8000-00805f9b34fb
04-16 14:05:31.179: I/ScanningState(10710): The device has service 0000180a-0000-1000-8000-00805f9b34fb
04-16 14:05:31.179: I/ScanningState(10710): The device has service 0000180f-0000-1000-8000-00805f9b34fb
04-16 14:05:31.179: I/ScanningState(10710): The device has service f0ba0000-c6b5-11e2-8b8b-0800200c9a66
04-16 14:05:31.179: W/ScanningState(10710): Device is missing sensor service
04-16 14:05:31.179: W/ScanningState(10710): Device is missing storage service
04-16 14:05:31.179: I/ScanningState(10710): Candidate did not support required services
Run Code Online (Sandbox Code Playgroud)
对于第二次(失败)扫描,我也看到以下日志:
04-16 14:24:26.310: D/BtGatt.GattService(2856): onGetCharacteristic() - address=00:07:80:13:14:33, status=133, charUuid=00000000-0000-0000-0000-000000000000, prop=0
04-16 14:24:26.310: D/BtGatt.btif(2856): btif_gattc_get_included_service
04-16 14:24:26.310: D/BtGatt.btif(2856): btgattc_handle_event: Event 1011
04-16 14:24:26.310: E/bt-btif(2856): No server cache available
04-16 14:24:26.310: E/BtGatt.btif(2856): bta_to_btif_uuid: Unknown UUID length 25104!
Run Code Online (Sandbox Code Playgroud)
更新:
进一步调查表明,如果一次只有一个BLE服务设备,onServicesDiscovered(BluetoothGatt gatt,int status)将返回所有BLE服务.下层有哪些资源泄漏?
好的,所以简短的回答是不要调用connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback)任何其他线程,而是主线程.
如果我有一段onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)时间连接到设备,我缓存了引用,之后connectGatt()在onConnectionStateChange(BluetoothGatt gatt, int status, int newState)与第一个设备断开连接后调用回调内部.这导致了这个问题中描述的问题.
| 归档时间: |
|
| 查看次数: |
2231 次 |
| 最近记录: |