首页 > 解决方案 > 连接 BLE 设备时出现 ChromeOS/Chromebook 异常 (getCharacteristic)

问题描述

在一个小团队中,我们正在开发一个部署到 Android(平板电脑)和 ChromeOS 设备的应用程序。为此,我们有几个构建目标,例如 Pixel C、Galaxy Tabs、Asus C302 Chromebook 和 Pixelbook。

我们正在通过 BLE 与 Windows 10 系统开发接口的应用程序,该系统运行接受传入 BLE 连接的应用程序。我们在应用程序中执行的操作:

当我们的应用程序部署到 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 上进行的:

到目前为止我们发现了什么

为什么我们不使用“普通”蓝牙(经典)?

我们目前正在使用 C# W10 应用程序连接到使用该应用程序。但是,此应用程序目前用作 Stub,并且在不久的将来将被我们正在开发的需要通过 BLE 运行的低功耗嵌入式解决方案(可穿戴产品)所取代。因此,我们必须使用 BLE。

标签: bluetooth-lowenergygattchromebook

解决方案


推荐阅读