我尝试从我连接的设备上读取一些配置,但在回调中 - onCharacteristicRead参数status = 10.
我注意到状态== 0测量BluetoothGatt.GATT_SUCCESS。
什么是10个席位?
我的代码如下:
public boolean read(byte[] bytes, String action) {
// is copied from android website example
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return false;
}
BluetoothGattService mCC2540_service = mBluetoothGatt.getService(UUID.fromString(mCC2540_SERVICE_UUID));
if (mCC2540_service == null){
Log.e(TAG, "mCC2540_service == null");
return false;
}
BluetoothGattCharacteristic bluetoothGattCharacteristic = mCC2540_service.getCharacteristic(UUID.fromString("0000fffc-0000-1000-8000-00805f9b34fb"));
bluetoothGattCharacteristic.setValue(bytes);
if ((bluetoothGattCharacteristic.getProperties() | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mBluetoothGatt.setCharacteristicNotification(bluetoothGattCharacteristic, true);
}
boolean status = mBluetoothGatt.readCharacteristic(bluetoothGattCharacteristic);
Log.d(TAG, "read() command sent");
return status;
}