13.BLE---HCI

Source: Internet
Author: User

Dsads

1. Overview

HCI supports four types of grouping:

    • Command group commands Packet
    • Asynchronous data grouping asynchronous Packet
    • Synchronous Data Packet
    • Events Group Event Packe

The grouping type is a byte value before the HCI group. The packet type has the following values:

Packet

Packet Type

command

1

asynchronous Data

2

synchronous Data

3

Event

4

HCI Packet Types

2.Command Packet

The HCI command package format consists of three parts: the opcode (2 bytes), the parameter length (1 bytes), and the command parameters used to confirm the command being sent. Each command has its own set of unique parameters.
There are three basic command types in ble, each of which implements the following functions:

    • Configuring Controller Status
    • Request to perform a specific action
    • Manage Connections

3.Asynchronous Data Packet
    • A packet is an application data transmitted between a host and a controller.
    • The controller receives the packet from the host and passes it to the peer device.
    • After the peer device receives the data, it is sent from the controller to the host.
      The HCI packet format contains a handle/tag (2 bytes), data Length (1 bytes), and data. The HCI packet has two types of tokens: a packet boundary tag and a broadcast token. The packet boundary tag is used to confirm that the information of the upper layer protocol L2cap is a start packet or a continuation package. Similar to the llid in a link-layer data channel PDU.
      Packets sent from the host to the controller, tag 00 identifies the start packet, and 01 identifies the continuation package;
      Packets sent from the controller to the host, Tag 10 identifies the start packet, and the 01 tag continuation package.

4.Synchronous Data Packet

This synchronous data packet are not used in BLE.

5.Event Packe

The HCI event packet is encoded by the event type (1 bytes), the parameter length (1 bytes), and the command parameters. Each time has its own set of unique parameters.
BLE has three basic types of events:

    • Common Command Completion events: tasks unrelated to wireless transport
    • Common Command Status Events
    • Specific command Completion events

6. Command flow control
    • The HCI interface has two types of flow control: command flow control and data flow control.
    • The controller uses command flow to process multiple HCI commands at the same time. Because there is enough cache inside the controller to store a certain number of commands;
    • The host can learn the length of the buffer through the controller, thus knowing the maximum number of commands that can be sent at the same time.
    • The HCI interface does not support event streaming because the number of events is limited by the number of commands that can be processed, and the host has more resources than the controller and is able to buffer and process these events in sequence.
7. Data Flow Control
    • A total of two data streams: host to controller and controller to host.
    • Host-to-controller data flow control is required, and controller-to-host data flow control can be ignored.
    • For host-to-controller data flow control, the controller has a certain number of buffers, each of which holds one packet.
    • Each time the controller extracts a packet from a buffer to the peer device, once the packet is sent successfully, the controller releases the buffer, filling the host with new packets sent to the controller.
8. Controller configuration

8.1 Reset the controller to a known state

    • The controller may be performing other operations, or the host transfer is just being established. In this case, you can reset the controller to the ready state, which restores all the configurable parameters to the default values.
    • The host resets the controller by resetting the Reset command. Once the controller is reset, the command complete event is returned to the host.
    • Resetting the command does not reset the physical link, and if you want to reset the physical link, you need to perform an additional link reset operation.
    • Although the host can send multiple commands to the controller, it cannot accept other commands if the controller is performing a reset.
    • The reset command can preempt execution of other commands.
8.2 Read Device Address

    • The host reads the device address by sending the read BD_ADDR command to the controller.
    • The latter returns a command complete event that contains a fixed device address.
    • If the controller does not have a fixed address, the full 0 address 00:00:00:00:00:00 is returned. At this point, the host needs to generate a random address for the controller, otherwise the data can not be transferred.
8.3 Setting the event mask

    • By setting the event mask, the host tells the controller which events can be received and which cannot be received. This allows the controller to send only those events that can be received.
    • The Set event Mask command was used for classic Bluetooth settings for various events, since the "Meta-event" event still applies to low-power Bluetooth, which the host can use to start or block meta-event.
    • In addition, the Le Set Event mask command is used to start or block related low-power Bluetooth events.
8.4 Read Buffer size

LE Read Buffer Size
Read Buffer Size

8.5 read the features supported by the Controller

13.BLE---HCI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.