【问题标题】:IOS Core bluetooth peripheral connection requestIOS Core蓝牙外设连接请求
【发布时间】:2013-08-07 08:05:38
【问题描述】:

我正在研究 corebluetooth 框架,如果两个 BLE 都可见,我可以发现并连接设备。现在我遇到了一个问题,一旦发现外围设备由于某种原因被关闭,我就能够发现设备现在我正在尝试使用连接该设备

[centralManager connectPeripheral:activePeripheral options:nil];

这个方法,但是外围不能连接,所以我需要先检查一下 连接是否可用外围设备。

谢谢

【问题讨论】:

  • 您想要可用的蓝牙设备列表吗?或者您需要检查指定设备?
  • 我有设备列表。一旦发现我的外围设备正在关闭,我正在尝试连接。

标签: iphone ios core-bluetooth


【解决方案1】:

你只有一种方法:

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI

如果您添加扫描选项,例如:

NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:@YES, CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[manager scanForPeripheralsWithServices:nil options:options];

然后会不断调用上述方法来更新外设的状态。然后你可以观察一段时间内没有调用该方法的外围设备,然后从列表中删除该外围设备

或者第二种选择是在连接到外围设备之前再次扫描它。

【讨论】:

    猜你喜欢
    • 2016-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-20
    • 2018-03-25
    • 1970-01-01
    • 2015-08-03
    相关资源
    最近更新 更多