Savage F. Morgan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

When setting the value to the descriptor instead of putting descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE), put descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE). The callbacks for onCharacteristicChanged are called now.

Can you clarify what "indication" is supposed to do? Based on the docs, I was sure that the right flag to set in this case was ENABLE_NOTIFICATION_VALUE but you're now the second person on this page who has suggested that ENABLE_INDICATION_VALUE is the right flag. What is the difference and use case for each? –  jkraybill Oct 28 '13 at 7:56
 
It depends on the Bluetooth Profile implementation inside the bluetooth device. It either uses "Notification" or "Indication" for posting updates. So you'll have to find out which one your device uses. –  Boni2k Oct 28 '13 at 20:47
 
Like Boni2k said, it depends on the Bluetooth Profile. If your service follows the standard profiles you should be able to find that information [here] (developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx). If you want to know this programatically, you can call the getProperties() method for your characteristic and do a bitwise AND against the property you want to check if it's different than 0, then it supports that activity. –  user2926265 Nov 1 '13 at 14:23
 
What bothers me here is that the Android documentation states that setCharacteristicNotifications works for EITHER notifications or indications. So I assume they are checking the properties internally and writing the correct flags to the characteristic. They also use the method in their example which has worked with some HeartRate monitors. Do you know if the method is flawed? My understanding is that one cannot set BOTH indication/notification flags though some devices may accept that. IF they are doing that then I would say their method IS wrong. –  Brian Reinhold Apr 2 at 9:48
 
http://stackoverflow.com/questions/17910322/android-ble-api-gatt-notification-not-received
posted on 2014-06-24 10:15  罗斯摩根  阅读(3545)  评论(0编辑  收藏  举报