当我尝试写入某些特征时,我也遇到了类似的问题,但是我是否记得相同的错误代码。 (它可以在某些设备上运行,而不能在其他设备上运行)。
原来是问题
property出在
characteristics和的
writeType。
由于特征可以设置值:
write without response
要么write with response
参考该属性,您必须
writeType在将实际数据写入特征之前进行设置。
一旦获得特性,就可以设置类型,而在写入之前。
BluetoothGattCharacteristic tChar = syncService.getCharacteristic(SYNC_HEIGHT_INPUT_CHAR); if (tChar == null) throw new AssertionError("characteristic null when sync time!"); // use one of them in regards of the Characteristic's property tChar.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); //tChar.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); tChar.setValue(, BluetoothGattCharacteristic.FORMAT_SINT32, 0); gatt.writeCharacteristic(tChar);


