mcd
mcd

Reputation: 1432

bluetooth low energy notification

i am trying to read temperature value from health profile.health thermometer service. according to official google ble devlopment page when i try to notify a health thermometer characteristic to read temperature i try to write descriptor value (Client Characteristic Configuration) using writeDescriptor a callback method of writeDescriptor return status 5 according to google it's GATT_INSUFFICIENT_AUTHENTICATION. so i comment the code of writedescriptor and try to call the method mBluetoothGatt.setCharacteristicNotification(characteristic, enabled); but onCharacteristicChanged method never called. when i talk to my ios devloper team. they said that they never write a descriptor value they just set the notification to true and they get temperature value from the same chip. to write a descriptor value is necessary for android developer to get notification ??? so at last i try to run the official bluetooth app from the bluetooth.com site for test purpose they just disable all three buttons notify read and write??? thank you and sorry for my English

[UPDATE]
find out some log which may cause some bonding issues please help me if you have any solution for that.

[UPDATE]
after upgrading kitkat 4.4 on nexus 7 . add two method
device.createBond();
device.setPairingConfirmation(true);

works for me now i can read the encrypted characteristic. but still unstable. but some success i got.

Upvotes: 4

Views: 8927

Answers (2)

madabrowski
madabrowski

Reputation: 1571

In my case the problem was that BluetoothGatt object can accept only one pending operation. Solution was to do read/write operations in sequence, waiting for the completion callback of first before requesting second read/write operation.

Upvotes: 0

reTs
reTs

Reputation: 1829

Yes, in Android for enabling BLE notification, you must both call mBluetoothGatt.setCharacteristicNotification(characteristic, enabled) and write suitable value to descriptor 0x2902 of that characteristic.

I am not sure why you get GATT_INSUFFICIENT_AUTHENTICATION, this may be caused by the implementation of the thermometer.

EDIT : From the new information in the comment and also the screen captured provided, there are a few things you may want to check :

  1. The characteristic is a indication characteristic, but not a notification characteristic. The value you write to the descriptor should be BluetoothGattDescriptor.ENABLE_INDICATION_VALUE, but not BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE. Notice that you still need to turn on the indication by setCharacteristicNotification(). (Confusing terminology here, but it is necessary as per the docs)

  2. For the unstable Bluetooth stack on Android, try to restart the Bluetooth, and turn of WiFi. This will increase the stability. (Although not 100% solving the problem)

Upvotes: 4

Related Questions