Why does CBCentralManager report "Peer removed pairing information" with 1st phone after 2nd phone is paired with device? - ios

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.

Related

CTKD implementation issue on iOS

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?

IOS Bluetooth not discover in iPhone settings page

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?

Communicating with a Bluetooth Classic device in iOS when the app is in the background?

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.

iOS: Automatically reestablishing Bluetooth BLE connection when in range

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

What is the simplest way to connect a device to an iPad from an application?

I am working on a major product release for my company. We are designing a new device that we would like to integrate into an iOS app. (FYI, we have recently been accepted into the Apple MFi program so we are past that step.)
What we desire is to create a hardware/software eco-system where our users can start our iPad app (yes, it is specific to the iPad and the not iPhone or iPod Touch devices) and the application will automatically discover and link up with any close-proximity hardware that we've developed.
This means that I will need to implement some form of device connection process on both the iPad and within the hardware.
Is there any way to code automatic connectivity to a Bluetooth device from within an iOS application?
I am aware of the Core Bluetooth Framework which has this capability, however, it only works with the new iPhone 4S. That's not an option.
I've also researched about the External Accessory Framework, which can be used to connect to external devices whether they are connected via the iPod port or Bluetooth. This is an option but, if my understanding is correct, our hardware must already be paired with iPad before the iOS software can connect to it. This is less than preferable because although many of our devices may not be in immediate vicinity at one point in time, our customers could potentially own 100's devices that they may desire to connect to with our software.
What are my reasonable options or alternatives? The end goal is to provide a very easy means for our users to be able to connect to our devices, from within our software, on an iPad.
NOTE: I MUST NOT jailbreak the iPad or break any Apple TOS agreements.
UPDATE (3-7-2012) I saw today that the 'New iPad' (as it is being officially called) will be Bluetooth 4.0 capable. I assume this means that this iPad device will be able to use the Core Bluetooth Framework. This doesn't immediately solve my problem because we do want remain compatible with at least the "last generation" iPad device, but this is worth pointing out for others who may be looking for such an answer.
You cannot connect an iOS device to a bluetooth device without pairing first. It is purposely built that way by Apple to reduce the likelihood that someone could connect a bluetooth device without the user knowing about it. If pairing each device is unacceptable (and it sounds like it is), and you don't want to develop a dongle, the only remaining path I can see is to make your devices capable of relaying data between them like a mesh network. That way the user would only have to pair with a single device, and that paired unit would relay communications between the other devices and the iPad.
One of your alternatives would be going WiFi (AdHoc or Infrastructure) with Bonjour. For example you would be able to detect the device nearby (if it is maintaining it's own AdHoc then by SSID; if it's in infrastructure network then by service being announced). One big drawback would be that you couldn't connect directly (from app) to the device's network - user would have to do it manually.
As for BT: big drawback is lack of a serial protocol (not implemented in iPhone/iPod/iPad).

Resources