【发布时间】:2013-03-10 13:07:41
【问题描述】:
我正在使用 Corebluetooth 框架开发应用程序,
并连接到 BLE 设备以获取 RSSI 值。
我设置了一个定时读取RSSI的函数,下面是定时器代码
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:1.2f target:self selector:@selector(detectRSSI) userInfo:nil repeats:YES];
detectRSSI 代码如下
- (void)detectRSSI
{
[self.peripheral readRSSI];
}
所以问题是,
该功能工作正常,但是当我设置的时间间隔小于 1.2 秒时,
peripheralDidUpdateRSSI 会随机报如下错误信息:
The operation was cancelled.
如果速率超过 1.2 秒,则不会发生。
有谁知道更频繁地读取 RSSI 值(0.5 秒或更短)?
【问题讨论】:
-
或许可以试试:peripheral.RSSI
-
如果我只调用 [peripheral RSSI] 或 peripheral.RSSI,RSSI 不会改变。调用[peripheral readRSSI]后会更新值。最后我找到了读取频率限制由固件定义的答案。
-
如果您使用 BLE,请使用
didRangeBeacons:。设备每秒只能扫描这么多次。
标签: ios xcode4.5 core-bluetooth bluetooth-lowenergy rssi