發表文章

目前顯示的是 十月, 2019的文章

[BLE] 不同的 Advertising 種類與用途

圖片
在 BLE 通訊協定中,
BLE 裝置透過 Advertising 告知周邊 BLE 裝置自己的存在,
其中, 考慮到 WiFi 的干擾,
Advertising 封包在以下 3 個 bluetooth channel 上廣播:
channel 37 (2402 MHz), channel 38 (2426 MHz), 和 channel 39 (2480 MHz),
我們可以利用下圖來了解其中干擾的關係:

來自: https://www.infsoft.com/technology/sensors/bluetooth-low-energy-beacons
對於 connection 之後的資料傳輸,
則使用其他 bluetooth channel 進行通訊,
並藉由展頻通訊 (跳頻) 的方法, 對抗 WiFi 通訊產生的干擾,

透過不同的通訊目標, BLE 設計了 4 種不同的 advertising 的方式,
如下表所示:
Advertising PDUDescriptionMax Adv Data LenMax Scan Res LenAllow ConnectADV_INDUsed to send connectable undirected advertisement31 bytes31 bytesYesADV_DIRECT_INDUsed to send connectable directed advertisementN/AN/AYesADV_SCAN_INDUsed to send scannable undirected advertisement31 bytes31 bytesNoADV_NONCONN_INDUsed to send non-connectable undirected advertisement31 bytesN/ANo(來自: Bluetooth Low Energy Scanning and Advertising)
Advertising Data (Adv Data) 代表在 advertising 封包中自帶的資訊,
在 BLE 中, 此資料的長度為 31 bytes.
更多的資訊可以透過 Scan Request (Scan Res) 像發送端要求,
若發送端有支援, 則可以附加額外 31 bytes 的資訊.

[BLE] State Machine and GAP Roles

圖片
在一般 BLE 裝置中, 不同的連線階段也扮演不同角色,
一般來說, 可以分成這四種 GAP Roles:

GAP RoleDescriptionBROADCASTERA device that only sends advertising events.OBSERVERA device that only receives advertising events.PERIPHERALA device that accepts the establishment of an LE physical link using the connection establishment procedure.CENTRALA device that supports the Central role initiates the establishment of a physical connection. (來自: Bluetooth Low Energy Scanning and Advertising)
其中, Broadcaster 和 Observer 為一對, 進行 adverting 通訊,
Peripheral 和 Central 為一對, 進行資料傳輸,
為了表示此 4 種 GAP 腳色, BLE 可以表示為以下狀態機 (State Machine) 的轉換:

來自: https://iot.electronicsforu.com/expert-opinion/improving-battery-life-in-bluetooth-low-energy-connected-things-part-2/
其中, 我們可以看到 Connection 和 Advertising 分屬不同的狀態,
以 one-hot state machine 的概念來說, 在一個時間內應只屬於一個狀態,
至於上述 4 個 GAP Role 則使用了狀態機不同的部分,
如下圖所示:

來自: https://iot.electronicsforu.com/expert-opinion/improving-battery-life-in-bluetooth-low-energy-connected-things-part-2/
其中, Peripheral 和 Central 此對連線, 多…