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

问题描述:

我需要通过蓝牙设备在附近搜索那些经典的蓝牙(蓝牙2.1或更高版本)。我搜索了很多,但只有图书馆和关于BLE的讨论,任何指导都会帮助我很多。如何在iOS上搜索和连接附近的蓝牙设备classic(Not BLE)?

+1

MFI蓝牙设备可以通过iOS的发现。有关可用设备的列表,请查看此链接:http://*.com/questions/20654123/how-to-list-out-all-mfi-devies-into-the-ios-app/20654221#20654221 – brianLikeApple

据我所知,你不能找到他们,直到你不手动配对和连接它们。为了发现已经配对和连接的,我用这个:

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") } 
} 

`