Add background info on BLE roles, GATT and L2CAP CoC authored by akwizgran's avatar akwizgran
......@@ -117,11 +117,15 @@ This does not allow a group of devices to bootstrap connectivity entirely withou
### Bluetooth Low Energy (BLE)
Bluetooth Low Energy is a separate protocol from Bluetooth classic that is designed to reduce the energy consumption during use, without greatly impacting functional range.
Bluetooth Low Energy is a separate protocol from Bluetooth classic that is designed to use less energy without greatly impacting functional range.
#### BLESSED Library
Like Bluetooth classic, BLE allows devices to discover and connect to each other. A device in the "peripheral" role sends advertisement packets and accepts connections, while a device in the "central" role receives advertisement packets and initiates connections.
We have found that the open source Bluetooth library [BLESSED](https://github.com/weliem/blessed-android) is useful for working with BLE on Android. The project's README.md offers an introduction to the library for new users, and they also offer a number of [example projects](https://github.com/weliem/blessed-android/tree/master/app/src/main/java/com/welie/blessedexample) to help developers get started with BLESSED.
Once a connection has been made, data may be exchanged using the Generic Attribute Profile (GATT). The peripheral offers one or more GATT services, each consisting of predefined "characteristics": small pieces of data that can be read or written by the central.
More recently, the Bluetooth standard has defined L2CAP Connection-Oriented Channels (CoC), which allow socket-like connections between centrals and peripherals. The server socket on the peripheral device is identified by an ephemeral number called the protocol/service multiplexer (PSM), which must be communicated to the central somehow (eg through BLE advertising, GATT, or out-of-band). Android provides an API for L2CAP CoC on API levels 29 and later if the hardware supports it.
Most Android phones can operate in the central role and some can also operate in the peripheral role, so some pairs of devices can make peer-to-peer BLE connections via GATT or L2CAP CoC.
#### Security
......@@ -189,6 +193,7 @@ On API level 30 and earlier, access to some Bluetooth APIs requires location-rel
### BLESSED
We have found that the open source Bluetooth library [BLESSED](https://github.com/weliem/blessed-android) is useful for working with BLE on Android. The project's README.md offers an introduction to the library for new users, and they also offer a number of [example projects](https://github.com/weliem/blessed-android/tree/master/app/src/main/java/com/welie/blessedexample) to help developers get started with BLESSED.
#### Peer Advertisement
Peer advertisement happens using BLE's peripheral advertisement protocol. Peripheral devices build a schema of characteristics, and advertise their core service UUID over the Bluetooth frequency band.
......@@ -316,7 +321,7 @@ Bluetooth Mesh is a relatively new Bluetooth standard that supports multi-hop co
* https://www.bluetooth.com/wp-content/uploads/2019/03/Mesh-Technology-Overview.pdf
* https://www.bluetooth.com/bluetooth-resources/controlling-bluetooth-mesh-networks-with-android-applications/
The mesh stack shares some lower layers with the Bluetooth LE stack in smartphones, but it also has some higher layers that aren't implemented in smartphones. So when a phone interacts with a mesh, it does so via a device called a proxy that implements both stacks. As far as we were able to tell, a mesh can't be formed from just smartphones.
The mesh stack shares some lower layers with the BLE stack in smartphones, but it also has some higher layers that aren't implemented in smartphones. So when a phone interacts with a mesh, it does so via a device called a proxy that implements both stacks. As far as we were able to tell, a mesh can't be formed from just smartphones.
There are several projects that implement the higher layers of the mesh stack in software, on Linux at least:
......
......