的Andr​​oid如何阅读BLE属性可读可写呈报关贸总协定特点 [英] Android How to read BLE properties Readable Writable Notifiable GATT Characteristics

查看:216
本文介绍了的Andr​​oid如何阅读BLE属性可读可写呈报关贸总协定特点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何阅读 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;
    }

这篇关于的Andr​​oid如何阅读BLE属性可读可写呈报关贸总协定特点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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