Reconnection procedure in iOS BLE application
bluetooth, bluetooth-lowenergy, core-bluetooth, ios
Solution
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.
Problem
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.