gpt4 book ai didi

swift - 如何在 iOS Swift 中获取蓝牙已打开的设备的名称

转载 作者:行者123 更新时间:2023-11-30 10:27:23 27 4
gpt4 key购买 nike

我想获取蓝牙设备上的所有内容。我正在使用 SwiftyBluetooth。

import SwiftyBluetooth

SwiftyBluetooth.scanForPeripherals(withServiceUUIDs: nil, timeoutAfter: 15) { scanResult in
switch scanResult {
case .scanStarted:
// The scan started meaning CBCentralManager scanForPeripherals(...) was called
print("scan Started")
case .scanResult(let peripheral, let advertisementData, let RSSI):

// A peripheral was found, your closure may be called multiple time with a .ScanResult enum case.
// You can save that peripheral for future use, or call some of its functions directly in this closure.
print("::::\(peripheral)")
self.peripheralArray.append(peripheral)
print("\(advertisementData)")
print("RSSI\(RSSI)")
case .scanStopped(let error):
print("error\(error)")
// The scan stopped, an error is passed if the scan stopped unexpectedly
}
}

此代码为我提供了 Mi 乐队和电视的名称,但没有提供 iPhone 或 Android 手机的名称,无论如何也可以获取手机。

最佳答案

关于swift - 如何在 iOS Swift 中获取蓝牙已打开的设备的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59857622/

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