abh*_*ora 8 linux bluetooth hci kernel-module bluez
我正在使用QN9021SoC controller mode(BLE蓝牙核心规范v4.0).它支持一些标准HCI命令以及一些供应商特定命令.我想把它贴在我的ubuntu笔记本电脑上.
我使用的命令是hciattach.
hciattach -s 9600 /dev/ttyUSBx any 9600 noflow nosleep
Run Code Online (Sandbox Code Playgroud)
hcidump执行时的节目sudo hciconfig hci1 up.
HCI sniffer - Bluetooth packet analyzer ver 5.37
device: hci1 snap_len: 1500 filter: 0xffffffffffffffff
> HCI Event: Command Complete (0x0e) plen 12
Read Local Supported Features (0x04|0x0003) ncmd 11
status 0x00
Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> HCI Event: Command Complete (0x0e) plen 12
Read Local Version Information (0x04|0x0001) ncmd 11
status 0x00
HCI Version: 4.0 (0x6) HCI Revision: 0x400
LMP Version: 4.0 (0x6) LMP Subversion: 0x400
Manufacturer: Quintic Corp. (142)
> HCI Event: Command Complete (0x0e) plen 10
Read BD ADDR (0x04|0x0009) ncmd 11
status 0x00 bdaddr 08:7C:BE:3E:34:BB
> HCI Event: Command Complete (0x0e) plen 11
Read Buffer Size (0x04|0x0005) ncmd 11
status 0x00
ACL MTU 0:0 SCO MTU 0:0
> HCI Event: Command Complete (0x0e) plen 4
Read Class of Device (0x03|0x0023) ncmd 11
status 0x01 class 0x000000
Error: Unknown HCI Command
Run Code Online (Sandbox Code Playgroud)
该hciconfig命令显示:
hci1: Type: BR/EDR Bus: UART
BD Address: 08:7C:BE:3E:34:BB ACL MTU: 0:0 SCO MTU: 0:0
DOWN
RX bytes:192 acl:0 sco:0 events:15 errors:0
TX bytes:60 acl:0 sco:0 commands:15 errors:0
hci0: Type: BR/EDR Bus: USB
BD Address: C4:8E:8F:66:3B:0E ACL MTU: 820:8 SCO MTU: 255:16
UP RUNNING PSCAN
RX bytes:2457 acl:0 sco:0 events:196 errors:0
TX bytes:24646 acl:0 sco:0 commands:196 errors:0
Run Code Online (Sandbox Code Playgroud)
我想知道如何防止内核或某些蓝牙内核模块发送不支持的HCI命令.我是否需要修补Linux内核源代码或为我的SoC编写模块.
注意: - 此项目无法更改SoC或为其编写固件以支持所有必需的命令.
编辑:
我知道HCI我的SoC支持的命令列表.我正在考虑创建一个module告诉内核和守护进程运行只向SoC发送支持的命令.我看一下linux内核源代码(特别是在这个hci_core.c).我认为修改它可能会在通过此链接后解决问题.在这个链接中,一些开发人员提供了一个补丁来支持bluetooth dongle.该补丁防止hci_core.c文件将特定的HCI命令发送到特定制造商的加密狗.
我想要的只是建议解决这个问题.我是否需要修改linux内核或为我的SoC编写模块?
注意: - 应用程序将在openwrtLinux上运行.
好的,今天我们找到了解决方案:
# hciattach -r /dev/ttyS0 bcsp 115200
Run Code Online (Sandbox Code Playgroud)
也许它可以帮助某人
有用的提示:愿此链接对您有所帮助。
几年前我已经解决了这个问题。我使用的是 Linux 版本4.4.14和 Bluez stack 5.38。看起来QN9021有一些错误。问题不在于命令Read Class of Device给出的响应,而在于: 。由于它是 BLE 控制器芯片,因此不应将其作为对上述命令的响应进行发送。QN9021Read Local Supported FeaturesFeatures: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
问题是内核将其检测为经典蓝牙控制器芯片,然后向芯片发送不支持的 HCI 命令。芯片应将第 4 个字节的第 5 位和第 6 位( LMP_NO_BREDR和LMP_LEFeatures位)设置为命令Read Local Supported Features,然后内核将其检测为BLE控制器模式芯片,并且不会向 ble 控制器模式芯片发送任何不支持的命令。
由于我无法更改芯片的固件,因此我必须修补内核。
这是我的补丁:
*** hci_event.c 2017-02-10 00:05:13.149974000 +0530
--- bluetooth/hci_event.c 2016-06-24 22:48:38.000000000 +0530
***************
*** 588,597 ****
if (rp->status)
return;
-
memcpy(hdev->features, rp->features, 8);
- hdev->features[0][4] |= LMP_NO_BREDR;
- hdev->features[0][4] |= LMP_LE;
/* Adjust default settings according to features
* supported by device. */
--- 588,594 ----
Run Code Online (Sandbox Code Playgroud)
我也厌倦了以下命令,但它没有帮助:
hciattach -r /dev/ttyS0 bcsp 115200
Run Code Online (Sandbox Code Playgroud)