简体   繁体   中英

How to disconnect BLE device in Swift 5

I am creating an iOS app in Swift 5 and can connect to my BLE device but can not disconnect. I found a function cancelPeripheralConnection on the apple developer website but Xcode does not seem to recognize it. When I type CBCentralManager the function appears and I can fill in the value to be passed but I keep getting an error.

Below are some picture of the code and the problem.

在此处输入图片说明

Try this :

centralManager.cancelPeripheralConnection(yourPeripheral)

Your manager is an object used to manage discovered or connected remote peripheral devices. So you have to use it to disconnect a peripheral.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM