问题
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