Pre-specify Bluetooth pairing request pass code in CoreBluetooth - ios

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?

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.

How to send data through central mode to peripheral?

I'm developing an application where Client App starts BLE scanning in "Central" mode and there is a scanner App which Acts as "Peripheral",client will keep scanning for Scanners (Beacons) with specific id (where the Scanners are advertising the same id) when that both id match data is sent over BLE to the scanner app I have an example code which works perfectly from peripheral to central but i don't have idea about my case how it work.
The Demo which you are following is the correct one for a beginner. In this Demo, app is sending text data from TextView. The text data is passed in octet form, in iOS it is considered as Data (.utf8).
Now, question is, which type of data you want to send from Central to Peripheral.
The General flow is:
1. Central will proximate peripheral so that other Bluetooth manager can scan it.
2. Once anyone try to connect with that peripheral, then on successful connection, it will return available Services and Characteristics inside of those each services.
3. Based on characteristic, you can write your own logic to send text, images, audio, video or anyother data from Central to Peripheral.
Just follow the Demo link which you are following. Thanks.

Handling multiple Bluetooth Pairing Request Dialogs at once

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.

Prevent other apps from receiving data from the accessory my app is talking to

My iOS app is connected and exchanging sensitive data with a BLE accessory, I want the data communication to be secured so I use an encrypted BLE connection (=paired).
But is there a way for my app to be the only app that can receive the data from the accessory?
I want to make sure it is not possible for another app running in the background to receive the data sent by the accessory.
Core Bluetooth will provide access to any apps that are on the device but if you implement your communication using additional authentication or encryption, then it will be harder for other apps to make successful connections to the peripheral.
I think it helps to think of the peripheral as an ssh server. Anyone can open a connection to it but they will be connected only if the correct credentials are provided to the server. Your peripheral should work similarly. The required method for the authentication depends on your requirements.

Resources