I figured this out and hope some of you are going to laugh.

I did not understand the way this all works. Keep in mind that I already
implemented all of this for iOS, so some of my thinking is influenced by
the way iOS does things.

On iOS the same callback is used for the response to a read request and the
response to an update notification for data. Getting a change in a
characteristic value is handled the same. Any time it changes whether that
is from a Read or a Notification it comes in the same iOS callback.

I assumed Android was the same way.

So I was expecting to get my data update in the onCharacteristicRead
response. Those who have experience with all of this probably know right
off that notification updates come in the onCharacteristicChanged callback.

Once I added that everything is now working.

On Mon, Dec 8, 2014 at 11:13 PM, Tony Pitman <t...@shatalmic.com> wrote:

> I have read several posting on this same thing and tried all of the
> suggestions.
>
> I am able to discover and connect to my BTLE device (it is actually an iOS
> device).
>
> My Android device is 4.4 and has BTLE.
>
> After I connect and get all the services and characteristics I try to read
> the one I am using and it works fine. If I update the value on the iOS
> device and do another read I get the new value as I would expect.
>
> I use this code:
>
> protected static final UUID
> CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString(
> "00002902-0000-1000-8000-00805f9b34fb");
> if (gatt.setCharacteristicNotification(characteristic, true)) {
>
> BluetoothGattDescriptor descriptor =
> characteristic.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);
> if (descriptor != null) {
>
> descriptor.setValue(enabled ?
> BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE :
> BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
> if (gatt.writeDescriptor(descriptor)) {
> // success
> }
> else {
> // failed
> }
> }
> }
>
> It reaches the // success line so it seems to be doing what I want I just
> never get the notifications. I know that this characteristic I am trying to
> subscribe to has the notification flag set on it. I do that in the iOS
> application. Unless something is going wrong there I guess.
>
> How can I debug this to figure out what is going on? Should I get
> something in the onDescriptor callback maybe? Where do I look and how do I
> diagnose?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/qwALaq3SwuQ/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to