我有代码连接到并尝试发现广告自定义服务的自定义 BLE 服务器设备提供的所有服务。
代码works on
- 搭载 Android 5.1 的 Nexus 5
- 三星 SM-T320 搭载 Android 4.4.2
- 中兴 Blade Vec 4G 搭载 Android 4.4.2
Code 不起作用 on
- 三星 SM-T360 搭载 Android 4.4.4
- 三星 GT-I9195 搭载 Android 4.4.2
在发生故障的设备上,它通常会发现一台(两台)设备上通告相同 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
缺少的服务:
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
对于第二次(失败)扫描,我还看到以下日志:
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!
Update:
进一步调查表明,如果一次仅存在一个 BLE 服务设备,则 onServicesDiscovered(BluetoothGatt gatt, int status) 会返回所有 BLE 服务。较低层存在某种资源泄漏?