gpt4 book ai didi

android - 如果传入的数据包太多,则不会调用 onCharacteristicChanged() 回调

转载 作者:行者123 更新时间:2023-11-30 02:50:13 25 4
gpt4 key购买 nike

我等待 onCharacteristicChanged() 回调通过 BLE 接收数据。但是,如果 BluetoothDevice 一次发送太多 20 字节的数据包,我最多会收到 10 条通知,而不是预期的 46 条 907 字节长的消息。通知少量数据就好了。

在 onServicesDiscovered(BluetoothGatt gatt, int status) 中,我通过以下方式注册通知:

public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
mService = mGatt.getService(SERVICE_UUID);
mCharacteristic = mService.getCharacteristic(CHARACTERISTIC_UUID);
mGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor =
characteristic.getDescriptor(UUID.fromString(CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);
}
}

我是否必须以某种方式确认我在 onCharacteristicChanged() 中获得了数据?

BluetoothDevice 正在发送大于 20 字节的消息,方法是将它们分成 20 字节的 block 。通常这些消息小于 200 字节。但是,当 BluetoothDevice 发送的消息长度超过 900 个字节时,应用程序仅通过 onCharacteristicChanged() 收到其中 200 个字节的通知。

在 iOS 上可以很好地接收这些较大的消息。

最佳答案

BLE 堆栈目前有点损坏,存在一个关于太多数据包和读取多个特征的已知错误。根据主题演讲中的幻灯片,BT 堆栈将在 L 版本中得到极大改进(包括从模式和中心模式)

关于android - 如果传入的数据包太多,则不会调用 onCharacteristicChanged() 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24326997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com