当前位置:网站首页>Ble link layer air packet format
Ble link layer air packet format
2022-06-09 21:54:00 【jim0506】
Air package format
BLE The air packet format of link layer is very simple , All its air packages follow the format shown in the figure below :

The picture above shows ,BLE Air bag by 4 Component composition , They are :
- Lead code (Preamble)
- Access address (Access Address)
- Protocol data unit (Protocol Data Unit)
- CRC
The preamble occupies 1 Bytes , The visiting address accounts for 4 Bytes ,PDU Occupy 2 To 257 Bytes ,CRC Occupy 3 Bytes , The size of a complete air bag is 10 Byte to 265 Between bytes
LSB(The Least Significant) Represents the least significant bit ;MSB(The Most Significant) Represents the most significant bit . The least significant bit is first sent to the air by the link layer , The most significant bit is sent last . In other words, the preamble is sent out first , The second is the access address , Again PDU, The last is CRC
Lead code (Preamble)
The preamble occupies 8 A bit , In all broadcast channels , The preamble of the air bag is 10101010b; In the data channel , The preamble of the air package is 10101010b Or is it 01010101
If you look at the level , The preamble is actually a high-low rectangular wave , The receiver can synchronize the frequency of the receiving circuit to the frequency of the rectangular wave , This is the so-called receiver frequency synchronization mechanism . In layman's terms , The receiver can estimate the starting position of a bit and the width of a bit , Thus, each significant bit can be received accurately .
meanwhile , The preamble marks the beginning of a valid air packet , Avoid the interference of invalid data in the air .
Access address (Access Address)
The access address in the broadcast channel is different from that in the data channel . The access address of broadcast channel is fixed as 0x8E89BED6; The access address of the data channel is determined by the initiator . So the simple understanding is , From the access address, we can first distinguish , Is the air packet a broadcast packet or a connected packet .
As mentioned above, the preamble of the data channel is 10101010b Or is it 01010101b, Actually, it depends on the least significant bit of the access address in the data channel 0 still 1, If it is 1, Then the preamble is 01010101b, It is 10101010b
When the initiator makes a connection request to the broadcaster , It puts the value of the access address into the corresponding field of the connection request , When the link layer connection is successfully established , Both sides are in the connected state , Later, both sides of the air package use this access address for communication .
thus it can be seen , The access address is also bound to a specific link layer connection . for example , A link layer connection is established between a device and multiple devices , In other words, a device maintains multiple links at the same time , When the device receives an air bag , It only needs to access the address to know which connection the air package is .
Protocol data unit (Protocol Data Unit)
The protocol data unit is the payload part of the air package , Different types of air bags , its PDU Are different , It can be roughly divided into broadcast channels PDU And data channel PDU
BLE Using frequency hopping mechanism , The link layer has 40 Channels , among 3 The first channel is the broadcast channel , in addition 37 The first channel is the data channel
When the device is in broadcasting or initiating state , The device sends or receives a broadcast channel PDU; When a device establishes a link layer connection with another device , Both sides are in the connected state , They send or receive data from the channel PDU
Broadcast channel PDU
Broadcast channel PDU Its structure consists of two parts , Namely Header and Payload, As shown in the figure below :

It can be seen from the above figure ,Header The size is 16bits, That is to say 2 Bytes ,Payload Length from Header Medium Length Field decision , So first look at Header The composition of the fields , As shown in the figure below :

Header The field consists of the following 6 Component composition :
- PDU type : The type of broadcast packet
- RFU(Reserve For Future): Reserved for future use
- TxAdd: The address type of the sender
- RxAdd: Recipient address type
- Length:Payload Length of part
- RFU(Reserve For Future): Reserved for future use
The types of broadcast packets are shown in the following table :
| PDU Type | Packet Name |
|---|---|
| 0000 | Can be connected to non directional broadcast (ADV_IND) |
| 0001 | Can be connected to directional broadcast (ADV_DIRECT_IND) |
| 0010 | Can't connect to broadcast (ADV_NONCONN_IND) |
| 0011 | Scan request (SCAN_REQ) |
| 0100 | Scan response (SCAN_RSP) |
| 0101 | Connection request (CONNECT_REQ) |
| 0110 | Scannable indication (ADV_SCAN_IND) |
| 0111-1111 | Retain (Reserved) |
I will not introduce the types of each package , There will be a detailed introduction in the future blog
Data channels PDU
Data channels PDU contain 16 Bit head and a ⻓ Variable degrees payload, And maybe there's also a
MIC(Message Itegrity Check: Message integrity check ), Data channels PDU The format is shown in the figure below :

among Header The structure of is shown in the figure below :

Header Include 6 Parts of :
LLID:
2 Bytes , This bag is LL Data PDU( Link layer packets ) still LL Control PDU( Link layer control packet ), Its possible values are as follows :
- 00b: Retain
- 01b:LL Data PDU( Link layer packets ) Or a Empty PDU( Empty bag ). If it's a link layer packet , Because of a long L2CAP Packets will be divided into multiple packets and sent separately , This package is not the first one after it is partitioned
- 10b:LL Data PDU( Link layer packets ), It represents a complete packet that is not fragmented , Or the first partition package after partition .
- 11b: yes LL Control PDU( Link layer control packet )
NESN:
The serial number of the next package
SN:
The serial number of the air bag
MD:
More Data It means , because BLE It's low power Bluetooth , It's essentially a sleep wake-up mechanism , Sending and receiving air packets while awake , If MD Field set to 1, It means that the sender has more air packets to send in the future , To inform the recipient not to go to sleep , Keep the data going ; If the field is set to 0, The sender has no more data to send , It's time to go to sleep .
CRC
CRC It's about PDU Partial data integrity verification
边栏推荐
- spider pi 智能视觉六足机器人 开箱介绍 0602
- MediaTek: the market demand will not disappear, and the compound annual growth rate of revenue in the next three years will exceed 14%
- PaddleNLP通用信息抽取技术UIE【一】产业应用实例:信息抽取{实体关系抽取、中文分词、精准实体标。情感分析等}、文本纠错、问答系统、闲聊机器人、定制训练
- Thinking of finding the k-th largest element in O (n) by fast sorting
- 剑指offer1-32题思路
- js 强制类型转换 和 隐式类型转换 和 Unicode编码
- [code audit] Buu_ [GWCTF 2019]mypassword
- How image search works in Dropbox
- Laravel8 use when search
- Understand go modules' go Mod and go sum
猜你喜欢

Spider PI intelligent vision hexapod robot patrol function 0603

Pycharm进入debug模式后一直显示collecting data解决方法

SPIDER Pi Intelligent Vision hexapode Robot VNC Connect Robot 0603

Scratch Programming flying birds Development Notes 0604

js基本数据类型和引用数据类型

Save and copy drawings with minimal white space

易买网开发 趣买买 数据库的导入与数据库结构一览表 0605

spider pi 智能视觉六足机器人 标签识别 ApirlTag标签 0604

浅谈倍增法求解LCA

Design of spectrum analyzer based on nexys3 VHDL board
随机推荐
线程池
How to search for keywords in Oracle tables?
Yolo series target detection post-processing - non maximum suppression
Embedded software design (interim summary)
快递单信息抽取【三】--五条标注数据提高准确率,仅需五条标注样本,快速完成快递单信息任务
First encounter with Kunpeng code migration tool
logrotate
An RS485 serial interface current sensor snap on type mutual inductor supports Modbus communication protocol
Do your filial duty to make an old people's fall prevention alarm system for your family
MySQL exception: the server time zone value 'xxx' solution
swagger上的model和返回的数据字段不一致的问题
Best practices and principles of lean product development system
Huawei announced the establishment of three corps and two system departments, and has established 20 Corps in total
Alternative scheme for electric energy acquisition terminal of Langer ffc3 watt hour meter (DLMS infrared photoelectric collector)
The difference between CompareTo and compare
PHP uses unlink to delete the file prompt without permission
List of resources of yimai.com development interest buying project 0605
通过快排O(n)内查找第K大元素思路
MFC connection database shows no data source name found and no default driver specified
Paddlenlp general information extraction technology UIE [i] industrial application examples: information extraction {entity relationship extraction, Chinese word segmentation, accurate entity markers,