• <bdo id='0n6pz'></bdo><ul id='0n6pz'></ul>

      <small id='0n6pz'></small><noframes id='0n6pz'>

      <legend id='0n6pz'><style id='0n6pz'><dir id='0n6pz'><q id='0n6pz'></q></dir></style></legend>

      <i id='0n6pz'><tr id='0n6pz'><dt id='0n6pz'><q id='0n6pz'><span id='0n6pz'><b id='0n6pz'><form id='0n6pz'><ins id='0n6pz'></ins><ul id='0n6pz'></ul><sub id='0n6pz'></sub></form><legend id='0n6pz'></legend><bdo id='0n6pz'><pre id='0n6pz'><center id='0n6pz'></center></pre></bdo></b><th id='0n6pz'></th></span></q></dt></tr></i><div id='0n6pz'><tfoot id='0n6pz'></tfoot><dl id='0n6pz'><fieldset id='0n6pz'></fieldset></dl></div>
    1. <tfoot id='0n6pz'></tfoot>

        核心蓝牙 - 范围内设备的持续 RSSI 更新

        时间:2023-05-31
        • <bdo id='ymFbG'></bdo><ul id='ymFbG'></ul>
          <legend id='ymFbG'><style id='ymFbG'><dir id='ymFbG'><q id='ymFbG'></q></dir></style></legend>
            <tbody id='ymFbG'></tbody>

            <i id='ymFbG'><tr id='ymFbG'><dt id='ymFbG'><q id='ymFbG'><span id='ymFbG'><b id='ymFbG'><form id='ymFbG'><ins id='ymFbG'></ins><ul id='ymFbG'></ul><sub id='ymFbG'></sub></form><legend id='ymFbG'></legend><bdo id='ymFbG'><pre id='ymFbG'><center id='ymFbG'></center></pre></bdo></b><th id='ymFbG'></th></span></q></dt></tr></i><div id='ymFbG'><tfoot id='ymFbG'></tfoot><dl id='ymFbG'><fieldset id='ymFbG'></fieldset></dl></div>

                <small id='ymFbG'></small><noframes id='ymFbG'>

                <tfoot id='ymFbG'></tfoot>
                1. 本文介绍了核心蓝牙 - 范围内设备的持续 RSSI 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我刚开始使用 iOS 的核心蓝牙框架,我正在开发一个需要不断扫描 BLE 设备的应用程序,以便我可以每分钟左右检索它们的 RSSI 编号.

                  I just started with the core bluetooth framework for iOS and I'm developing an app that needs to constantly scan for BLE devices so that I can retrieve their RSSI number every minute or so.

                  目前我有:

                  manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
                  NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
                  [manager scanForPeripheralsWithServices:nil options:options];
                  

                  这将启动我的应用程序扫描 BLE 设备并在发现设备时调用此委托方法:

                  this starts my app scanning for BLE devices and calls this delegate method when a device is discovered:

                  - (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]];}
                  

                  这个方法可以得到我可以显示的外围设备的 RSSI 号码.最后一行然后调用这个委托方法:

                  this method gets me the peripheral's RSSI number which i can display. The last line then calls this delegate method:

                  - (void) centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals {
                  
                      NSLog(@"Currently known peripherals :");
                      int i = 0;
                      for(CBPeripheral *peripheral in peripherals) {
                          NSLog(@"[%d] - peripheral : %@ with UUID : %@",i,peripheral,peripheral.UUID);
                  
                      }
                  
                       NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
                       [manager scanForPeripheralsWithServices:nil options:options];
                  
                  }
                  

                  这段代码似乎在工作,并且大约每 1 分钟扫描一次,但我不知道它为什么工作......

                  This code seems to be working and doing a scan roughly every 1 minute, but I don't exactly know why it working...

                  关于核心蓝牙的文档非常少,所以如果有人对如何做到这一点有任何想法,或者有更好的方法来完成我想要完成的工作,我将不胜感激!

                  The documentation on core bluetooth is pretty sparse so if anyone has any idea on how to do this, or has a better way to do what I'm trying to accomplish I'd appreciate the help!

                  推荐答案

                  你试过把扫描选项改成YES吗?

                  Have you tried changing the scan option to YES?

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

                  如果您这样做,您的 iPhone 看到的每个广告包都会收到您的didDiscoverPeripheral"回调,通常大约每 100 毫秒(尽管我发现对于同一设备,此回调时间变化很大).这包括它看到的每个设备的 RSSI.

                  If you do this you will get your "didDiscoverPeripheral" callback with every ad packet that is seen by your iPhone, which would normally be about every 100ms (although I see this callback timing varying a lot for the same device). This includes the RSSI of each device it sees.

                  这应该比您大约 1 分钟的更新速度快很多.

                  This should be a lot faster than your ~1 minute update rate.

                  这篇关于核心蓝牙 - 范围内设备的持续 RSSI 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在没有开发人员程序的设备上安装 iOS 应用程序, 下一篇:iOS 5 SDK 中的容器视图是什么?

                  相关文章

                  最新文章

                2. <i id='NzdS4'><tr id='NzdS4'><dt id='NzdS4'><q id='NzdS4'><span id='NzdS4'><b id='NzdS4'><form id='NzdS4'><ins id='NzdS4'></ins><ul id='NzdS4'></ul><sub id='NzdS4'></sub></form><legend id='NzdS4'></legend><bdo id='NzdS4'><pre id='NzdS4'><center id='NzdS4'></center></pre></bdo></b><th id='NzdS4'></th></span></q></dt></tr></i><div id='NzdS4'><tfoot id='NzdS4'></tfoot><dl id='NzdS4'><fieldset id='NzdS4'></fieldset></dl></div>

                  <small id='NzdS4'></small><noframes id='NzdS4'>

                  <legend id='NzdS4'><style id='NzdS4'><dir id='NzdS4'><q id='NzdS4'></q></dir></style></legend>

                      • <bdo id='NzdS4'></bdo><ul id='NzdS4'></ul>
                    1. <tfoot id='NzdS4'></tfoot>