微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

GetGattServicesForUuidAsync 返回的服务无助于枚举特征

如何解决GetGattServicesForUuidAsync 返回的服务无助于枚举特征

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

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 中使用它,但看到了同样的问题。

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

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。