... | ... | @@ -64,7 +64,7 @@ Testing mesh networking software is often challenging from a developer's perspec |
|
|
## Bluetooth
|
|
|
|
|
|
Bluetooth is a short-range radio technology that comes bundled with most modern day mobile devices.
|
|
|
It allows devices to discover each other, and transfer relatively small packets of data over a range of up to 33 feet.
|
|
|
It allows devices to discover each other and transfer data over a range of up to 10 metres.
|
|
|
The accessibility of Bluetooth API's on most modern day smartphones makes Bluetooth an attractive transport for infrastructure-free data transfers, like those needed for a public mesh system.
|
|
|
|
|
|
### Resources
|
... | ... | @@ -89,9 +89,43 @@ Background information about Bluetooth: |
|
|
|
|
|
- <https://code.briarproject.org/briar/public-mesh-testbed/-/tree/bt-classic>
|
|
|
|
|
|
### Bluetooth "classic" (BR/EDR)
|
|
|
|
|
|
The early generations of the Bluetooth standard, which are now sometimes called "classic" to distinguish them from Bluetooth Low Energy, are supported by nearly all smartphones.
|
|
|
|
|
|
#### Discovery
|
|
|
|
|
|
At any given time, a Bluetooth classic device may be connectable and/or discoverable. A connectable device can receive incoming connections from other devices. A discoverable device can be discovered by other devices that are performing discovery.
|
|
|
|
|
|
An Android device is connectable whenever Bluetooth is turned on. There is an API for making the device discoverable, which requires confirmation from the user. If confirmation is given, the device remains discoverable for up to 120 seconds. On versions of Android up to 8.1 (API level 27), some devices allow making the device discoverable for an unlimited amount of time, but we could not find any devices running versions later than 8.1 that allowed this.
|
|
|
|
|
|
Android also provides an API for performing discovery, which does not require confirmation from the user. Discovery runs for about 10 to 30 seconds. Receiving discovery results requires Bluetooth and/or location permissions, depending on the API level.
|
|
|
|
|
|
#### Pairing
|
|
|
|
|
|
To provide a measure of security and enable users to manage the relationships between their devices, Bluetooth allows devices to be paired. This sometimes involves entering a PIN on one or both devices. Once this has been done, connections between the devices can be encrypted and/or authenticated at the Bluetooth layer, and the devices can connect to each other automatically without needing to repeat the discovery and pairing process.
|
|
|
|
|
|
On Android, the list of paired devices is accessible outside the scope of the application that created each pairing. This may be a privacy issue if the existence of a pairing indicates a social relationship between users.
|
|
|
|
|
|
#### RFCOMM
|
|
|
|
|
|
The Bluetooth standard defines a profile called RFCOMM that supports socket-like connections between devices. Android provides an API for making and receiving RFCOMM connections. When opening a server socket to receive RFCOMM connections, the application specifies a UUID to identify the service. The same UUID must be specified when opening a socket on the client device, along with the Bluetooth classic address of the server device.
|
|
|
|
|
|
If encryption and/or authentication is needed at the Bluetooth layer then the devices must be paired, but an application can request a socket that does not use encryption/authentication at the Bluetooth layer, and therefore does not require pairing. This enables an Android device to connect to another device without user interaction, if the first device knows the second device's Bluetooth classic address and there is prior agreement about the UUID of the RFCOMM service.
|
|
|
|
|
|
#### Access to the Bluetooth classic address
|
|
|
|
|
|
If an application can find out the device's own Bluetooth classic address and share it with another device out-of-band then an RFCOMM connection can be made between the devices without needing user confirmation at any stage.
|
|
|
|
|
|
On Android versions 6 and later (API level 23), applications do not have access to the device's own Bluetooth classic address. There are workarounds for accessing the address up to Android 8 (API level 26).
|
|
|
|
|
|
Beyond that point, an application receiving an RFCOMM connection can still access the address of the remote device, and can send this information back to the remote device (via the RFCOMM connection or out-of-band) to enable the remote device to learn its own address. The developers of Thali called this technique "bro mode" after the phrase "help a brother out".
|
|
|
|
|
|
This does not allow a group of devices to bootstrap connectivity entirely without user interaction, as would have been possible on earlier API levels: at least one device must be made discoverable in order to receive the first RFCOMM connection. But this technique can be used to reduce the amount of user interaction needed.
|
|
|
|
|
|
### 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 reduce the energy consumption during use, without greatly impacting functional range.
|
|
|
|
|
|
#### Security
|
|
|
|
... | ... | |