gpt4 book ai didi

ios - 在某些 iOS 设备中无法连接到 BLE 外设

转载 作者:行者123 更新时间:2023-12-04 14:07:12 26 4
gpt4 key购买 nike

BLE 在 7 Plus (iOS 14.4.2) 和 6 (iOS 12) 上运行良好。但是在 XR (14.4.2) 上,11 连接卡在 centralManager.connect(peripheral, options: nil)(无限连接)

之后

外围设备处于连接模式,因为其他智能手机无法检测到它。一开始以为是外围设备本身的radio模块(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 的最普通的代码。

关于ios - 在某些 iOS 设备中无法连接到 BLE 外设,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67587818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com