Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

bluetooth lowenergy - Service returned by GetGattServicesForUuidAsync doesn't help enumerate characteristics

Instead of searching for the service of interest, I tried the following

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

The way I constructed servUuid is to use the string that had the service UUID

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

I also tried other ways to obtain a service Uuid, for e.g., enumerating all services and storing the Uuid of the service of interest and then using it in GetGattServicesForUuidAsync but to see the same issue.

It would be very useful to know what is that I am not doing right, Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem as I understand is that since I have already enumerated all the services and characteristics therein, I have to call Close on the services before obtaining a service again. Here's the link that explains possibly why the access has been denied.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...