4

When connection to a custom BLE device from an app (android and ios) I have two options

a) first pair the device on the phone (like a headset or other devices) and then use it from the app to read and write data

b) without pairing on the phone, go inside the app, search for a device with a specific name or address, and just connect to it and read and write data.

when is one preferred over the other one ? Its just when it needs to interact in the background or am I missing something?

Daniel Benedykt
  • 6,496
  • 12
  • 51
  • 73

2 Answers2

3

Bonding (technically correct term for BLE, often called Pairing in non-technical speech) is mostly for security, we can send sensitive information because the receiver is verified and data is transferred in encrypted form.

Prefer to use bonding if the data is sensitive (means users feel uncomfortable if somebody they don't know receive their data). For example, I consider "current temperature = 25" as NOT sensitive. For detailed explanation, find "Bonding with a BLE device" in BLE guide by PunchThrough.

Also this is a good answer to a similar question: https://stackoverflow.com/a/42916081/10380092.

Your second question about background - no, bonding is not related to interaction in background.

alexander.cpp
  • 747
  • 6
  • 15
3

The devices you see in your phones Bluetooth settings are Bluetooth Classic devices. There are some devices using both BLE and Bluetooth Classic which show up in the settings too, but the settings page is only for the Bluetooth Classic part of the device. Headphones for example are streaming music trough the Bluetooth Classic profile A2DP but might offer BLE services for additional features.

You always have to use a special app to communicate with the BLE part of a device. This could be an app provided by a manufacturer or a generic BLE scanner app such as nRF Connect.

As alexander.cpp already told you in his answer pairing (the exchange of keys) and bonding (saving of said keys) is not required for the communication with BLE devices and only needed if the device requires a secured connection.

Michael Kotzjan
  • 2,093
  • 2
  • 14
  • 23