【问题标题】:The BLE advertisement package getting frequency become very lowBLE广告包获取频率变得非常低
【发布时间】:2016-09-07 03:54:56
【问题描述】:

我的项目需要接收 BLE 广告包,并在不连接 BLE 设备的情况下处理 kCBAdvDataManufacturerData。BLE 设备每秒发送 1 次广告包。在空视图控制器中,我每秒接收 1 次广告包,但在我的我显示 BLE 广告包数据的控制器,我接收广告包的频率减少到 1 次/4 秒或更低。在这个控制器中,我发送一些 http 请求并使用 NSTimer 更新 UI 每秒 1 次。我在 dispatch_sync 中处理 kCBAdvDataManufacturerData (dispatch_get_global_queue(0, 0),并在 mainqueue 中更新 UI。 有没有人想提高接收BLE广告包的频率?

【问题讨论】:

    标签: ios bluetooth-lowenergy


    【解决方案1】:

    -1。首先你需要开始发现。

    -(void)startDiscovery
    {
    if (self.mBtmanager == nil) {
      _mScanState = false;
        self.mBtmanager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
        self.mBtmanager.delegate = self;
    }    
    if (self.mBtmanager.state != CBCentralManagerStatePoweredOn) {
        _mScanState = true;
    }
        NSDictionary *scanOption = @{CBCentralManagerScanOptionAllowDuplicatesKey:@YES};
    [self.mBtmanager scanForPeripheralsWithServices:[[NSArray alloc] initWithObjects:[CBUUID UUIDWithString:JAALEE_ADV_SERVICE_UUID_STRING], nil] options:scanOption];
    }
    

    - 2. 你需要连接到 Beacon。

    -(void)startConnectDevice:(CBPeripheral*)peripheral
    {
    peripheral.delegate = self;
    [self.mBtmanager connectPeripheral:peripheral options:nil];
    } 
    

    -3。然后使用 writeServicesUUID 更改广播间隔

     [peripheral writeValue:value forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
    

    -最后 CONFIGURE_BROADCAST_INTERVAL_CHARACTERISTIC_ 会帮助你。

    【讨论】:

    • 我解决了这个问题,还是谢谢你的关注。
    猜你喜欢
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 2019-04-24
    • 2014-02-03
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    相关资源
    最近更新 更多