Reputation: 805
I'm learning android ble api. I can't receive notification from a characteristic that it's protperty is 0x002. So I tried setCharacteristicNotification(mChar, true)
and descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)
to make onCharacteristicChanged invoked. But it does't work, can anybody help me?
Thanks.
Upvotes: 1
Views: 498
Reputation: 1015
It seems that 0x02 (Click here to see all the available properties) means that you can only read this characteristic and you cannot enable notifications to it.
To read a characteristic value use the following method:
and then the
onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
callback will be called with the updated value of the characteristic. You can then use one or more of the following methods to retrieve it's updated value
ch.getFloatValue(formatType, offset);
ch.getIntValue(formatType, offset);
ch.getStringValue(offset);
ch.getValue();
Upvotes: 2