Low-power Bluetooth BLE traditional broadcast summary

Low-power Bluetooth BLE traditional broadcast summary

Low-power Bluetooth: Bluetooth Low Energy abbreviated BLE, compared to traditional Bluetooth BT has a low power, low cost, small size and other advantages, BLE and BT are working on worldwide public common 2.4GHz wireless band, but they They are two completely different technology, but the Bluetooth SIG Bluetooth SIG be classified under the category of so called BLE technology.

Bluetooth chips today, there are two different modes: single-mode, dual-mode

  • Single-mode: Bluetooth chip only supports BT BLE or one of the functions, but common market for the single-mode BLE chips majority

  • Dual-mode: Bluetooth chip two functions are supported, in general such as mobile phones Bluetooth, PC and other Bluetooth

This article, we will focus on talk radio to the BLE, which is the basis BLE function began.

BLE Broadcasting classification:
Here Insert Picture Description

  • Directed Broadcast: can not be scanned, the device can only be connected to a specific address BLE Bluetooth

  • High and low duty cycle: a radio broadcast cycle is time consuming and high duty cycle, otherwise low duty cycle

  • When using the extended broadcast, the broadcast can not be connected to be scanned broadcast

  • When using the extended broadcast, it can be connected not only to scan the directed broadcast low duty cycle
    Here Insert Picture Description

Due to the extended broadcast is limited by the chip support (Bluetooth protocol 5.x support), so we are going to explain in a conventional broadcast broadcast process of BLE.

BLE broadcast process comprises four steps: setting parameters of a broadcast, the broadcast data set, set the scan response data, enabling the broadcasting, we will be described separately.

Step 1: Set broadcast parameter
Here Insert Picture Description

The latest version of the Bluetooth protocol "Core_v5.2.pdf" be aware of the parameters part of the HCI commands a total of 15 bytes. Android is AdvertiseSettings or AdvertisingSetParameters corresponding parameters, these two classes can be expressed broadcast parameters, but contains more content AdvertisingSetParameters also use the extended broadcast, that is, if you want to enable an extended broadcast, the only parameter AdvertisingSetParameters can use to organize.

AdvertiseSettings tissue parameters, need to focus on the following data:
Here Insert Picture Description

AdvertisingSetParameters tissue parameters, need to focus on the following parameters:
Here Insert Picture Description

AdvertiseSettings parameters used BluetoothLeAdvertiser.startAdvertising () will be re-organized into AdvertisingSetParameters parameter JNI layer will eventually be converted into the HCI command parameters required.

Step 2: Set the broadcast data

Data is broadcast comes when foreign broadcasting-related data, which requires the application layer and wanted to take the initiative to set up broadcast data.
Here Insert Picture Description

As can be seen from the predetermined protocol broadcast data length is set to 31 bytes, the application layer data need to be considered when setting the broadcast data length, otherwise excessive length of the data it is unable to go.
Here Insert Picture Description

Step 3: Set the reply data scans

When a scanner scans the broadcast data of the need to respond to the scanner. The composition and the same data broadcast data, the data length is limited to 31 bytes.
Here Insert Picture Description

Step 4: Broadcast Enable

After the first three steps related parameters successful start broadcasting.
Here Insert Picture Description

Here, BLE traditional broadcast was enabled up, let's turn to the timing chart to learn more about the next broadcast of the relevant processes:
Here Insert Picture Description

From the above timing diagram can be seen in the upper layer application you want to call BluetoothLeAdvertiser only after the relevant data structure. StartAdvertising () interface to begin broadcasting, enabling broadcast underlying success tells the application by the callback method.

But there are two kinds of application layer disposed broadcast callback method:

  1. BluetoothLeAdvertiser.startAdvertising (): Use callback AdvertiseCallback, so the callback to the application of information only broadcast parameters AdvertiseSettings original settings. The advantage is simple, the disadvantage is change the radio parameters and other data required to stop broadcasting, re-broadcasting began calling API.

  2. BluetoothLeAdvertiser.startAdvertisingSet (): callbacks AdvertisingSetCallback, there is an important parameter to AdvertisingSet this callback application, the application can be operated by such current broadcast, many methods such as start broadcasting , turn the radio , reset broadcast parameters , reset the broadcast data , the reset scan reply broadcast data , obtaining the address used for broadcast and so a single operation, all the data need not be sent together at the bottom Controller, thus can more easily control the broadcast of the application layer.

Andrews native Bluetooth protocol stack when the enable broadcast, some of the broadcast parameters are fixed, as follows:
Here Insert Picture Description

Broadcast data and scan format reply data will be more complicated, but also the relevant provisions. Data format as shown below:
Here Insert Picture Description

A broadcast data AD Structure by a series configuration, each of which is configured longitudinal length (one byte) plus composition data Data, and Data is composed of AD Type + AD Data, AD Type definition has been specified in the protocol well, interested can view the contents of self-assigned-numbers of generic-access-profile protocol defined in the Bluetooth official website. Andrews source AD ​​Type type commonly used as follows:

    private static final int COMPLETE_LIST_16_BIT_SERVICE_UUIDS = 0X03;

    private static final int COMPLETE_LIST_32_BIT_SERVICE_UUIDS = 0X05;

    private static final int COMPLETE_LIST_128_BIT_SERVICE_UUIDS = 0X07;

    private static final int SHORTENED_LOCAL_NAME = 0X08;

    private static final int COMPLETE_LOCAL_NAME = 0X09;

    private static final int TX_POWER_LEVEL = 0x0A;

    private static final int SERVICE_DATA_16_BIT_UUID = 0X16;

    private static final int SERVICE_DATA_32_BIT_UUID = 0X20;

    private static final int SERVICE_DATA_128_BIT_UUID = 0X21;

    private static final int MANUFACTURER_SPECIFIC_DATA = 0XFF;

Protocol can know from the AD Type occupies one byte, so the actual length of the data AD Data byte length-1.

BLE traditional broadcast we analyze here, welcome partners interested in small private letter message discussion.

More interoperability technology, welcomed the focus on micro-channel public number: Connectivity
Here Insert Picture Description

Published 15 original articles · won praise 6 · views 1226

Guess you like

Origin blog.csdn.net/weixin_44260005/article/details/105121053