-1
奇怪的情况发生在相同的代码为Android 4.4.2操作系统三星和三星(A8)Android 5.1.1。Android Ble写
if(mBluetoothGattCharacteristic==null){
return;
}
byte [] mCommandData=new byte[64];
mCommandData[0]=Constants.REMOTE_CMD;
mCommandData[1]=(byte) mRemoteCommand;
mBluetoothGattCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
boolean isUpdated= mBluetoothGattCharacteristic.setValue(mCommandData);
boolean isWriteDone=mBluetoothGatt.writeCharacteristic(mBluetoothGattCharacteristic);
LogUtils.i("LOG", "Ble Write set is---"+ isUpdated + " Characteristics Write done"+ isWriteDone);
/**
* Create New Command Release Key
*/
byte [] mCommandRelease=new byte[64];
mCommandRelease[0]=Constants.REMOTE_CMD;
mCommandData[1]=(byte)Constants.IR_KEY_RELEASE;
isUpdated= mBluetoothGattCharacteristic.setValue(mCommandData);
isWriteDone=mBluetoothGatt.writeCharacteristic(mBluetoothGattCharacteristic);
LogUtils.i("LOG", "Ble Write set is---"+ isUpdated + " Characteristics Write done"+ isWriteDone);
在上面的代码为Android 4.4.2 writeCharacteristic
两个命令写给真。
但是在android系统的情况5.1.1给它真正的第一次写,当它继续旁边写它提供虚假的writeCharacteristic
现在的解决方案我想到的是Android 5.1.1我不得不等待为onCharacteristicWrite
,然后写下一个命令。
如果有人知道这样的问题,并指出我是否仅发生在三星设备上?
这是正确的解决方案。在Android的BLE API中,一次只能有一次优秀的GATT操作。 – Emil