[英]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. 我正在Swift 5中创建一个iOS应用,可以连接到我的BLE设备,但无法断开连接。 I found a function
cancelPeripheralConnection
on the apple developer website but Xcode does not seem to recognize it. 我在苹果开发人员网站上找到了一个
cancelPeripheralConnection
函数,但Xcode似乎无法识别它。 When I type CBCentralManager
the function appears and I can fill in the value to be passed but I keep getting an error. 当我键入
CBCentralManager
将出现该函数,我可以填写要传递的值,但会不断收到错误。
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.
因此,您必须使用它断开外围设备的连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.