我想通过蓝牙在android应用程序中连续从ble硬件读取数据.
连接已完成,我可以将数据从应用程序发送到ble,但是无法从ble读取数据.
从ble获取一些数据时必须调用onCharactersticChanged方法,但此回调方法未调用.我想通知ble但
writeChar.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(BLEUtils.CLIENT_CHARACTERISTIC_CONFIG_UUID, BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
// Enable local notifications
gatt.setCharacteristicNotification(writeChar, true);
boolean succes = gatt.writeDescriptor(descriptor);
其返回假
解决方法:
我建议您在订阅特性时应设置ENABLE_NOTIFICATION_VALUE.这是我执行此操作的代码:
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
List services &#