Consider a scenario where i have a bonded connection established with a peer device from my iPhone 4S running iOS 5.1.
And then there is a disconnection due to some reason (either user initiated or otherwise).
In this case if the app has to auto reconnect to the previously paired device, as far as i know Apple exposes the API retrieve_peripheral which is supposed to give the call back did_retrieve_peripheral with the previously connected or paired peripheral structure filled.
And using this peripheral instance i can compare my previously paired uuid and if matches can attempt connection (reconnection). But i am not able to fetch the peripheral since the count is coming as 0 in did retrieve peripheral callback.
Am I missing anything?
Also have anybody tried replicating or storing the entire peripheral structure in the app which includes the (services discovered in the peripheral, characteristics etc). and used this in reconnection.
To use the retrievePeripheral API, you need to save the CBPeripheral UUID somewhere (I use CoreData). The retrievePeripheral call takes an NSArray of UUIDs as a parameter. Looks like you're not providing the saved UUID to your retrievePeripheral call. When your didRetrievePeripherals callback is called, you will get an array of CBPeripheral objects. You can then reconnect to these peripherals. You don't need to scan for these and you also won't need to pair with the peripherals.
I have the same problem and I think one solution: when connection is lost, masterhave to scan for peripherials in the same way that we scan and connect, and slave have to pass to advertisin state and both have to recognice caractheristics services uuid's and caracteristics for the services again.
This is the way I going to try to reconnect.
Of course I thing we have to refresh on your own way with some more functions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With