gpt4 book ai didi

ios - scanForPeripheralsWithServices :options: and CBCentralManagerScanOptionSolicitedServiceUUIDsKey

转载 作者:可可西里 更新时间:2023-11-01 17:05:48 27 4
gpt4 key购买 nike

我在阅读 Apple 的文档时遇到了一个问题。关于 CBCentralManagerScanOptionSolicitedServiceUUIDsKey Apple 的文档指出:

An array (an instance of NSArray) of service UUIDs (represented by CBUUID objects) that you want to scan for.

Specifying this scan option causes the central manager to also scan for peripherals soliciting any of the services contained in the array.

关于 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.

那有什么区别呢?为什么使用其中之一?

最佳答案

通常,蓝牙外围设备会发布服务,而中央设备会扫描这些服务。这是第一个参数涵盖的情况。

然而,在某些情况下,行为是相反的——中央提供服务而外围寻找它。这称为服务请求。当您使用 CBCentralManagerScanOptionSolicitedServiceUUIDsKey 提供一组服务标识符时,您正在提供中央将“通告”给外围设备的服务列表。

启动连接仍然是中心的责任,因此一旦识别出正在请求其中一项服务的外围设备,您将像往常一样收到对 didDiscoverPeripheral 方法的调用.

关于ios - scanForPeripheralsWithServices :options: and CBCentralManagerScanOptionSolicitedServiceUUIDsKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31062176/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com