如何在 Linux 中使用命令行工具 (hciconfig/bluetoothctl) 获取/设置蓝牙 MTU 值

问题描述

我正在开发一个嵌入式 Linux 设备作为与 Android 应用程序通信的 BLE 外设。

我从 github 项目 python-gatt-server 开始。

现在有一些吞吐量瓶颈,我怀疑这与 MTU 设置有关。

hciconfig输出如下:

root@linux:~# hciconfig
hci0:   Type: Primary  Bus: UART
        BD Address: C0:EE:40:3B:31:A0  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN ISCAN 
        RX bytes:1392 acl:0 sco:0 events:78 errors:0
        TX bytes:1752 acl:0 sco:0 commands:78 errors:0
  1. 有 2 个 MTU 设置:ACL MTU: 1021:8SCO MTU: 64:1,它们分别是什么意思?
  2. 听说不同的芯片组支持不同的 MTU 设置。如何找到这些值?
  3. 如何使用 hciconfigbluetoothctl 等命令行工具设置 MTU?

解决方法

您可以使用 gatttool 更改 MTU 值。您需要使用 gatttool -I 命令。然后连接您的设备。您可以使用帮助命令。 MTU 1234 可以工作