【发布时间】:2015-10-02 18:54:52
【问题描述】:
【问题讨论】:
标签: ios swift bluetooth bluetooth-lowenergy core-bluetooth
【问题讨论】:
标签: ios swift bluetooth bluetooth-lowenergy core-bluetooth
我最近在我的开发板上测试 BLE 配置文件时,使用该应用 (LightBlue) 看到了相同的结果。
我注意到,根据 UUID 的设置方式,有时该应用可以识别出具有 BLE 配置文件的外围设备,但随后会报告其中没有服务。当我询问外围设备时,我的个人资料的“服务”将与特征混为一谈。
我怀疑您正在查看的 Apple TV 确实具有 BLE 服务,但由于 LightBlue 应用程序正在对信息进行分类,它以某种方式错过了该服务,但可以正确地看到其中的特征。
最后,在相关说明中,如果您在 iOS 上实现自己的 BLE 处理程序代码,那么您应该限制您正在寻找的服务。例如,如果您有以下内容:
centralManager.scanForPeripheralsWithServices(nil, options: nil)
在您的 Swift 代码中(我怀疑 LightBlue 会这样做),考虑将第一个 nil 参数替换为您正在寻找的服务的 CBUUID。当您扫描附近的所有 BLE 服务时,会发生奇怪的错误事情。
【讨论】:
斯威夫特 3
var bleCentralManager:CBCentralManager!
@IBAction func btnScan(_ sender: UIButton){
//for scan peripheral(BLE) device
self.bleCentralManager.scanForPeripherals(withServices: nil, options: nil)
}
【讨论】: