I am working on an audio device project with dual-mode Bluetooth. I want to create a seamless connection experience with iOS devices, so I use CTKD with iOS. This gives us the ability to connect both BR/EDR and BLE without leaving our app in the system settings.
It works perfectly if the initial pairing happened inside the app. I got both BR/EDR and BLE connected and working and only one device shows on the Bluetooth page.
But if I pair the Bluetooth(BR/EDR) first in the system settings and then go to the app to pair BLE. The app initiated a new CTKD process, which creates a new BLE connection beside the BR/EDR connection.
My question is if I pair BR/EDR first in the Bluetooth settings, is there a way that I can only pair BLE and didn't trigger the CTKD while keeping the one device displayed on the Bluetooth settings page? Or anything else that can get the same result?
Related
Background
I'm using a couple of different hobbyist BLE devices (HM-10). This particular one is an example of one of them.
It's a simple 4-pin device and I've set all the parameters on it using an Arduino Nano and I can see the data coming into it live since it is connected to USB of my computer and I'm monitoring serial data using Arduino Serial Monitor.
The device works great. I have it set to Type 3 which forces it to pair/bond (so iphone or ipad will force you to enter the 6-digit PASS code, which I've set on the device.
iPhone App Works
I have written a simple Single-View iOS app which runs on my iphone / ipad and finds local BLE peripherals.
Everything works great.
When I select the item (HM-10) shown above by name I see the iOS pairing dialog & successfully pair the item.
I can send data and everything works fine. If I go out of distance or turn off bluetooth on my device then come back into proximity or turn the device back on, then the iphone can send data again and I see it in the Serial Monitor. Works great.
** The Problem **
The problem occurs if I then pair this device with any other iphone or ipad.
After that, the new iphone / ipad can send data to the device with no problem.
However, if I then go back to my original iphone and attempt to send data again, I see the following error raised by the CBCentralManager:
"Peer removed pairing information."
After that, I cannot send data from the original iphone to the device again, unless I go to Bluetooth settings on the phone and say, "Forget this device".
Android & HC-06 Bluetooth Devices
I've developed simple Android apps which use a similar Bluetooth classic device (HC-06) and I could pair multiple devices.
Questions
Does BLE 4.0 Allow multiple devices to be paired & bonded?
Do you know why the Peripheral would remove the pairing info? (again, this only occurs if I pair the device with a new iphone / ipad).
Is there a way to send something via iOS app that would tell it to renew the pairing information?
Do you have any suggestions (code to try or other) that would allow me to definitively know that this device does or does not allow multiple phones to pair with it? (I've contacted the manufacturer also.)
Note: I also have a another BLE device here and it seems to exhibit the same behavior. This seems odd though, because I have a BLE speaker that will pair with multiple devices so it must be possible. And I understand that could depend upon the BLE hardware.
Does BLE 4.0 Allow multiple devices to be paired & bonded?
Sure. But that doesn't mean that the device does. It needs to allocate memory for it, and smaller devices often don't.
Do you know why the Peripheral would remove the pairing info? (again, this only occurs if I pair the device with a new iphone / ipad).
It doesn't remove the pairing info. It's telling you the device has removed the pairing info. Pairing info includes a shared secret, so if one side throws away their secret, there's no point in you keeping yours. You have to create a new one.
Is there a way to send something via iOS app that would tell it to renew the pairing information?
Unfortunately no. Apple doesn't give any access to the pairing experience.
There isn't any standardized way to ask devices this kind of information. Some devices support a single pairing Some support two. Some support "a few." But it's really up to the device.
It is very possible that you will get a better overall experience with a Bluetooth 4.1 or 4.2 device, because they've added better security protocols. With iOS 13, the phone also supports cross-transport key derivation, which possibly will help here (if the device also supports it). But I don't think you can improve things with a Bluetooth 4.0 device.
We are working in Blood pressure monitor project . we have implemented GATT protocol in our device to communicate with iphone / iPad . so far we are using Core bluetooth framework to communicate with our device ,Its working fine in data transmitting.
But our device is not visible / listing in iPhone Bluetooth in the settings page.
please note that we are not using any MFI chip.
Please advice what we needs to be done to make our device visible in iphone's bluetooth settings page without using MFI chip.
In order for your BLE device to show up in iOS Bluetooth settings, it has to have gone through the pairing process, as stated by Larme.
To do so, the device must have one or more characteristics that are encrypted. When your app tries to read/write/indicate on that characteristic, the read will fail with an Insufficient Authentication error code, which will then should start the pairing process. See section 25.10 in Apple's Accessory Design Guidelines - https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf
Once the user has selected to Pair in the dialog, keys are exchanged to finish the pairing process. Your device will show up in Bluetooth settings at that point.
Is there a specific reason that you want the device to show up in Bluetooth settings?
We are building a custom Bluetooth device that supports both Bluetooth Classic for Handsfree as well as Bluetooth LE for other features. I am able to connect and communicate with the device via Bluetooth LE however, right now the user must manually pair with the device from Settings in order for the handsfree stuff to work. Like the Apple Watch, is it possible to automatically pair with the device via Bluetooth Classic when the device is selected from the Bluetooth LE list of available devices?
Basically, here is how we want it to work.
User launches application for the first time.
User is redirected to registration screen and registers their phone with our environment.
User is taken to the applications Dashboard and then clicks the applications Settings button.
In Settings, the user clicks Bluetooth Peripherals and is taken to a screen with a list of the BLE devices in range.
Here is where the new magic needs to happen:
User chooses BLE device, the devices is discovered and connected to via BLE.
After the devices characteristics have been discovered, the application should pair with the device via Bluetooth Classic for the handsfree stuff to work such as the microphone and speaker.
Any help is appreciated.
I have looked into the External Accessory framework however, I was unable to get it to even work properly. The application kept failing telling me "init" was not available or something.
Thank you.
We're trying to do the same thing and it looks like you can only pair a hands-free device working via HFP profile if leaving your app, going to Bluetooth settings in Settings.app and tapping the device there. From the app it's absolutely impossible. All the hands-free vendors I checked recently (Jabra, Parrot, etc.) do it this way.
The only thing I can think about would be pair via BLE, send the iPhone name to your hands-free accessory via BLE open Bluetooth settings screen in the Settings.app and wait for the accessory to discover the iPhone and connect to it from its side. This will save your user a tap, but he will still have to open the Settings.app (manually, bloody hell, not even via a system alert).
ExternalAccessory.framework is used to connect with devices registered in MFi program. It has absolutely nothing to do with hands-free devices working with HFP profile.
I'm working on iOS development for a bluetooth peripheral. We want the (already paired) device to connect when a button is pressed on it, and this will cause the app to execute some code. Is it possible for the app to detect that the device is connected, even while in the background?
Also, is it possible for the app to bring itself into the foreground when this is detected? Would I need to be a member of the MFi program to do either of these things?
You will be able to detect that the device is connected in the background using Bluetooth 2.0, however you must include the App communicates with an accessory string under Required Background Modes in the app's plist.
So yes, the first part of your question is doable. However when you say: "We want the (already paired) device to connect when a button is pressed on it", it is important to note that this functionality must be built into the device's firmware. The app can always be searching for it, but the device will not be able to communicate with the phone until it connects. Therefore, the button must wake up the device and signal that it now wants to connect.
For the third part of your question, you will not be able to bring the app into the foreground without the user opening the app.
Btw, CoreBluetooth is the Bluetooth Low Energy framework for iOS. It is completely different from Bluetooth 2.0.
as ttarules told you iphone can't connect automaticly to a paired device.
I don't know what kind of bluetooth receiver have you in your device but generally you can set up a method of "AUTOCALL" that automatically call a paired device (in this case an iPhone).
When you (your iPhone) come around the device it automatically establish a connection!
If you set all the parameters correctly in the bluetooth module you can make sure that the iPhone shows a message like this: "YourDevice would like access to YourApplication" when the connection is established.
this way helps the user to use your application and you can run the code you mentioned above when the app start.
Is is possible to "pair" a Bluetooth BLE device such that they automatically connect when in range? (ie. an iPhone app sets up a connection to the Bluetooth device and from then on, the iPhone automatically reconnects to the device if in range, even if the app hasn't been opened in days and is fully closed).
Once reconnected, the device could either using Event Backgrounding to prompt the user to open the app or otherwise interact with a possibly backgrounded app (as described here).
Anecdotally, I've used Bluetooth keyboards that automatically reconnect to my laptop when back in range. These are not necessarily BLE devices, is this something that's possible in BLE land?
Could this be possible if the iPhone were the server instead of the device? What if this were done using traditional Bluetooth under the MFI program?
There are number of relevant comments here and on the Apple Bluetooth-dev mailing list, but nothing that cleared it up for me. Thank you for your help.
I posted my question on Bluetooth-dev, I'm leaving the response here for posteriority: http://lists.apple.com/archives/bluetooth-dev/2012/Sep/msg00117.html