In my project, I managed to connect to the Bluetooth LE peripheral peripheral device and the finished value CBCharacteristic
from this device. I ran into a problem. I need to disconnect the peripheral device and reconnect the device if I want.
I am using the following steps.
1. To disconnect : I'm calling
centralManager?.cancelPeripheralConnection(peripheral)
. This call successfully completes the delegate callfunc centralManager(central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: NSError?)
2. To reconnect : I run a scan for peripheral devices, as it was when I started the applicationcentralManager!.scanForPeripheralsWithServices(nil, options: nil)
But this call never calls a delegate func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber)
where I try to connect a detected BLE peripheral.
My question is what is the best way to disconnect a BLE peripheral device and reconnect it again in iOS. Am I doing something wrong?
source
share