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。以下链接可能解释了访问被拒绝的原因。

最新更新