Как я могу получить имена для устройств, Bluetooth которых включен в iOS Swift - PullRequest
0 голосов
/ 22 января 2020

Я хочу получить все на устройствах Bluetooth. Я использую 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, чтобы получить телефоны.

1 Ответ

0 голосов
/ 22 января 2020

Как сказано в документации, я предполагаю, что это имя ...?

http://cocoadocs.org/docsets/SwiftyBluetooth/1.0.0/Classes/Peripheral.html# / s: vC15SwiftyBluetooth10Peripheral4nameGSqSS_

...