如何阅读 BluetoothGattCharacteristic
属性,如为特征读
,可写
或呈报
。
/ **
* @返回返回< B>真< / B>如果属性是可写的
* /
公共静态布尔isCharacteristicWriteable(BluetoothGattCharacteristic PCHAR){
返回(pChar.getProperties()及(BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE))!= 0;
}
/ **
* @返回返回< B>真< / B>如果属性是可读
* /
公共静态布尔isCharacterisitcReadable(BluetoothGattCharacteristic PCHAR){
返回((pChar.getProperties()及!BluetoothGattCharacteristic.PROPERTY_READ)= 0);
}
/ **
* @返回返回< B>真< / B>如果属性是支持的通知
* /
公共布尔isCharacterisiticNotifiable(BluetoothGattCharacteristic PCHAR){
返回(pChar.getProperties()及BluetoothGattCharacteristic.PROPERTY_NOTIFY)!= 0;
}
How to read BluetoothGattCharacteristic
properties like is characteristic Readable
, Writable
or Notifiable
.
/**
* @return Returns <b>true</b> if property is writable
*/
public static boolean isCharacteristicWriteable(BluetoothGattCharacteristic pChar) {
return (pChar.getProperties() & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) != 0;
}
/**
* @return Returns <b>true</b> if property is Readable
*/
public static boolean isCharacterisitcReadable(BluetoothGattCharacteristic pChar) {
return ((pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) != 0);
}
/**
* @return Returns <b>true</b> if property is supports notification
*/
public boolean isCharacterisiticNotifiable(BluetoothGattCharacteristic pChar) {
return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;
}