1. Introduction 1.1 link state machine link layer operations can be described as link state machines
The link state machine has the following five kinds of states
-Standby state: prepare, not transmit or receive packets-advertising state: broadcast, advertiser, send advertising channel packets, Accept response from Scanner-scanning state: monitor/scan, scanner, monitor advertising channel packets-initiating State from Advertiser: Initialize, initiator, listen for advertising channel packets from a special device, and initialize the connection-Connection state: connected, there are two roles: Master role ( Enter from initiator)/slave Role (entered from advertiser)
Link state machine only allowed in one of five states
The link layer can have multiple link state machines, but at least one of the advertising/scanning states is supported
A device in master role can communicate with multiple slave role ticks
Devices in slave role can only communicate with devices that are in master role
Shows the combination of allowed and forbidden link state machines and roles
1.2-bit sequence (bit ordering)
Specifies that the PACKET/PDU bit sequence is little Endian format in the link layer specification
LSB sent first
1.3 Device Address
The device address can be a public address or a random address, with a length of
-Public Address: 48-bit Universal LAN MAC addresses with IEEE 802-2001 standard
-Random Address: Detailed requirements can be referenced in the specification
1.4 Physical channel (physical channel)
The BLE RF channel is defined as two kinds: advertising and data
-Advertising channel: Use 3 RF channels to discover the device, initialize the connection and broadcast the data-the database channel: use up to 37 RF channels for communication between two connected devices
The corresponding relationship between the RF channel and the Advertising/data Channel index
2. BLE Packet2.1 Packet Format
For the BLE link layer, the Advertising/data Channel packet format is as follows
Packet length of 80~376bits (10~47byte)
-Preamble: Preamble for receiver synchronization frequency, etc.
Advertising channel packet-10101010b
Data channel packet-10101010b (LSB 0 in Access address) or 01010101b (the LSB for access address is 1)
-Access Address: Access addresses
Advertising channel Packet-0x8e89bed6
Data channel packet-each link-layer connection has its own unique value, generated randomly by initiator, and related restrictions can be found in the specification
-PDU: Protocol data unit with individual format requirements for advertising and data channel packet
-CRC: Calculated by PDU
2.2 RFU
Reserved for future use, left behind, set to 0, ignored after receiving
2.3 Advertising Channel PDU
The PDU format is as follows
The header section is formatted as follows
-PDU Type: Define PDU types
-Txadd/rxadd: Determined by the PDU type, if undefined, is considered RFU
-Length: Defines the number of bytes of payload (octets), the valid range is 6~37bytes
-Payload: Determined by PDU type
In Adv PDUs, advdata/scanrspdata refers to data from the host
2.3.1 Advertising PDUS
Advertising PDUs contains the following types
-Adv_ind: Indicates that you can be connected
Payload-adva (6 octets) + advdata (0~31 octets)
Adva Field Advertiser address (txadd=0 = Public address, txadd=1 for random address)
-Adv_direct_ind: Establishing a connection to a specific device
Payload-adva (6 octets) + Inita (6 octets)
Adva Field Advertiser address (txadd=0 = Public address, txadd=1 for random address)
Inita field Initiator (receiver) address (rxadd=0 means public address, rxadd=1 means random address)
-Adv_nonconn_ind: For broadcast information
Payload-adva (6 octets) + advdata (0~31 octets)
Adva Field Advertiser address (txadd=0 = Public address, txadd=1 for random address)
-Adv_scan_ind:scannable undirected Advertising Event
Payload-adva (6 octets) + advdata (0~31 octets)
Adva Field Advertiser address (txadd=0 = Public address, txadd=1 for random address)
These puds data flows to the Advertiser->scanner/initiator
2.3.2 Scanning PDUS
Scanning PDUs contains the following types
-Scan_req: Data flow to Scanner->advertiser
Payload-scana (6 octets) + Adva (6 octets)
Scana field Scanner Address (txadd=0 = Public address, txadd=1 for random address)
Adva Field Advertiser address (rxadd=0 = Public address, rxadd=1 for random address)
-SCAN_RSP: Data flow to Advertiser->scanner
Payload-adva (6 octets) + scanrspdata (0~31 octets)
Adva Field Advertiser address (txadd=0 = Public address, txadd=1 for random address)
2.3.3 Initiating PDUS
Initiating PDUs contains the following types
-Connect_req: Data flow to Initiator->advertiser
Payload-inita (6 octets) + Adva (6 octets) + lldata (octets)
Inita field Scanner Address (txadd=0 = Public address, txadd=1 for random address)
Adva Field Advertiser address (rxadd=0 = Public address, rxadd=1 for random address)
The Lldata fields are as follows, see the specification for more information
2.4 Data Channel PDU
The Data Channel PDU format is as follows
2.4.1 Header
The header section format and field meanings are as follows
2.4.2 Payload
The payload format is determined by the Llid field and has the following two types
-LL data PDU: Used to send l2cap data, llid to 01b/10b
-LL control PDU: Used to control link layer connections, please refer to the specification for more information
Payload-opcode (1 octet) + ctrdata (0~22 octets)
2.4.3 MIC
MIC (Message Integrity Check)
-Non-existent situation
~ In a non-encrypted connection
~ Encrypted connection, payload is empty
-Conditions of existence
~ Encrypted connection, payload not empty
3. Air Interface Protocol
Refer to the following section of the BLE specification
Low Engrgy Controller Volume
-Link Layer Specification
-AIR INTERFACE PROTOCOL
Bluetooth Low Energy link layer