linux - 事件包头如何进入 hci_send_req api 实现?

标签 linux bluetooth bluez hci

您好,我正在 hci.c 文件中执行 hci_send_req。在向 Controller 发送 hci 命令后的这个函数中。 Controller 发送事件数据包。通过 read(dd, buf, sizeof(buf)) (dd 是 hci 套接字描述符) 读取缓冲区中的事件包后,现在我们需要事件包头并获取事件包头,buf 被筛选1个字节。为什么??

hdr = (void *) (buf + 1); (line number 1049 of hci.c)

请告诉我这件事。谢谢。

最佳答案

HCI 事件数据包:主机 Controller 通知 HCI 驱动程序事件:

Packet indicator (for UART interfaces) of 4.
事件码(8位):标识事件。
参数长度(8位):所有参数的总长度,以字节为单位。
事件参数:参数的数量和长度是特定于事件的。

因此第一个八位字节用于数据包指示符,即事件数据包的 0x04。

命令包 - 0x01(UART接口(interface))
对于 ACL 数据包 - 0x02(对于 UART 接口(interface))
对于 SCO 数据包 - 0x03(对于 UART 接口(interface))

关于linux - 事件包头如何进入 hci_send_req api 实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34202216/

相关文章:

c# - 如何将 intelliJ 键绑定(bind)导入 Linux 上的 MonoDevelop?

android - 在 iOS 和 Android 上唯一标识 Beacon

bluetooth - 为什么暴露服务的总是GATT服务器呢?

java - 在 Android 中通过蓝牙接收数据

python - 我在哪里可以找到 PyBluez API

linux - Tizen 支持哪个 BT 堆栈?

linux - 如何读/写 hci_le_create_conn 返回的句柄?

objective-c - 在 clang 编译期间无法找到 objc.h

c++ - 制作C++脚本的问题

python - Shutil.copy 只能运行一次