Can';在某些iOS设备中,无法连接到BLE外围设备
BLE在7 Plus(iOS 14.4.2)和6(iOS 12)上运行良好。但在XR(14.4.2)和11上,连接在Can';在某些iOS设备中,无法连接到BLE外围设备,ios,swift,bluetooth-lowenergy,core-bluetooth,cbcentralmanager,Ios,Swift,Bluetooth Lowenergy,Core Bluetooth,Cbcentralmanager,BLE在7 Plus(iOS 14.4.2)和6(iOS 12)上运行良好。但在XR(14.4.2)和11上,连接在centralManager.connect(外围设备,选项:nil)之后卡住了(无限连接) 外围设备处于连接模式,因为其他智能手机无法检测到它。 起初我认为问题出在外围设备本身的无线电模块(NRF52)上,但调试板也出现了问题。 重新启动智能手机没有帮助。 有趣的是,该应用程序在带有M1芯片的MacBook上运行良好 代码的一部分: // Peripheral model in
centralManager.connect(外围设备,选项:nil)之后卡住了(无限连接)
外围设备处于连接模式,因为其他智能手机无法检测到它。
起初我认为问题出在外围设备本身的无线电模块(NRF52)上,但调试板也出现了问题。
重新启动智能手机没有帮助。
有趣的是,该应用程序在带有M1芯片的MacBook上运行良好
代码的一部分:
// Peripheral model
init(withPeripheral peripheral: CBPeripheral, advertisementData advertisementDictionary: [String : Any], andRSSI currentRSSI: NSNumber, using manager: CBCentralManager) {
centralManager = manager
basePeripheral = peripheral
RSSI = currentRSSI
super.init()
advertisedName = parseAdvertisementData(advertisementDictionary)
basePeripheral.delegate = self
}
public func connect() {
centralManager.delegate = self
centralManager.connect(basePeripheral, options: nil)
print("Connecting to \(advertisedName ?? "device")...")
// logs stops here
}
public func disconnect() {
centralManager.cancelPeripheralConnection(basePeripheral)
print("Cancelling connection with \(advertisedName ?? "device")...")
// triggers on VC dismiss
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if central.state != .poweredOn {
print("Central Manager stated changed to \(central.state)")
}
}
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
if peripheral == basePeripheral {
print("Connected to \(advertisedName ?? "device")")
delegate?.peripheralDidConnect()
discoverPrimaryServices()
}
}
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
if peripheral == basePeripheral {
print("Disconnected from \(advertisedName ?? "device")")
delegate?.peripheralDidDisconnect()
}
}
“外设处于连接模式,因为其他智能手机无法检测到它。”你是说其他智能手机可以检测到它吗
考虑到您列出的正在使用和未使用的手机,我预计您的董事会在蓝牙5(最初在iPhone 8上支持)方面会遇到问题。NRF52支持BT5(它支持5.2),但如果您已经编写了自己的固件,则可能已经破坏了该支持。首先,我要确保您运行的是Nordic提供的最普通的代码。我的意思是,当外围设备在连接到智能手机的阶段冻结时,它会从扫描仪中消失,也就是说,它似乎工作正常,没有错误和断开连接,在某些设备上根本无法完全连接。我写的代码基于NRF BLIMKY应用程序,当然,它是相当大的修改,但基础和一般模式保持不变。事实上,我替换了UUID服务和特性,并添加了许多我自己的服务和特性。你说问题可能出在主板本身的固件上,我会尝试在那里查找问题,谢谢你,因此我们安装了NRF52(UART)的原始固件,我们的软件就是基于此编写的,连接是成功的,显然问题确实出在外围设备方面。谢谢你的提示!