问题描述
我正在hci.c文件中通过hci_send_req实现.向控制器发送hci命令后,在此功能中.控制器发送事件包.通过 read(dd,buf,sizeof(buf))(dd是hci套接字描述符)
读取缓冲区中的事件包后,现在我们需要事件包头并获取事件包头,将buf筛选为1个字节.为什么?
Hi I am going through hci_send_req implementation in hci.c file. in this function after sending hci command to controller . Controller send event packet. After reading event packet in buffer by read(dd, buf, sizeof(buf)) (dd is hci socket descriptor)
, now we need event packet header and to get event packet header, buf is sifted by 1 byte. why??
hdr = (void *) (buf + 1); (line number 1049 of hci.c)
请让我知道这一点.谢谢.
Please let me know about this. Thanks.
推荐答案
HCI事件数据包:主机控制器将事件通知HCI驱动程序:
HCI Event Packets: the Host Controller notifies the HCI Driver of events:
数据包指示器(用于UART接口)为4.
事件代码(8位):标识事件.
参数长度(8位):所有参数的总长度(以字节为单位).
事件参数:参数的数量和长度取决于事件.
Packet indicator (for UART interfaces) of 4.
Event code (8 bits): identifies the event.
Parameter length (8-bit): total length of all parameters in bytes.
Event parameters: the number of parameters and their length is event specific.
因此第一个八位字节用于数据包指示符,对于事件数据包为0x04.
用于命令包-0x01(用于UART接口)
用于ACL数据包-0x02(用于UART接口)
用于SCO数据包-0x03(用于UART接口)
for command packet - 0x01 (for UART interface)
for ACL data packet - 0x02 (for UART interface)
for SCO data packet - 0x03 (for UART interface)
这篇关于hci_send_req api实现中如何获取事件数据包头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!