When I get delegate didConnectPeripheral:(CBPeripheral *)peripheral
can I just store peripheral in an array, and then use it to re-connect later, instead of using retrievePeripherals and its subsequent didRetrievePeripherals
?
Seems like it would be easier, if it's feasible and has no risk.
How much later can (CBPeripheral *)peripheral
be re-used? Is it still valid after disconnection with that peripheral?
Workflow:
scanForPeripheralsWithServices()
- to scan for a peripheraldidDiscoverPeripheral:(CBPeripheral *)peripheral
- when it's detectedconnectPeripheral:peripheral
didConnectPeripheral:(CBPeripheral *)peripheral
stopScan and store the(CBPeripheral *)peripheral
for later.- ... read or write characteristics ...
cancelPeripheralConnection
didDisconnectPeripheral
LATER, TO RE-CONNECT...
connectPeripheral:peripheral
- from array with peripheraldidConnectPeripheral:(CBPeripheral *)peripheral
...