AZ_*_*AZ_ 11 android characteristics bluetooth-lowenergy gatt
如何阅读BluetoothGattCharacteristic属性,如特征Readable,Writable或Notifiable.
AZ_*_*AZ_ 14
/**
* @return Returns <b>true</b> if property is writable
*/
public static boolean isCharacteristicWritable(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 isCharacteristicReadable(BluetoothGattCharacteristic pChar) {
return ((pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) != 0);
}
/**
* @return Returns <b>true</b> if property is supports notification
*/
public boolean isCharacteristicNotifiable(BluetoothGattCharacteristic pChar) {
return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6353 次 |
| 最近记录: |