How to make a characteristic both read and write?

拜拜、爱过 提交于 2019-12-08 10:36:07

问题


I understand that a characteristic can have only one property and one permission, and that the property must have the same value as the permission e.g. a characteristic must have the property of being writable if it has permission to be written to... so how can I make a characteristic readable AND writable?

e.g.

How to turn this

int permission = BluetoothGattCharacteristic.PERMISSION_WRITE;
int property = BluetoothGattCharacteristic.PROPERTY_WRITE;

Into read and write


回答1:


Use a mask

int permission = BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ;
int property = BluetoothGattCharacteristic.PROPERTY_WRITE|BluetoothGattCharacteristic.PROPERTY_READ;


来源:https://stackoverflow.com/questions/47341515/how-to-make-a-characteristic-both-read-and-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!