我正在使用蓝牙LE设备与Android应用程序连接,并且我能够建立连接。 但进行连接后,我无法获得设备更新的回调。 我不知道我在做什么错,所以下面是我无法理解的制造商文档的一部分: -无法从智能蓝牙LE设备获取数据Android
“测定仪在其控制点支持Display Sync命令。Display Sync命令是写入控制点的2个字节的消息,该功能可用于将血氧仪的显示与主机设备的显示进行同步,这有助于操作员确认脉搏血氧饱和度读数已正确接收。
在第一八位的值将为0x61和第二个字节应该有 5 25秒
之间的值,为了得到这一点,我做了以下内容: -
在LeScanCallback我连接BluetoothDevice BluetoothGattCallback
在onServicesDiscovered我写下面的代码行,我很怀疑是 正确的方式来实现它并且可以是我没有从 蓝牙设备获取数据的原因: -
BluetoothGattCharacteristic oximeterCharacteristic =
noninService.getCharacteristic(UUID.fromString(Oximeter_characteristic_uuid)); BluetoothGattCharacteristic noninControlPointCharacteristic = noninService.getCharacteristic(UUID.fromString(Nonin_control_point_characteristic_uuid)); oximeterCharacteristic.setValue(0x61, oximeterCharacteristic.FORMAT_SINT16, 1); oximeterCharacteristic.setValue(15, oximeterCharacteristic.FORMAT_SINT16, 2); noninControlPointCharacteristic.setValue(0x61, noninControlPointCharacteristic.FORMAT_SINT16, 1); noninControlPointCharacteristic.setValue(15, noninControlPointCharacteristic.FORMAT_SINT16, 2); gatt.writeCharacteristic(noninControlPointCharacteristic); gatt.writeCharacteristic(oximeterCharacteristic); gatt.setCharacteristicNotification(oximeterCharacteristic, true); gatt.setCharacteristicNotification(noninControlPointCharacteristic, true);
你可以添加操作系统版本和手机的问题?它有助于查明特定的异常情况。 – Zomb
“进行连接后,我无法获得设备更新的回调”。你确定你正在处理通知特性? (不读特性和写特性)其实,你没有提供足够的信息,你怎么做?不仅仅是编码。 –