-(voID) disconnect { if (_selectedPeripheral != nil && _selectedPeripheral.state != CBperipheralstatedisconnected) { NSLog(@"Peripheral disconnecting"); [_centralManager cancelPeripheralConnection:_selectedPeripheral]; _selectedPeripheral = nil; } }
当我单击按钮时,上面的方法是调用和应用程序显示外围设备已断开连接,当我从应用程序中出来并查看设置/蓝牙/ .Peripheral正在显示已连接.如何停止连接外围设备级别,即在设置.请帮我解决问题.
解决方法 您无法保证系统级别与外围设备断开连接.这是直接来自CBCentralManager文档的链接:
cancelPeripheralConnection:
discussion
This method is nonblocking,and any CBPeripheral class
commands that are still pending to peripheral may or may not complete.
Because other apps may still have a connection to the peripheral,
canceling a local connection does not guarantee that the underlying
physical link is immediately disconnected. From the app’s perspective,
however,the peripheral is consIDered disconnected,and the central
manager object calls the centralManager:dIDdisconnectPeripheral:error:
method of its delegate object.
根据我的经验,如果您是使用外围设备的唯一应用程序,物理链接会很快断开连接,但如果您可能不像Apple明确指出的那样,其他应用程序可能会维持持久连接,这会导致物理链接不能尽管它已经向你说明它已经断开了.
总结以上是内存溢出为你收集整理的ios – CoreBluetooth:从应用程序断开外围设备连接全部内容,希望文章能够帮你解决ios – CoreBluetooth:从应用程序断开外围设备连接所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)