BLE 包结构及传输速率
根據(jù)Bluetooth 4.0 BLE部分協(xié)議:
BLE中物理層physical layer的傳輸速率是1Mbps,除了這個外,數(shù)據(jù)傳輸速率與包大小、CPU處理時間相關。
包結構:
1.總體結構:
?
preamble(1 Byte)+ Access Address(4 Bytes)+ PDU + CRC(3 Bytes)
preamble = 10101010 or 01010101
Access Address = 0x8e89bedd6
2. 廣播包
PDU =??Header(2 Bytes)+ Payload (37 Bytes max.)
Header:??1)0000 - connected undirected advertising event 可連接非定向廣播事件
???2)0001 -?connected directed advertising event 可連接定向廣播事件
???3)0010 - non-connected undirected advertising event 不可連接非定向廣播事件
4)0011 -?response to scan request form scanner掃描請求響應
?????5)0101 - connect request by initiator連接請求
6)0110?-connected directed advertising event 可發(fā)現(xiàn)非定向廣播事件
?
- 非定向廣播包(Undirected advertising packets)
Payload ?= AdvA (6 Bytes) + AdvData (31 Bytes max.) ;?
?
?
//?AdvA ?contains advertiser‘s public address if TxAdd = 1, or a random address if TxAdd = 0;?
//?AdvData advertising data;
- 定向廣播包(Directed advertising packets)
Payload ?= AdvA (6 Bytes) + InitA(6 Bytes) ;?
//?AdvA ?contains advertiser‘s public address if TxAdd = 1, or a random address if TxAdd = 0;?
//?InitA contains initiator's address if RxAdd = 1, or a random address if RxAdd = 0;
?
?
3. 掃描請求及掃描響應
?
PDU =??Header(2 Bytes)+ Payload (37 Bytes max.)
Header:??1)0011 - scan request for further information from advertiser 掃描請求
???2)0100 -?response to scan request from scanner 掃描響應
?
- 掃描請求
Payload ?= ScanA (6 Bytes) + AdvA(6 Bytes) ;
// ScanA ?contains Scanner's public address if TxAdd = 1, or a random address if TxAdd = 0;?
//?AdvA ?contains advertiser‘s public address if TxAdd = 1, or a random address if TxAdd = 0;?
- 掃描響應
Payload ?= ?AdvA(6 Bytes) + ScanRspData(0~31Bytes);
// ScanRspData data from advertiser’s host;?
//?AdvA ?contains advertiser‘s public address if TxAdd = 1, or a random address if TxAdd = 0;?
?
?
3. 連接請求
?
PDU =??Header(2 Bytes)+ Payload (34 Bytes)
Header:0101 - connect request by initiator
Payload?=InitA(6 Bytes)+ AdvA(6bytes)+ LLData(22 Bytes)
LLData 包含連接信息,詳細結構參考bluetooth 4.0 協(xié)議。
4. LL 數(shù)據(jù)通道及控制包
?
PDU =??Header(2 Bytes)+ Payload (27 Bytes max.)
Header:詳細說明參考bluetooth 4.0 協(xié)議;
?
- LL 數(shù)據(jù)通道
?
Payload ?= 0~27 bytes
?
- LL?控制包
Payload = 1~23 Bytes
?
若只考慮藍牙設備連接之后,評估數(shù)據(jù)傳輸速率
?
- 最大包長度:preamble(1 Byte)+ Access Address(4 Bytes)+ PDU(29 Bytes) + CRC(3 Bytes)= 41 Bytes
- 射頻PHY傳輸速率 1Mbps
則傳輸有效payload 27字節(jié)耗時:41*8/1 = 328 us
?
一個27字節(jié)的傳輸周期 :328 + 150 + 80 + 150 = 708 us,若能持續(xù)傳輸,即傳輸速度:38KB/s,這樣顯然功耗不會低,也不符合BLE協(xié)議規(guī)范,真正的傳輸速度受連接事件間隔和間隔內能傳輸數(shù)據(jù)包數(shù)目相關。
如果連接時間間隔設置到7.5ms(協(xié)議規(guī)定最小值),一個連接事件傳輸3個包,則傳輸速率大約是10.8kB/s,一個連接事件能傳輸幾個包與連接設備密切相關,看到很多CC2540實測數(shù)據(jù),時間間隔7.5ms和一個傳輸時間3個包以上很多都達不到,51內核是其重要原因之一,在?http://processors.wiki.ti.com/index.php/CC2540_Data_Throughput有5.9KB/s,也有在論壇看到有40ms間隔,2個包,即1.4KB/s成功的案例,以后有時間我再實測下速度。
《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的BLE 包结构及传输速率的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nrf51822-配对绑定实现过程
- 下一篇: nrf51822-提高nordic bl