I am working on a BLE iOS application (Swift) that has several ViewControllers. The main ViewController has a button that moves to the TableViewController, which has detected BLE devices to connect to. But when I return to the main or another kind, the peripheral device turns off. I tried to transfer the peripherals from the TableViewController to the main ViewController, but still it shuts down.
MainViewController:
var bleManager: BLEManager! var peripheral: CBPeripheral! override func viewDidLoad() { bleManager = BLEManager() super.viewDidLoad() } override func viewWillAppear(_ animated: Bool) { if let peripheral = self.peripheral { do { print("Value from display = \(peripheral.state)") } } } func setPeripheral(sent: CBPeripheral) { self.peripheral = sent } @IBAction func manageDevice(sender: UIButton) {
How to continue BLE on the next view controller
ios swift core-bluetooth
Maihan nijat
source share