扫描外设广播详解

2024-06-06 01:12
文章标签 广播 详解 扫描 外设

本文主要是介绍扫描外设广播详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

        • 扫描外设广播详解
          • 一、接口说明
          • 二、Options说明
            • 1、CBCentralManagerScanOptionAllowDuplicatesKey
            • 2、CBCentralManagerScanOptionSolicitedServiceUUIDsKey

扫描外设广播详解
一、接口说明
/*!*  @method scanForPeripheralsWithServices:options:**  @param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.*  @param options      An optional dictionary specifying options for the scan.**  @discussion         Starts scanning for peripherals that are advertising any of the services listed in <i>serviceUUIDs</i>. Although strongly discouraged,*                      if <i>serviceUUIDs</i> is <i>nil</i> all discovered peripherals will be returned. If the central is already scanning with different*                      <i>serviceUUIDs</i> or <i>options</i>, the provided parameters will replace them.*                      Applications that have specified the <code>bluetooth-central</code> background mode are allowed to scan while backgrounded, with two*                      caveats: the scan must specify one or more service types in <i>serviceUUIDs</i>, and the <code>CBCentralManagerScanOptionAllowDuplicatesKey</code>*                      scan option will be ignored.**  @see                centralManager:didDiscoverPeripheral:advertisementData:RSSI:*  @seealso            CBCentralManagerScanOptionAllowDuplicatesKey*    @seealso            CBCentralManagerScanOptionSolicitedServiceUUIDsKey**/
- (void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options;

这个方法是支持后台扫描的,前提是工程开启了后台蓝牙模式。然后两个细节:

  1. 如果是后台扫描serviceUUIDs需要至少包含一个

  2. CBCentralManagerScanOptionAllowDuplicatesKey选项将被忽略

二、Options说明
1、CBCentralManagerScanOptionAllowDuplicatesKey
/*!*  **@const** CBCentralManagerScanOptionAllowDuplicatesKey**  **@discussion** An NSNumber (Boolean) indicating that the scan should run without duplicate filtering. By default, multiple discoveries of the*              same peripheral are coalesced into a single discovery event. Specifying this option will cause a discovery event to be generated* every time the peripheral is seen, which may be many times per second. This can be useful in specific situations, such as making* a connection based on a peripheral's RSSI, but may have an adverse affect on battery-life and application performance.**  **@see**        scanForPeripheralsWithServices:options:**/

这个选项是一个bool值。缺省是false,当发现多个相同的外设时候会合并为一个事件回调。当设置为true的时候,它会将多个相同的的外设单独回调,对设备电池寿命和应用的性能会有影响。但是某些需要通过RSSI来做业务需求的,又需要持续扫描。

2、CBCentralManagerScanOptionSolicitedServiceUUIDsKey
/*!*  **@const** CBCentralManagerScanOptionSolicitedServiceUUIDsKey**  **@discussion** An NSArray of <code>CBUUID</code> objects respresenting service UUIDs. Causes the scan to also look for peripherals soliciting* any of the services contained in the list.**  **@see**        scanForPeripheralsWithServices:options:**/

这个选项是一个bool值。外设建立连接时应用程序挂起,系统会给定外设的连接警报。

这篇关于扫描外设广播详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1034692

相关文章

一文详解如何在idea中快速搭建一个Spring Boot项目

《一文详解如何在idea中快速搭建一个SpringBoot项目》IntelliJIDEA作为Java开发者的‌首选IDE‌,深度集成SpringBoot支持,可一键生成项目骨架、智能配置依赖,这篇文... 目录前言1、创建项目名称2、勾选需要的依赖3、在setting中检查maven4、编写数据源5、开启热

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

Python中使用uv创建环境及原理举例详解

《Python中使用uv创建环境及原理举例详解》uv是Astral团队开发的高性能Python工具,整合包管理、虚拟环境、Python版本控制等功能,:本文主要介绍Python中使用uv创建环境及... 目录一、uv工具简介核心特点:二、安装uv1. 通过pip安装2. 通过脚本安装验证安装:配置镜像源(可

C++ 函数 strftime 和时间格式示例详解

《C++函数strftime和时间格式示例详解》strftime是C/C++标准库中用于格式化日期和时间的函数,定义在ctime头文件中,它将tm结构体中的时间信息转换为指定格式的字符串,是处理... 目录C++ 函数 strftipythonme 详解一、函数原型二、功能描述三、格式字符串说明四、返回值五

LiteFlow轻量级工作流引擎使用示例详解

《LiteFlow轻量级工作流引擎使用示例详解》:本文主要介绍LiteFlow是一个灵活、简洁且轻量的工作流引擎,适合用于中小型项目和微服务架构中的流程编排,本文给大家介绍LiteFlow轻量级工... 目录1. LiteFlow 主要特点2. 工作流定义方式3. LiteFlow 流程示例4. LiteF

CSS3中的字体及相关属性详解

《CSS3中的字体及相关属性详解》:本文主要介绍了CSS3中的字体及相关属性,详细内容请阅读本文,希望能对你有所帮助... 字体网页字体的三个来源:用户机器上安装的字体,放心使用。保存在第三方网站上的字体,例如Typekit和Google,可以link标签链接到你的页面上。保存在你自己Web服务器上的字

MySQL存储过程之循环遍历查询的结果集详解

《MySQL存储过程之循环遍历查询的结果集详解》:本文主要介绍MySQL存储过程之循环遍历查询的结果集,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录前言1. 表结构2. 存储过程3. 关于存储过程的SQL补充总结前言近来碰到这样一个问题:在生产上导入的数据发现

MyBatis ResultMap 的基本用法示例详解

《MyBatisResultMap的基本用法示例详解》在MyBatis中,resultMap用于定义数据库查询结果到Java对象属性的映射关系,本文给大家介绍MyBatisResultMap的基本... 目录MyBATis 中的 resultMap1. resultMap 的基本语法2. 简单的 resul

从基础到进阶详解Pandas时间数据处理指南

《从基础到进阶详解Pandas时间数据处理指南》Pandas构建了完整的时间数据处理生态,核心由四个基础类构成,Timestamp,DatetimeIndex,Period和Timedelta,下面我... 目录1. 时间数据类型与基础操作1.1 核心时间对象体系1.2 时间数据生成技巧2. 时间索引与数据