从iOS在后台扫描Bluetooth LE设备

固体软

我正在努力在后台模式下扫描BLE。

问题在后台扫描中不起作用。它在前景模式下工作得很好。

以下是几行代码。

dispatch_queue_t centralQueue = dispatch_queue_create("com.XXXXX.BLEback", DISPATCH_QUEUE_SERIAL);// or however you want to create your dispatch_queue_t
manager = [[CBCentralManager alloc] initWithDelegate:self queue:centralQueue options:nil];

- (void)centralManagerDidUpdateState:(CBCentralManager *)central 
{
    if (central.state == CBCentralManagerStatePoweredOn) {

        [self startScan];
    }

    if (![self supportLEHardware]) 
    {
        @throw ([NSError errorWithDomain:@"Bluetooth LE not supported"
                                    code:999
                                userInfo:nil]);
    }
}

- (void)startScan
{
    NSDictionary * options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:false] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
    [manager scanForPeripheralsWithServices:nil options:options];
}

在这里,我通过零作为服务。

我在Xcode的“设备”部分中收到日志。但不在应用程序中。

Notice>: (Error) Discovered unknown type for scan: {
        kCBAdvDataChannel = 37;
        kCBAdvDataIsConnectable = 1;
        kCBAdvDataManufacturerData = <00003962 6708f4c1 00000000 00d02b00 20d03300 20d03300 20>;
        kCBAdvDataWSaturated = 0;
        kCBAdvDataWlanRSSI = 0;
    }, -51, puck type: 57
Paulw11

您不能nil在后台扫描服务-您必须指定您感兴趣的服务。来自文档

指定了蓝牙中心背景模式的应用程序可以在后台扫描。也就是说,它们必须通过在serviceUUIDs参数中指定它们来显式扫描一个或多个服务。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在后台扫描 BLE 设备?

来自分类Dev

iOS:使用NSTimer写入Bluetooth LE设备

来自分类Dev

iOS 7 Core蓝牙外围设备在后台运行

来自分类Dev

iOS如何在后台重新连接到BLE设备?

来自分类Dev

在后台 iOS 中重新连接 BLE 设备

来自分类Dev

使用CoreBluetooth可以获取Bluetooth LE设备的原始扫描记录

来自分类Dev

Delphi android:关闭屏幕时无法扫描Bluetooth LE设备

来自分类Dev

蓝牙LE扫描未检测到设备

来自分类Dev

蓝牙LE后台扫描

来自分类Dev

使用iOS获取Bluetooth LE扫描响应数据

来自分类Dev

如何允许设备通过Bluetooth LE连接

来自分类Dev

在后台使用iOS设备的加速度计

来自分类Dev

可以在后台运行并可以连接到设备的IOS应用程序

来自分类Dev

连接到iOS的蓝牙外围设备无法在后台运行

来自分类Dev

如何通过dbus API扫描蓝牙LE设备?

来自分类Dev

如何在运行时确定iOS设备是否支持Bluetooth LE

来自分类Dev

如何使用Bluetooth LE iOS在表视图上显示找到的设备列表

来自分类Dev

Android设备(Bluetooth LE)的wav文件的升采样

来自分类Dev

Android设备(Bluetooth LE)的wav文件的升采样

来自分类Dev

Android KitKat是否允许支持Bluetooth LE的设备充当外围设备?

来自分类Dev

在后台模式下连接的外围设备(Core蓝牙)

来自分类Dev

Swift CoreMotion在后台时检测设备上的点击或敲门

来自分类Dev

我的IntentService在后台如何始终收听设备的震动?

来自分类Dev

无法在后台从设备导出视频文件

来自分类Dev

在后台模式下连接的外围设备(核心蓝牙)

来自分类Dev

您可以在iOS应用中将蓝牙LE设备配对吗

来自分类Dev

在后台运行应用程序但在模拟器上但不在设备上运行(iOS 9)时更新位置

来自分类Dev

iOS是否可以通过指定)(CBPeripheral *)peripheral而不是retrievePeripherals来重新连接到Bluetooth LE外围设备?

来自分类Dev

iOS是否可以通过指定)(CBPeripheral *)peripheral而不是retrievePeripherals来重新连接到Bluetooth LE外围设备?

Related 相关文章

  1. 1

    如何在后台扫描 BLE 设备?

  2. 2

    iOS:使用NSTimer写入Bluetooth LE设备

  3. 3

    iOS 7 Core蓝牙外围设备在后台运行

  4. 4

    iOS如何在后台重新连接到BLE设备?

  5. 5

    在后台 iOS 中重新连接 BLE 设备

  6. 6

    使用CoreBluetooth可以获取Bluetooth LE设备的原始扫描记录

  7. 7

    Delphi android:关闭屏幕时无法扫描Bluetooth LE设备

  8. 8

    蓝牙LE扫描未检测到设备

  9. 9

    蓝牙LE后台扫描

  10. 10

    使用iOS获取Bluetooth LE扫描响应数据

  11. 11

    如何允许设备通过Bluetooth LE连接

  12. 12

    在后台使用iOS设备的加速度计

  13. 13

    可以在后台运行并可以连接到设备的IOS应用程序

  14. 14

    连接到iOS的蓝牙外围设备无法在后台运行

  15. 15

    如何通过dbus API扫描蓝牙LE设备?

  16. 16

    如何在运行时确定iOS设备是否支持Bluetooth LE

  17. 17

    如何使用Bluetooth LE iOS在表视图上显示找到的设备列表

  18. 18

    Android设备(Bluetooth LE)的wav文件的升采样

  19. 19

    Android设备(Bluetooth LE)的wav文件的升采样

  20. 20

    Android KitKat是否允许支持Bluetooth LE的设备充当外围设备?

  21. 21

    在后台模式下连接的外围设备(Core蓝牙)

  22. 22

    Swift CoreMotion在后台时检测设备上的点击或敲门

  23. 23

    我的IntentService在后台如何始终收听设备的震动?

  24. 24

    无法在后台从设备导出视频文件

  25. 25

    在后台模式下连接的外围设备(核心蓝牙)

  26. 26

    您可以在iOS应用中将蓝牙LE设备配对吗

  27. 27

    在后台运行应用程序但在模拟器上但不在设备上运行(iOS 9)时更新位置

  28. 28

    iOS是否可以通过指定)(CBPeripheral *)peripheral而不是retrievePeripherals来重新连接到Bluetooth LE外围设备?

  29. 29

    iOS是否可以通过指定)(CBPeripheral *)peripheral而不是retrievePeripherals来重新连接到Bluetooth LE外围设备?

热门标签

归档