I am working on a CoreBluetooth manager app for an iPhone. To be able to reconnect to a previously discovered CBPeripheral, I save the UUID of the peripheral (in CoreData) and then call CBCentralManager's retrievePeripherals:. My didRetrievePeripherals: callback is called and I can connect, etc. So far so good.
Since I am reconnecting to a peripheral that I already know about, I would like to avoid discovering its services and characteristics. So I save the UUIDs of the services and characteristics (again in CoreData, along with the peripheral's UUID) when I first connect.
But I cannot use these UUIDs to read or write the characteristics because the CBPeripheral's readValueForCharacteristic: or writeValueForCharacteristic: take a CBCharacteristic as a parameter, and there is no API to construct a CBCharacteristic instance.
Is there any way to avoid discovering services and characteristics while reconnecting with a previously known peripheral?
Mezulu, you want to use an encrypted/paired link – then iOS will do the caching for you. See my answer here.
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