gpt4 book ai didi

ios - scanForPeripheralsWithServices :return result twice on the same peripheral

转载 作者:可可西里 更新时间:2023-11-01 05:55:20 26 4
gpt4 key购买 nike

我使用下面的代码

[centralManager scanForPeripheralsWithServices:serviceUUIDArray 
options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
forKey:CBCentralManagerScanOptionAllowDuplicatesKey]]

扫描外围设备,然后在同一个外围设备上返回两次结果。如何返回?谢谢。

最佳答案

发生这种情况是因为外围设备的名称已更新。在这种情况下,您会再次收到回调。

此线程包含详细说明:http://lists.apple.com/archives/bluetooth-dev/2013/Apr/msg00099.html

感谢 Etan Kissling:

The device name is cached by iOS according to a priority list:

  1. Name read from Device name characteristic after a connect
  2. Name from advertising packet
  3. null

Note that the name from the advertising packet should be a prefix of the final name in the Device name characteristic.

Maybe the physical device already had the name cached, and does not send the second update, as it already retrieved the name.

Your app should be able to deal with duplicates even when you don't request them.

要处理重复项,您可以使用外围设备上的isEqualTo: 方法检查已经收到的,或者使用NSSet 来存储它们。

关于ios - scanForPeripheralsWithServices :return result twice on the same peripheral,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18348615/

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