Today the app writes about the Bluetooth re-connect phase, previously written for SDK 6.0, the Bluetooth device's reply is through
-(void) Retrieveperipherals:(nsarray *)peripheraluuids
And then callback
Centralmanager:didretrieveperipherals:
function to get an array that can reply to the device.
After SDK7,-(void) Retrieveperipherals:(nsarray *)peripheraluuids was abolished and replaced by
This function will returns a list of known peripherals by their identifiers.
At first I thought that the function was called, and the connection operation was done in the callback function, and it was later discovered that the callback function in SDK6.0 was to return a list of known peripherals by their identifiers. Instead of using the callback function now, Retrieveperipheralswithidentifiers: The return value is a list of known peripherals by their identifiers. This makes the code more concise, which allows direct connection to these peripherals.
The simple code is as follows:
var Identiferarray = array<nsuuid>() identiferarray.append (peri.identifer)// Add Identider to get Identiferarrayvar knownperipherals = mycentralmanager! . Retrieveperipheralswithidentifiers (Identiferarray) for inch knownperipherals { mycentralmanager!. Connectperipheral (P, options:nil)}
iOS8 Bluetooth Device reconnection (retrieve) Swift implementation