HCI layer of the Bluetooth protocol stack (chapter 1)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/madannasf/article/details/102738510

About HCI

HCI (host communication interface) host communications port, it is mainly for the upper layer provides a unified communications port, which is mainly used to transfer commands and time. Probably the diagram below,
Here Insert Picture Description
Host (user app) controls Bluetooth communications protocol to send commands are defined to control the Bluetooth into work mode response will be returned as an event to inform the host Bluetooth after treatment.

A protocol data format

HCI transport data format There are four types, respectively, for the command, acl, sco event and corresponding data in the protocol type, respectively,
Command (0x01)
ACL (0x02)
SCO (0x03)
Event (0x04)

1.1、command pocket

command pocket data format below, you can also read the Bluetooth protocol stack of documents to understand.
Here Insert Picture Description
He opcode for the command operation, and the ocf ogf composition.

1.2、ACL Data pocket

acl mainly used for master-slave asynchronous exchange of data between devices, such as music, our l2cap is using this mode. Protocol data packet format is as follows,
Here Insert Picture Description
handle represents the handle of the current communication channel, PB Flag (packet boundary flag) may be represented by the received packet layer.
Here Insert Picture Description

1.3、SCO Data Packet

SCO is mainly used for transmission of isochronous data between the ble and the host, the packet format is as follows,
Here Insert Picture Description
as described above, handle, PSF follows,
Here Insert Picture Description

1.4、Event Packet

The main event is to inform the host device be in the following format when an event occurs.
Here Insert Picture Description

Second, the command and the time introduction

Bluetooth protocol stack, the command and too many events, here we only list what a few common command and events

2.1 reset command

2.1.1, host transmitting portion:

00000010 00000010 00100000 00000110 00000000 00000010 00000000 01000001 00000001 00000000 00000001 00000001 00000011 00001100 00000000

Command:00000001(0x01)

Opcode: 00000011 00001100 (ogf: 000011 (0x03), ocf: 0000000011 (0x03)) The table lookup apparent to OGF and reset instruction ocf

2.1.2, below response receiving device,

00000100 00001110 00000100 00000001 00000011 00001100 00000000

Event:00000100(0x04)

Event code: 00001110 (0x0e, command completion command)

Paramter total length: 00000100 (parameter length is 4)

Num hci command packet: 00000001 (indicates that th host controller 1 may also receive instructions)

Opcode: 00000011 00001100 (ogf: 000011 (0x03), ocf: 0000000011 (0x03)) is specified reset command reply, this value must be the same transmitting section

Status: 00000000 (zero is successful, the other for failure, with particular reference to the failure code)

Guess you like

Origin blog.csdn.net/madannasf/article/details/102738510