相关疑难解决方法(0)

核心蓝牙 - 范围内设备的不断RSSI更新

我刚刚开始使用iOS的核心蓝牙框架,我正在开发一个需要不断扫描BLE设备的应用程序,以便我可以每分钟检索一次RSSI编号.

目前我有:

manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[manager scanForPeripheralsWithServices:nil options:options];
Run Code Online (Sandbox Code Playgroud)

这启动我的应用程序扫描BLE设备并在发现设备时调用此委托方法:

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
    NSLog(@"Did discover peripheral. peripheral: %@ rssi: %@, UUID: %@ advertisementData: %@ ", peripheral, RSSI, peripheral.UUID, advertisementData);
    //Do something when a peripheral is discovered.

    rssiLabel.text = [RSSI stringValue];

    [manager retrievePeripherals:[NSArray arrayWithObject:(id)peripheral.UUID]];}
Run Code Online (Sandbox Code Playgroud)

这个方法得到我可以显示的外围设备的RSSI号码.最后一行然后调用此委托方法:

- (void) centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals {

    NSLog(@"Currently known peripherals :");
    int i = 0;
    for(CBPeripheral *peripheral in peripherals) …
Run Code Online (Sandbox Code Playgroud)

ios ios5 core-bluetooth

14
推荐指数
1
解决办法
2万
查看次数

iOS 8 CoreBluetooth不推荐使用RSSI方法

所以从阅读CBPeripheralDelegate文档,它看起来RSSIperipheralDidUpdateRSSI:error:被抛弃了与iOS 8.

我注意到我的信号强度指示器不再被更新,所以我做了一些研究并发现了一个新的方法([CBPeripheralDelegate peripheral:didReadRSSI:error:]),它应该在调用readRSSI方法后异步调用.不幸的是,即使我确实将父类设置为CBPeripheral委托,这种方法似乎也没有被回调.

有没有其他人有iOS 8 CoreBluetooth更新的问题?

objective-c ios core-bluetooth ios8

6
推荐指数
1
解决办法
5881
查看次数

标签 统计

core-bluetooth ×2

ios ×2

ios5 ×1

ios8 ×1

objective-c ×1