【问题标题】:Advertisement data shows 3 services, but there is only one discovered广告数据显示 3 项服务,但仅发现一项
【发布时间】:2021-02-15 15:31:54
【问题描述】:

我使用 CBCentralManager 连接到 BLE 外围设备。它与此广告数据连接:

["kCBAdvDataLocalName": name, 
"kCBAdvDataIsConnectable": 1, 
"kCBAdvDataServiceUUIDs": <__NSArrayM 0x600000c74de0>(
Generic Access Profile,
Generic Attribute Profile,
1803
),
"kCBAdvDataChannel": 37]

所以我打电话给peripheral.discoverServices(nil) 来获得这3 项服务,但didDiscoverServices 只找到一项

 [<CBService: 0x600001768040, isPrimary = NO, UUID = 1803>]

谁能解释一下为什么会这样?

【问题讨论】:

  • 您能否与BlueLight.app(可在AppStore 中获得)进行调试。您的设备宣传它有 3 项服务,但它无法正确响应扫描服务,这可以解释为什么您只能看到一项。
  • @larme 谢谢,我去看看

标签: swift bluetooth-lowenergy core-bluetooth


【解决方案1】:

您在广告中看到的三个服务中有两个是Generic Access ProfileGeneric Attribute Profile。这些用于管理外围设备的发现以及服务和属性的发现。

当您请求外围设备、服务和特征发现时,核心蓝牙使用这些服务。

您不能直接与他们互动,因此当您发现可用服务时,他们不会报告给您的代理人。

外围设备公开的最终服务是link loss 服务 (0x1803)。该服务确实具有您的中心可以与之交互的特性,因此在您发现服务时会返回它。

【讨论】:

    猜你喜欢
    • 2019-12-11
    • 2021-11-17
    • 2020-02-24
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    相关资源
    最近更新 更多