相关疑难解决方法(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获取蓝牙LE扫描响应数据

我正在使用蓝牙低功耗设备,我想知道是否可以在没有连接的情况下将扫描响应数据读取到具有iOS和Core蓝牙的广告.

我知道在阅读广告数据包后,您可以以31字节扫描响应的格式从外设请求其他数据.我知道Core Bluetooth建议如果广告包已满,您可以将本地名称放在扫描响应数据包中,但它是否允许您查看整个数据包?

bluetooth ios core-bluetooth bluetooth-lowenergy ibeacon

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