gpt4 book ai didi

Android Ble MTU 大小

转载 作者:行者123 更新时间:2023-12-04 23:47:28 26 4
gpt4 key购买 nike

我用 BluetoothGatt.requestMtu(512)在我的安卓应用程序中。
第一次效果很好
但是在 Mtu 自动更改为 23 之后(默认)
我不知道是什么问题...
这是一个日志

`D/BluetoothGatt: setCharacteristicNotification() - uuid: 0000fff1-0000-1000-8000-00805f9b34fb enable: true
D/BluetoothGatt: configureMTU() - device: 74:F0:7D:C0:CB:68 mtu: 512
D/BluetoothGatt: onConfigureMTU() - Device=74:F0:7D:C0:CB:68 mtu=23 status=0
D/BluetoothGatt: discoverServices() - device: 74:F0:7D:C0:CB:68
D/BluetoothGatt: onSearchComplete() = Device=74:F0:7D:C0:CB:68 Status=0
I/gattSuccess: gattSuccess`
这是在 onMtuChanged() 所以它工作无限循环

最佳答案

正如 M. Kotzjan 所指出的,这与其他设备支持的 MTU 有关。来自蓝牙规范 v5.2,第 3 卷,G 部分,第 4.3.1 节(交换 MTU):-

This sub-procedure is used by the client to set the ATT_MTU to themaximum possible value that can be supported by both devices when theclient supports a value greater than the default ATT_MTU for theAttribute protocol. This sub- procedure shall only be initiated onceduring a connection.


换句话说,如果您请求 MTU 为 512,而远程设备回复 23(最小 MTU 值),则连接的 MTU 将为 23。如果您请求 512,远程设备回复 100,则连接的 MTU 将为 100 . 如果您请求 200,而远程设备回复 512,则连接的 MTU 将为 200。
请查看以下链接以获取更多信息:-
  • Maximising BLE Throughput Using Larger MTU
  • The Ultimate Guide to Android BLE
  • 关于Android Ble MTU 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65883084/

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