菜鸟教程小白 发表于 2022-12-13 00:48:04

ios - 如何过滤心率监测器


                                            <p><p>我正在尝试使用 CoreBluetooth API 连接到心率监测器。 </p>

<p>根据蓝牙规范,心率监测服务是<a href="https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx" rel="noreferrer noopener nofollow">0x180D</a> .要了解蓝牙设备有哪些服务,您可以连接到它,然后请求可用的服务。如果设备服务之一是 <a href="https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx" rel="noreferrer noopener nofollow">0x180D</a>你有一个心率监测器。不幸的是,这意味着要连接到附近的所有蓝牙设备来过滤心率监测器。</p>

<p>好在iOS有如下方法<a href="https://developer.apple.com/Library/ios/documentation/CoreBluetooth/Reference/CBCentralManager_Class/translated_content/CBCentralManager.html#//apple_ref/occ/instm/CBCentralManager/scanForPeripheralsWithServices:options:" rel="noreferrer noopener nofollow">-scanForPeripheralsWithServices:</a>它会扫描广告特定服务的蓝牙设备。我遇到的问题是一些心率监测器宣传他们的服务,但有些没有。</p>

<p>其他应用如何连接到心率监测器?他们是否连接到附近的每个蓝牙设备以发现它是否是心率监测器?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>核心蓝牙只能根据它知道的数据进行过滤。如果设备宣传 180D 服务,那么您的应用会在过滤时发现它。如果设备不宣传 180D,则 CB(或其他任何设备)没有其他信息可以使其有资格被选中。 </p>

<p>因此,检测所有设备的唯一方法是扫描而不过滤特定服务。这是最简单、最有效的方法。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何过滤心率监测器,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/25324692/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/25324692/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何过滤心率监测器