BLE外围设备如何使用广告包在锁屏模式下向iphone(BLE中心)应用程序发送数据?

BLE外围设备如何使用广告包在锁屏模式下向iphone(BLE中心)应用程序发送数据?,iphone,Iphone,iphone应用程序如何在锁屏模式下从BLE外围设备接收广告包 BLE外围设备(芯片nRF51822)每30分钟向iphone应用程序发送一次带有温度数据的广告包 我的代码: UInt16 service2 = BLE_UUID_HEALTH_THERMOMETER_SERVICE; service2 = [self swap:service2]; NSData *serviceData2 = [[NSData alloc] initWithBytes:(char *)&

iphone应用程序如何在锁屏模式下从BLE外围设备接收广告包

BLE外围设备(芯片nRF51822)每30分钟向iphone应用程序发送一次带有温度数据的广告包

我的代码:

UInt16 service2 = BLE_UUID_HEALTH_THERMOMETER_SERVICE;
    service2 = [self swap:service2];
    NSData *serviceData2 = [[NSData alloc] initWithBytes:(char *)&service2 length:2];
    NSArray *services = @[[CBUUID UUIDWithData:serviceData2]];
    [self.centeralManager scanForPeripheralsWithServices:services    options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];
iPhone应用程序在“后台模式”下运行良好,几乎没有广告包丢失

但当iphone屏幕变黑时,广告包数据丢失。 一旦我拉出iPhone的控制中心,或滑动解锁iPhone,应用程序就可以再次正常工作

在锁定屏幕的情况下,是否有ios应用程序获取BLE adv数据包的示例代码