【发布时间】:2015-09-26 01:17:36
【问题描述】:
我想发现我所在地区的 BLE 设备并存储它们当前的 RSSI 值。发现有效,但我确定,如果我的函数 didDiscoverPeripheral 真的保存...我认为我应该在离开 didDiscoverPeripheral 之前等待 didReadRSSI 函数。但是我怎样才能以一种简单的方式意识到这一点,我的观点是否正确?
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber)
{
CBperipheral = [peripheral]
peripheral.readRSSI()
}
func peripheral(peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: NSError?)
{
//Store the peripheral specific RSSI, Name and identifier
}
【问题讨论】:
-
您不能在
didDiscoverPeripheral中“等待”。当它发生时,您需要处理对didReadRSSI的回调。您的didDiscoverPeripheral的第一行也没有任何意义。我建议您创建一个由外围设备键入的 RSSI 值字典。 -
请看我的回答:)
标签: ios swift bluetooth bluetooth-lowenergy core-bluetooth