Handling multiple Bluetooth Pairing Request Dialogs at once - ios

I have an app that integrates with BLE devices. I can connect to any number of devices. When initiating a pairing from the app to the device via [CBCentralManager connectPeripheral:options:] the system bluetooth pairing request alert will fire if no previous pairing information is found. This all works great.
However, I am implementing a functionality that discovers, pairs, and reads characteristics from multiple devices at once. This also works great if the devices have been paired previously. But if this is the first pairing for more than one of the devices, only one of the pairing request alert controllers is displayed. What makes this even more difficult is that I also don't receive a failed connection error from CB for the other devices waiting for response from the pairing dialog.
Is there any way I can elegantly handle situations where there are multiple pairing requests needing attention? It would be helpful if at least one of these was possible:
The ability to complete the outstanding pair requests sequentially
Notification of failed pairing for other devices
Knowledge of whether a pairing request dialog will be fired before initializing the pairing so I can pair one at a time

There are no APIs in CoreBluetooth that lets you interact with the pairing.
Are you in control of the firmware of the peripherals you want to be able to pair with? If so, you can enable notifications and send events how the pairing process is going. That way you know in the app the current status of a pairing process.
For some examples, by looking at status and error codes (details depends on your peripheral BLE stack), you will be able to identify when iOS shows the pair dialog, when the user presses cancel and when pairing succeeds. It will also be possible to identify when iOS didn't put up the pair dialog.

Related

Bluetooth peripheral does not pair

I have written an apple watch app to try to communicate with a bluetooth peripheral which has implemented some custom encryption and pairing process I already managed to implement correctly.
The device seems not to conform to standards and as such does not indicate that it needs encryption through its chatacteristic properties. After going through the pairing I can write values to it and recieve notifications.
The problem is that when I disconnect and connect again I have to go through the pairing process again. Also I have noticed that after pairing via other apps the device does a long beep sound which seems missing when I pair it through my app.
Is there any way to force pairing/binding in CoreBluetooth?

iOS - Bypass Pairing alert for bluetooth

I'm using Core Bluetooth framework in my iOS app to communicate securely with BT devices. In my product, server sends a pairing code that user has to enter in the text box in peripheral device’s alert to complete the pairing process. It's working good.
As server sends the code, without showing the pairing alert, can I by-pass the alert and handle the code that pairs the device without user's intervention.
No, if you are using encryption on any of your characteristics an attempt to read or write that characteristic will trigger the iOS pairing dialog.
Your app has no direct access to the pairing process as it happens outside of your app.

When does iOS display "need to bond" dialog?

I am writing an iOS app that communicates with a BLE device that we are developing. Most communication does not require bonding, but there are some secure features where bonding will be required. I've put those secure features in a separate service which has been flagged as requiring bonding, and when I try to access that service iOS correctly starts the bonding process.
The problem I'm having, is that I want to be able to control exactly when this bonding takes place so I can design my UI appropriately. Most of the time, iOS waits until I try to access the secure service before it starts the bonding process, but I have also seen the bonding dialog appear shortly after I call CBPeripheral.DiscoverCharacteristics() and long before I actually use the secure service for anything. The bonding dialog seems to appear later if I'm re-running the app when I've already bonded once and then deleted the bonding both in iOS and the remote BLE device.
I'm guessing that iOS is caching the service/characteristic information, so after the first connection when I call CBPeripheral.DiscoverCharacteristics() it's not actually communicating with the remote BLE device, and thus isn't triggering the need to bond.
There's a discussion about how to clear the bluetooth cache on OSX, but nothing similar for iOS. I've tried this:
Unbond device in iOS
Turn off Bluetooth
Turn off iPad
Turn iPad back on
Turn Bluetooth back on
But the bonding request dialog still comes later, which I'm guessing means the cache didn't actually get cleared.
If the devices are unbonded and the peripheral sends an SMP "Security Request", it will show the popup.
It also shows it when you try to interact with a protected characteristic.

Pre-specify Bluetooth pairing request pass code in CoreBluetooth

I'm creating an iBeacon maintenance app for a client.
When the app connects to the beacon, it shows a CoreBluetooth pairing request dialog:
Because I want to make it as simple as possible for the client, and because I store the required codes on my server which the app can fetch, I'd rather specify, programmatically, what code CoreBluetooth should connect with, rather than asking the user for it.
Is it possible to do this?

ios Core BlueTooth Pairing to External BLE Device

I am making an BLE based application.
As I know Bluetooth Pairing is handling ios internally.
Is there any possiblity to get access over bluetooth pairing request in ios . I am getting pairing request from external BLE Device but i am not able to know whether user is paired or cancelled.
Apps like TI SensorTag and Multitool apps are handling the pairing request when user clicks cancel then these apps disconnects the peripheral.
I am not getting any clue how they are handling the pairing.
Please help me in getting this solved.
Thanks
The BLE devices are more then likely handling the cancel on their side. When you click cancel through iOS it does not pair and does not enable encryption. At this point the BLE devices are probably issuing a disconnect because encryption has not been started.
The only time you will see that pairing message is when encryption is being requested.

Resources