Android How to read BLE properties Readable Writable Notifiable GATT Characteristics

前端 未结 2 1587
春和景丽
春和景丽 2021-02-14 02:09

How to read BluetoothGattCharacteristic properties like is characteristic Readable, Writable or Notifiable.

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-14 02:48

    I ran into the similar problem where the sample code ONLY works when the characteristic is READ because of the operator "|". If the characteritic is of other types such as Notification or Write, the code will always set it sup as READ. The correct code should be as the following:

    if((charaProp & BluetoothGattCharacteristic.PROPERTY_READ) > 0){ 
    
    } else if(charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFICATION) > 0){
    }
    

    (...Continue with other cases)

    Again, the google sample code is NOT correct.

    David

提交回复
热议问题