简体   繁体   English

scanForPeripheralsWithServices:options:和CBCentralManagerScanOptionSolicitedServiceUUIDsKey

[英]scanForPeripheralsWithServices:options: and CBCentralManagerScanOptionSolicitedServiceUUIDsKey

I have a question that I got by reading Apple's documentation. 我通过阅读Apple的文档得到了一个问题。 When it comes to CBCentralManagerScanOptionSolicitedServiceUUIDsKey Apple's documentation states: 说到CBCentralManagerScanOptionSolicitedServiceUUIDsKey Apple的文档说明:

An array (an instance of NSArray) of service UUIDs (represented by CBUUID objects) that you want to scan for. 要扫描的服务UUID(由CBUUID对象表示)的数组(NSArray实例)。

Specifying this scan option causes the central manager to also scan for peripherals soliciting any of the services contained in the array. 指定此扫描选项会导致中央管理器也扫描外围设备,请求获取阵列中包含的任何服务。

On regard of scanForPeripheralsWithServices:options: 's first argument, however: 关于scanForPeripheralsWithServices:options:的第一个参数,但是:

An array of CBUUID objects that the app is interested in. In this case, each CBUUID object represents the UUID of a service that a peripheral is advertising. 应用程序感兴趣的一组CBUUID对象。在这种情况下,每个CBUUID对象表示外围设备正在通告的服务的UUID。

So what's the difference? 那有什么区别? Why use one or the other? 为什么要使用其中一个?

Typically the Bluetooth peripheral advertises services and the central scans for those services. 通常,蓝牙外围设备通告服务以及这些服务的中央扫描。 This is the case covered by the first parameter. 这是第一个参数所涵盖的情况。

In some cases, however, the behaviour is reversed - the central offers the service and the peripheral looks for it. 然而,在某些情况下,行为是相反的 - 中央提供服务,外围设备寻找它。 This is called service solicitation. 这称为服务请求。 When you supply an array of service identifiers using CBCentralManagerScanOptionSolicitedServiceUUIDsKey you are providing the list of services that the central will 'advertise' to peripherals. 当您使用CBCentralManagerScanOptionSolicitedServiceUUIDsKey提供服务标识符数组时,您将提供中央将“通告”给外围设备的服务列表。

It is still the responsibility of the central to initiate the connection, so once a peripheral is identified that is soliciting for one of those services, you will receive a call to the didDiscoverPeripheral method as per usual. 启动连接仍然是中心的责任,因此一旦识别出正在寻求其中一个服务的外围设备,您将按照惯例接收对didDiscoverPeripheral方法的调用。

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

相关问题 iOS BLE scanForPeripheralsWithServices:options:在背景上 - IOS BLE scanForPeripheralsWithServices:options: on Background self.manager.scanForPeripheralsWithServices(nil,选项:nil)错误 - self.manager.scanForPeripheralsWithServices(nil, options: nil) error CBCentralManagerScanOptionSolicitedServiceUUIDsKey的目的 - Purpose of CBCentralManagerScanOptionSolicitedServiceUUIDsKey 没有发现nil参数的scanForPeripheralsWithServices - scanForPeripheralsWithServices with nil argument not discovering iOS蓝牙scanForPeripheralsWithServices没有结果 - iOS bluetooth scanForPeripheralsWithServices no results CoreBluetooth:scanForPeripheralsWithServices无法与服务数组一起使用 - CoreBluetooth: scanForPeripheralsWithServices not working with service array iOS核心蓝牙CBCentralManager scanForPeripheralsWithServices没有结果 - iOS core bluetooth CBCentralManager scanForPeripheralsWithServices no results iOS上的scanForPeripheralsWithServices无法通过服务UUID查找设备 - scanForPeripheralsWithServices on iOS not finding devices by service UUID CBCentralManager scanForPeripheralsWithServices:nil不返回任何结果 - CBCentralManager scanForPeripheralsWithServices:nil is not returning any results 如何判断CBCentralManager是否仍在处理scanForPeripheralsWithServices? - How to tell if CBCentralManager is still processing scanForPeripheralsWithServices?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM