How to make a characteristic both read and write?

2019-06-12 11:56发布

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条回答
趁早两清
2楼-- · 2019-06-12 12:09

Use a mask

int permission = BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ;
int property = BluetoothGattCharacteristic.PROPERTY_WRITE|BluetoothGattCharacteristic.PROPERTY_READ;
查看更多
登录 后发表回答