Android BLE 4.3 onDescriptorWrite returns status 128 on enabling characteristics notification

本文探讨了使用Android BLE 4.3版本时遇到的问题:尽管已启用特性通知,但未收到BLE设备的通知。作者尝试了多种方法仍未解决问题,并在写入特定UUID的描述符时遇到了状态128和133的错误。最终发现,对于需要指示而非通知的特性,应使用ENABLE_INDICATION_VALUE而非ENABLE_NOTIFICATION_VALUE。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

question:

A question on enabling characteristics using the new android BLE 4.3:

I am not getting any notification from the BLE device though I enable notification on characteristics one by one asynchronously using a queue. 

I also write the descriptor with UUID "00002902-0000-1000-8000-00805f9b34fb" with ENABLE_NOTIFICATION_VALUE. 

I have followed the recommendation from Google sdk doc and as well suggestions from various forums. 

By the way I get status = 128 on "onDescriptorWrite". Any idea as what this status means?

I went thru google code and did not see any info on this. Even the source code does not throw any light as how this status is being set. 

Let me know if any of you have experienced this when you enabled notifications for the body media device. Also at times I get status 133 on descriptor write. I use latest Nexus 7 for my tests.

answer:

A very late answer, but this might prove valuable to anyone encountering status 128 (GATT_NO_RESOURCES) on a gatt.writedescriptor() call.

In my case status 128 showed up when trying to write a descriptor with a value of ENABLE_NOTIFICATION_VALUE for a characteristic that required a subscription for an indication via ENABLE_INDICATION_VALUE instead.

So instead of

BluetoothGattDescriptor descriptor = bluetoothGattCharacteristic.getDescriptor(DESCRIPTOR_UUID);
descriptor.setValue(ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);

going for

BluetoothGattDescriptor descriptor = bluetoothGattCharacteristic.getDescriptor(DESCRIPTOR_UUID);
descriptor.setValue(ENABLE_INDICATION_VALUE);
mGatt.writeDescriptor(descriptor);

Fixed the problem. I assume the other way around will produce the same error status 128.

转载于:https://my.oschina.net/dccjll/blog/1540260

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值