【问题标题】:Service returned by GetGattServicesForUuidAsync doesn't help enumerate characteristicsGetGattServicesForUuidAsync 返回的服务无助于枚举特征
【发布时间】:2021-04-07 11:43:34
【问题描述】:

我没有搜索感兴趣的服务,而是尝试了以下方法

auto f = leDev.GetGattServicesForUuidAsync(servUuid).get(); // returns a GattDeviceServicesResult
auto g = f.Services().GetAt(0); // There is only one such service on the device that I am using
auto h = g.GetCharacteristicsAsync().get(); // Use the service to obtain all the characteristics of the service
auto j = h.Characteristics(); // Size of j is 0 despite there are 4 services

我构造servUuid的方式是使用具有服务UUID的字符串

guid servGUIDstruct = make_guid(servID);
winrt::guid servUuid = reinterpret_cast<winrt::guid&>(servGUIDstruct);

我还尝试了其他方法来获取服务 Uuid,例如,枚举所有服务并存储感兴趣的服务的 Uuid,然后在 GetGattServicesForUuidAsync 中使用它,但看到同样的问题。

知道我做错了什么会非常有用,谢谢

【问题讨论】:

  • 我发现对GetCharacteristicsAsync 的调用返回状态为Access denied

标签: bluetooth-lowenergy windows-10-universal c++-winrt


【解决方案1】:

据我了解的问题是,由于我已经枚举了其中的所有服务和特征,我必须在再次获取服务之前对服务调用Close。 这是the link,它可能解释了访问被拒绝的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 2014-01-09
    • 1970-01-01
    • 1970-01-01
    • 2012-11-21
    • 2015-06-08
    相关资源
    最近更新 更多