问题
We have a BLE device and android/ios app for communication with the device.
The requirement is to have an android/ios app connect to the device without any pairing request. No security is required on the device.
Hereafter a few questions around this:
- Q1. Is it possible at all to have an android/ios app connect to a BLE device without a pairing request?
- Q2. Does the bonding required for the BLE communication?
- Q3. What is the downside of having the device with no bonding? Is it going to drop the connection while the app is running?
- Q4. Who is the initiator or pairing dialog, the app, or the device?
- Q5. When having the device with Just Works security protocol, with no bonding and no MITM protection, should we see a pairing dialog?
回答1:
Please see answers to your questions below:-
- A1. Yes it is possible to do this because pairing and connection are two separate actions. Connection is when you establish a communication channel with a remote device, while pairing is when you exchange security keys with the device and have the option of encrypting that connection.
- A2. No, pairing/bonding is not required for BLE communication but it is preferred in order to have extra features and extra security on that connection.
- A3. No, having no bonding does not affect the stability of your connection/communication. There are a few downsides which include less security on the connection and also potential inability to find the device if privacy is implemented. More details are provided in the link below.
- A4. The app is the initiator of the pairing dialog. Specifically, the central device (the one that initiates the connection) is the one that is responsible for initiating pairing. When this central device requests to pair to the remote device, the pairing dialog is shown.
- A5. I believe this is dependent on the OS type (Android/iOS) and the version number of that OS, but generally speaking the pairing dialog should not pop up because as the name suggests, it should just work. Pairing dialog pops up when MITM protection is requested.
You can find more details about pairing/bonding and general BLE communication is the answer below:-
Should one create a bond with a Bluetooth LE device
I would also recommend trying the nRF Connect app on both iOS and Android to see the difference between connection and bonding and to verify that you can have normal connections without pairing.
回答2:
Based on what we got working and based on the answers to this question.
- A1: Yes, it's possible if no MITM is set and the Security scheme is set to Just Works, which means no security at all.
- A2: Bonding is not required for BLE communication. If the BLE device can't store the Bond information, it may lead to some issues as we got in our case. If the BLE device is able to store and use Bond information then it's recommended to Bond.
- A3: The Connection will not be closed. The only downside we got is that now it takes a little more time to reconnect.
- A4: The app is initiating the connection, but the dialog is shown only if the BLE device requests some type of security, it can be MITM, encryption, pin. Short answer, the pairing dialog can be avoided by changing the settings on the BLE device.
- A5: When having the device with Just Works security protocol, with no bonding and no MITM protection the pairing dialog should not be presented. We got no pairing dialog experience on both iOS and Android.
回答3:
To add to Youssif's answer:
A3: one difference is that connection setup will be faster since bonding allows the GATT db cache to be used. Otherwise service rediscovery must be done on every connection (if the service changed characteristic is present).
A4: on Android you can call createBond
to start pairing, but on iOS there is no API for the security, so either you need to interact with a characteristic that sends an error that pairing is needed, or the remote device can send a Security Request to initiate pairing.
A5: iOS shows a dialog "accept / abort" for just works, Android doesn't.
来源:https://stackoverflow.com/questions/61489768/is-bonding-required-for-ble-android-ios-device-communication