Introduction to BLE knowledge

Official documentation and reference documentation

  1. specifications
  2. assigned-numbers
  3. 00_Basic knowledge of Bluetooth Low Energy BLE
  4. Bluetooth technology summary
  5. A brief discussion on knowledge related to BLE low-power Bluetooth technology

1. Bluetooth transmission frequency band

Bluetooth low energy has a total of 40 channels, with the frequency band ranging from 2402MHz to 2480MHz, of which 37, 38, and 39 are broadcast channels, and the rest are data channels.
ble-adv-channel

Why choose 37, 38, and 39 as broadcast channels?

We can take a look at the WiFi transmission channel. This design may be to avoid interference from the WiFi transmission channel to the greatest extent and affect broadcast scanning pairing. After successful pairing, Bluetooth transmission supports the channel hop function for anti-interference.
wifi-channel

Why is it the 2.4G frequency band?

The 2.4GHz frequency belongs to the ISM (Industrial, Scientific and Medical Equipment) frequency, which can be used without permission from the authorities and is used worldwide.

2. Bluetooth broadcast data

The length of the Bluetooth broadcast packet is 37 bytes, of which the first 6 bytes are fixed as the Mac address, and the remaining 31 bytes are defined according to the actual situation.
adv-data-struct
Length = 1 + N

Let’s look at a specific example. The following are two structures of a broadcast packet. The first one occupies 5 bytes, the second one occupies 4 bytes, and the remaining 31 bytes are filled with zeros.

ad-structure1

Now that we know how broadcast data structures are organized, let’s take a look at how to interpret these data structures. We can view the complete broadcast type definition in the Assigned Numbers document provided by the official specifications . Here are several commonly used type descriptions:
adv-usual-type

Many fields need to be queried in the official Bluetooth information. Here are a few common query addresses:

Type Description
Supplementary Description
Register Bluetooth Company Logo Query
Appearance Type Query

3. Bluetooth scanning, broadcast duration and scanning window

  1. scan refers to the central side scanning peripheral Bluetooth devices, and the scan interval (scan interval: 2.5ms ~ 10.24s) must be set. Advertising refers to the peripheral side broadcasting information, and the advertising interval needs to be set (broadcast period: 20ms ~ 10.24s)
  2. Scan interval: The time difference between the start times of two consecutive scan windows, including scan rest time and scan time.
  3. The longer the Interval time, the more power is saved, and vice versa, the more power is consumed.
  4. Set the Time out time to avoid product power consumption caused by long-term scanning or advertising.
  5. Scan window (scan window): the time width of a scan
    scan-adv-interval_window

4. Bluetooth broadcast classification and scanning

Bluetooth broadcast classification mainly starts from three dimensions:

  1. connectability: Connectable vs Non-connectable
  2. scannability: Scannable vs Non-scannable. Scannability means that the scanner can send scan request and the advertiser can send scan response data.
  3. Directability: Directed vs Undirected. Directed means specifying the address of the scanner. Other scanners cannot connect to it.
    Another dimension is discoverable, which is divided into non-discoverable vs discoverable (general or limited). Non-discoverable can be understood, but it is not discoverable. .
broadcast type use Connection support scan response
Connectable non-directed Commonly used ordinary broadcast methods yes support
connectable orientation Used for quick connection broadcast after pairing Specified devices can be connected not support
Not connectable non-directed Commonly used in beacons, sensors no not support
Can scan non-directional Based on 3, add the ability to scan responses to carry more data no support

Bluetooth advertising and scanning

The data formats of Bluetooth broadcast and scanning are the same. The difference is that broadcast is actively sent by the slave device, while scanning is sent by the slave device in response to the scan request of the host device. Sometimes the length of Bluetooth broadcast data exceeds 31 bytes, and we will feed other data back to the host device through scanning responses.
adv-scan

5. Bluetooth connection

During connection pairing, peripheral needs to provide four parameters to central:
. MIN_CONN_INTERVAL
. MAX_CONN_INTERVAL
. SALVE_LATENCY
. CONN_SUP_TIMEOUT

Central will refer to these four parameters and transmit the connect event to peripheral as the time to communicate with each other.
connect interval: standard bit 7.5ms~4s (IOS interval: 20ms~2s)
slave latency: In order to save peripheral power consumption, central can accept peripheral several times without returning.
supervision Timeout: Set how long it takes to interrupt the connection when no communication request is received.
connect-data-change

6. Bluetooth services and features

Bluetooth protocol block diagram
Bluetooth protocol block diagram

Bluetooth device services and feature relationships
Bluetooth device services and feature relationships

From the Bluetooth service and feature UUID,
UUID
you can see that the 128-bit uuid above is very long, but the uuid we see in actual use or in nrfconnect is not so long. This is because the Bluetooth Alliance organization provides a base address for convenience. Users You can modify 16bit based on the base address as the uuid you need.

base-uuid
In Bluetooth low energy, all data communication depends on the characteristics of each service, and is divided according to different types of characteristics such as readable, writable, and notification. Each attribute can be assigned to multiple different permissions at the same time.

service-char-permision

per-diff

7. 16bit UUID

The name corresponding to each UUID is defined in the data sheet.

8. SPP Agreement

Bluetooth serial port data transparent transmission.

Guess you like

Origin blog.csdn.net/guoxulieying/article/details/133124167