Welcome to OGeek Q&A 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...