[英]How to search and connect nearby bluetooth device classic (Not BLE) on iOS?
I need to search nearby by bluetooth device those are classic Bluetooth (Bluetooth 2.1 or later). 我需要通过蓝牙设备在附近搜索那些经典的蓝牙(蓝牙2.1或更高版本)。 I searched a lot but there are only library and discussion about the BLE any guidance will help me a lot.
我进行了很多搜索,但只有图书馆和关于BLE的讨论,任何指南都对我有很大帮助。
As far as I know, you can't find them until you don't manually pair and connect them. 据我所知,除非不手动配对并连接它们,否则您将找不到它们。 In order to discover the already paired and connected ones, I use this:
为了发现已经配对和连接的对象,我使用以下方法:
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.