简体   繁体   English

我应该如何将多个BLE外围设备连接到iOS设备?

[英]How should I connect multiple BLE peripherals to an iOS device?

Currently my team is calling 目前我的团队正在打电话

[myCentralManager scanForPeripheralsWithServices:nil options:nil];

and then starting an NSTimer that fires in two seconds. 然后启动一个在两秒内触发的NSTimer During these two seconds, the Central Manager delegate method 在这两秒钟内,Central Manager委托方法

centralManager:didDiscoverPeripheral:advertisementData:RSSI:

is used to create an array of CBPeripherals that we are interested in. 用于创建我们感兴趣的CBPeripherals数组。

When the timer fires, we call connectPeripheral on every item in the array within a for loop. 当计时器触发时,我们在for循环中对数组中的每个项目调用connectPeripheral

I am worried that this is not the best way to connect to several devices at once. 我担心这不是一次连接多个设备的最佳方式。 Should we wait for one device's connection process to complete before calling connectPeripheral on another device? 我们是否应该在另一台设备上调用connectPeripheral之前等待一个设备的连接过程完成?

Thanks for any suggestions. 谢谢你的任何建议。

Have you experienced issues? 你遇到过问题吗? If not, then do it the way you do. 如果没有,那就按照你的方式去做。

Some additional thoughts: 一些额外的想法:

  • Generally, it is advised to stop scanning before starting a connection request. 通常,建议在开始连接请求之前停止扫描。 The connection will be established significantly faster this way. 通过这种方式可以显着加快连接速度。
  • Starting multiple connections at once has no implications from the API side, however, it's possibly safer (from a robustness point of view) to do it sequentially. 一次启动多个连接对API方没有任何影响,但是,从稳健性的角度来看,顺序执行它可能更安全。 This way you can prevent overloading the Core Bluetooth stack. 这样您就可以防止核心蓝牙堆栈过载。
  • Instead of an NSTimer, I'd rather use the GCD dispatch_after function but this is my personal preference. 而不是NSTimer,我宁愿使用GCD dispatch_after函数,但这是我个人的偏好。 (Using ReactiveCocoa would be even better.) (使用ReactiveCocoa会更好。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我知道iOS中该BLE设备的MAC地址,如何区分该连接到哪个BLE设备外围设备? - How to differentiate to which BLE device's peripheral should I connect If I know mac address of that BLE device in iOS? 我应该在用于 OBDII 的 BLE IOS 设备中使用什么 BLE 特性 - What BLE characteristic should I use in a BLE IOS device for OBDII 单个BLE中心可以通过蓝牙低功耗与多个BLE外设连接吗? - Can a single BLE central connect with multiple BLE peripherals via bluetooth low energy? 如何在iOS上搜索和连接附近的经典蓝牙设备(Not BLE)? - How to search and connect nearby bluetooth device classic (Not BLE) on iOS? 如何在 iOS Swift 中第二次连接到 BLE 设备 - How to connect to a BLE device the second time in iOS Swift 在后台iOS中重新连接BLE设备 - Re-Connect BLE device in background iOS 在iOS应用中自动连接到BLE设备 - Auto connect to BLE device in iOS app 使用MAC ios连接到BLE设备 - Connect to a BLE device using MAC ios 如何通过 BLE(低功耗蓝牙)将 Android 设备连接到 iOS 设备 - How to connect Android device to an iOS device over BLE (Bluetooth Low Energy) 如何使用 Xcode CoreBluetooth 将多个外围设备连接到中央节点? - How to connect multiple peripherals to central node using Xcode CoreBluetooth?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM