android 蓝牙notify,Android Bluetooth LE - BluetoothGatt - onNotify stops receiving data

I am connecting to a Bluetooth LE peripheral as a central. I am writing data to a characteristic and I receive data through Notifications in chunks of 20 bytes.

Notification subscription:

private void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {

if (mBluetoothAdapter == null || mBluetoothGatt == null) {

Log.w("BluetoothAdapter not initialized");

return;

}

Log.d("Enabling Notifications");

mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);

BluetoothGattDescriptor descriptor =

characteristic.getDescriptor(UUID.fromString(CLIENT_CHARACTERISTIC_CONFIG));

descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);

mBluetoothGatt.writeDescriptor(descriptor);

}

This works fine if only small number of chunks need to be received between writes. The bluetooth stack sends notifications for each chunk:

D/BluetoothGatt﹕ onNotify() - Device=B0:EC:8F:00:07:AA UUID=06d1e5e7-79ad-4a71-8faa-373789f7d93c

But if the number of chunks between writes is bigger than about 10, the stack stops the notifications and the rest of the data is lost! The device is definitely sending more data, as we can receive it on iOS devices.

The number of received notifications varies between android devices. A Galaxy S3 (4.3) receives 5, a nexus 5 (4.4.4) and a htc one (4.4.2) receive 12.

The BT stack closes the connection 30 seconds after the last notification.

D/BluetoothGatt﹕ onClientConnectionState() - status=0 clientIf=5 device=B0:EC:8F:00:00:88

Can anybody reproduce this issue?

As the Bluetooth LE stack is polling based, I guess that the stack stops polling data from the peripheral for some reason. The target device does not support indications.

Update: Additional Information provided by the Android L bluetooths stack:

06-27 12:20:02.982 18909-18946/? D/BtGatt.GattService﹕ onNotify() - address=B0:EC:8F:00:01:09, charUuid=06d1e5e7-79ad-4a71-8faa-373789f7d93c, length=20

06-27 12:20:07.666 18909-18984/? E/BTLD﹕ ######################################################################

06-27 12:20:07.666 18909-18984/? E/BTLD﹕ #

06-27 12:20:07.666 18909-18984/? E/BTLD﹕ # WARNING : BTU HCI(id=0) command timeout. opcode=0xfd55

06-27 12:20:07.666 18909-18984/? E/BTLD﹕ #

06-27 12:20:07.666 18909-18984/? E/BTLD﹕ ######################################################################

06-27 12:20:07.670 18909-18984/? E/bt-btm﹕ can not interpret IRK VSC cmpl callback

06-27 12:20:07.670 18909-18984/? W/bt-hci﹕ HCI Cmd timeout counter 1

06-27 12:20:34.315 18909-18984/? E/bt-btm﹕ btm_sec_disconnected - Clearing Pending flag

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值