bluetooth-lowenergy - 连接 BLE 设备时出现 ChromeOS/Chromebook 异常 (getCharacteristic)
问题描述
在一个小团队中,我们正在开发一个部署到 Android(平板电脑)和 ChromeOS 设备的应用程序。为此,我们有几个构建目标,例如 Pixel C、Galaxy Tabs、Asus C302 Chromebook 和 Pixelbook。
我们正在通过 BLE 与 Windows 10 系统开发接口的应用程序,该系统运行接受传入 BLE 连接的应用程序。我们在应用程序中执行的操作:
- 我们执行扫描以查找具有特定名称的设备
- 我们连接到这个设备:使用 Android Native BluetoothDevice 类:mBluetoothDevice.connectGatt();
- 我们请求服务:使用 Android Native BluetoothGatt 类:mBluetoothGatt.discoverServices();
当我们的应用程序部署到 Android 目标时,它成功连接到 W10 应用程序并检索其服务 (onServicesDiscovered)。但是,当在 ChromeOS 上运行相同版本的应用程序时,检索服务会引发以下异常:
08-17 10:46:52.750 3827-3846/com.(our namespace) D/TheApp: BleGattHandler | onServicesDiscovered() called with: gatt = [android.bluetooth.BluetoothGatt@baff2ee], status = [0]
08-17 10:46:52.751 3827-3846/com.(our namespace) W/BluetoothGatt: Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference
at com.(our namespace).communication.bluetooth.lowenergy.BleGattHandler.onServicesDiscovered(BleGattHandler.java:90)
at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:237)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:103)
at android.os.Binder.execTransact(Binder.java:565)
我们的结论是,由于某种原因,ChromeOS 无法检索 BLE 设备的服务。我们在这里不知所措,希望听到你们中是否有人知道原因或可能的解决方案(我们也愿意寻求专业帮助)
我们使用的是什么 ChromeOS 版本
我们最近的测试(今天)是在 Pixelbook 上进行的:
- ChromeOS 68.0.3440.87(来自测试版)
- ChromeOS 69.0.3497.21(来自开发频道)
到目前为止我们发现了什么
此 ChromeOS 问题,但已报告已修复: https ://bugs.chromium.org/p/chromium/issues/detail?id=722987
为什么我们不使用“普通”蓝牙(经典)?
我们目前正在使用 C# W10 应用程序连接到使用该应用程序。但是,此应用程序目前用作 Stub,并且在不久的将来将被我们正在开发的需要通过 BLE 运行的低功耗嵌入式解决方案(可穿戴产品)所取代。因此,我们必须使用 BLE。
解决方案
推荐阅读
- java - 用于自定义 ObjectMapper 的 Jax-rs ContextResolver
- python - 使用 _raw_delete 从 ManyToMany 表中删除条目
- c# - 有没有办法制造各种类型的敌人?
- google-bigquery - 6小时后查询超时,如何优化?
- python - How to change width of a plot while zooming with tkinter toolbar
- java - 我想编写一个检查二维列表中是否存在重复元素的函数
- reactjs - 类型错误:无法读取未定义的属性“地图”
- c++ - 调用 getInstance 函数时,C++ 中的单例实现不会产生相同的类实例
- highcharts - 在多个独立轴上同步刻度
- angular - 如何使用 Angular Universal 进行部分(按组件)服务器端渲染?