I need functionality like user is pairing to an device. And he/she should be able to retrieve that device from any iOS mobile device. i.e., without connecting.
So I have saved the id which is getting at the time of connection success and saves the same in server.
But when user is trying to login from another device, the retrievePeripherals is returning null array. Because the id was device specific.
Edit
As Paulw said in comments its great to make connection in background. So is there any way to know any details about my previously connected BLE device from this saved identifier.
Like
During first connection :
phone uuid + device characteristics = identifier // + refers to some internal operations done by OS
So in reverse can I do
identifier - phone uuid = device characteristics
Related
We are developing an iOS app that must pair (and bond) with a BLE peripheral before our app can proceed with other steps. From what I understand Apple wants accessories to follow this flow to initiate pairing:
iOS device connects to accessory
iOS device attempts to access an attribute that requires special permissions (e.g. authenticated connection or encrypted connection)
Accessory rejects the attribute access with an “Insufficient Authentication” error code
iOS realizes it needs to initiate pairing, so it generates a pairing popup that allows the user to initiate it
The problem is that the firmware on our BLE peripheral can not be altered. All of its BLE attributes are unprotected and do not require an encrypted or authenticated connection to access these attributes. So in this case, how can we get iOS to generate the pairing popup so that the user will have the ability to pair?
I realize that my question is related to How to bond/pair to a bluetooth LE device programmatically in swift Xcode?, but it differs in that we can not change the permissions used by the characteristics of our BLE peripheral. We have no control over the firmware.
Thanks in advance.
My question is how can we detect our own device's unique bluetooth ID (must be available from other device when we scan for nearby available bluetooth)
I tried this
CBUUID *myService = [CBUUID UUIDWithString: #"MyServiceID"];
but in my case this is same as device UUDI.
You can’t. Apple works hard to ensure that apps can not access any identifiers that uniquely identify a device; the Bluetooth MAC address would be such an identifier.
The Bluetooth identifiers that are reported by Core Bluetooth on another iOS device are local to that device.
You could allocate your own UUID and make that available via a characteristic. That way you would know what value the remote device would see, but it would need to connect to retrieve the value. You could also put a specific name in the advertising data.
In my BLE app, the user story is like, bluetooth pairing should happen without the passcode confirmation step. As far as i have researched so far, it is possible in Android (like Android Bluetooth Pairing without User Enter Pin and Confirmation Using Android API)
Is it possible in iPhone?
Sadly, on iOS it is not possible to skip the pairing dialog. It is directly sent from the OS. It is a strict convention from apple that apps are not able to skip security processes.
Some additional information:
Dependent on the IOCapabilityResponse from the peripheral device on bluetooth level iOS will show you a dialog asking to pair or to confirm a pass code. If iOS will show you the dialog at all depends if the bondable flag is set in the IOCapabilityResponse from the peripheral.
There are three types of connection in BLE:
connection: pin not required, connection not secure
pair: pin could be requested or not, connection secured with short term key, a popup will be displayed
bond: pin could be requested or not, connection secured with long term
key, a popup will be displayed
All of these method are managed by BLE peripheral firmware, iOS only adapts its connection based on how the peripheral is configured
See the image above. I am pairing my iOS app from iphone1 to a single Bluetooth device, say BT1, which is further inter-connected with other similar bluetooth devices via Bluetooth Mesh. As soon as I connect with BT1, I get a uuid1 for the connection.
Now, I need to uniquely identify the paired device uuid. This is essential as I would like to transfer my phone app settings to another iPhone, say iPhone2, via cloud, so that any phone can connect to the original paired BT device. But when I try to pair iPhone2 to Device1, I get a different uuid2 for Device1, because of which, I cannot match it with the uuid1. So if uuid1 = uuid2, then the cloud will send me the original settings.
Question -
1. is it technically possible to ensure that a bluetooth device shares the same uuid to all its client?
2. If #1 is no, is there an alternative?
Thanks in adv.
Following off of this question:
Corebluetooth, How to get a unique UUID?
After connecting to a peripheral, I can retrieve its CFUUIDRef, which is unique, and can use it to reconnect via retrievePeripherals. However, I have found that I can not use it to reconnect after closing the application.
Is the unique UUID generated after a connection only valid for the lifetime of the application or are we supposed to be able to save it for later use? I am trying to have my application remember one particular peripheral, but besides peripheral.UUID, I don't know of any other unique identifiers.
Long story short, YES you can use the UUID to reconnect to the same device even after you close the application (in exactly the way you say).
I assume however, that you are not actually pairing with peripheral. That's a big problem right there. You need to actually establish the pairing request and get the peripheral to show up in the bluetooth table. The UUID will then be solidified with the iOS device and will remain until you flush the Network Settings of the iOS device.
The other possibility is that your BLE device has a firmware problem, wherein after you disconnect, it forces itself into advertising mode or something. This will also mess with your ability to reconnect. Let me know if you have any questions!