how event packet header is getiing in hci_send_req api implementation?

蓝咒 提交于 2021-02-07 10:15:38

问题


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.


回答1:


HCI Event Packets: the Host Controller notifies the HCI Driver of events:

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.

So first octet is for Packet indicator that is 0x04 for event packet.

for command packet - 0x01 (for UART interface)
for ACL data packet - 0x02 (for UART interface)
for SCO data packet - 0x03 (for UART interface)



来源:https://stackoverflow.com/questions/34202216/how-event-packet-header-is-getiing-in-hci-send-req-api-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!