繁体   English   中英

如何在iOS上搜索和连接附近的经典蓝牙设备(Not BLE)?

[英]How to search and connect nearby bluetooth device classic (Not BLE) on iOS?

我需要通过蓝牙设备在附近搜索那些经典的蓝牙(蓝牙2.1或更高版本)。 我进行了很多搜索,但只有图书馆和关于BLE的讨论,任何指南都对我有很大帮助。

据我所知,除非不手动配对并连接它们,否则您将找不到它们。 为了发现已经配对和连接的对象,我使用以下方法:

import AVFoundation
func example() {
    let session = AVAudioSession.sharedInstance()
    do {
        try session.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
        if let inputs = session.availableInputs { ... } //should contain bluetooth devices aswell
    }
    catch { print("Failed to set category") }
}

`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM