BluetoothGattCharacteristic characteristic = mBluetoothGatt.getService(serviceUUID).getCharacteristic(characteristicUUID);
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
byte[] command = {0x01, 0x02, 0x03};
characteristic.setValue(command);
mBluetoothGatt.writeCharacteristic(characteristic);
在上述代码中,setWriteType()函数的参数为WRITE_TYPE_DEFAULT,这意味着使用默认的带有响应的写入模式。在写入数据后,应该确保在BluetoothGattCallback的onCharacteristicWrite()回调函数中接收到响应。