如何使读写特性都好? [英] How to make a characteristic both read and write?

查看:104
本文介绍了如何使读写特性都好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解,特征只能具有一个属性和一个许可,并且该属性必须具有与许可相同的值,例如如果特征被允许写入,则特征必须具有可写的属性.那么,如何使特征可读和可写?

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?

例如

如何打开它

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

进入阅读写作

推荐答案

使用遮罩

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

这篇关于如何使读写特性都好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆