你能在 Swift 中使用按钮扫描一定数量的外围设备吗?

问题描述 投票:0回答:0

我正在尝试按下一个连接按钮,该按钮将使我能够扫描并连接到 2 个 BLE 外围设备。目前,当我按下按钮时,它只会扫描并连接到 1 个外围设备,我必须再次按下它才能扫描并连接到第二个外围设备。我不明白我错过了什么。

@IBAction func scanFeathers() {
    //disable other buttons while scanning for feather 1
    disconnectFeather1.isEnabled = false
    disconnectFeather2.isEnabled = false
    
    //assign feather uuid
    nodeService = featherService
    
    //start activity indicator
    activityIndicator1.startAnimating()
    
    //scan for peripherals
    centralManager.scanForPeripherals(withServices: [nodeService], options: [CBCentralManagerScanOptionAllowDuplicatesKey: NSNumber(0)])

    
}

这是我按下按钮的代码。

swift core-bluetooth
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.