0

I want to read characteristics from a service using WinRT API for BLE. Ihad some working code, but in my last question (Bluetooth low energy characteristic access only works once) i was told my API was too old and wont work on every PC. My issues now are:

  1. I can't get the sample code working. Research on this issue didn't give me answers, so I'm asking here. In the image you can see part of the code and some error messages. enter image description here

  2. The code doesn't seem to read characteristics, but I'm really unsure how to read them with this new API.

You can take a look at the code here: https://github.com/urish/win-ble-cpp/blob/master/BLEScanner/BLEScanner.cpp

Im using Visual Studio 2019 and i have installed UWP, WinRP C++, and everything else I think I need. Thanks in advance

Suceeded with errors

Static
  • 87
  • 8
  • Compiling errors: check compiler options and included files. Read characteristics: use GetCharacteristicsAsync() and similar for services. Or use third party libraries (any one) that makes it simple. – Mike Petrichenko Jul 24 '20 at 11:00
  • Already did that for several hours. Compiler options and includes should be fine. Thats why i dont understand this issue. – Static Jul 24 '20 at 11:05
  • My main problem with these errors is, that my code compiles fine, but i get nontheless 184 errors in the vccorlib.h. I researched that, but couldnt find the same issue on the net. As shown in the image, its all 'E' errors E0018 - E0898 – Static Jul 24 '20 at 11:11
  • I have downloaded your code form github, opeened it in VS 2019, updated to the VS 2019 toolset and latest SDK and built it without any problem. – Mike Petrichenko Jul 24 '20 at 11:36
  • My Visual Studio Build Tools 2019, and Visual Studio Community 2019 (2) version is 16.6.5. My Windows Software Development Kit Version is 10.0.19041.1. should me up to date. The build works, but i still get errors. – Static Jul 24 '20 at 11:43
  • I do not udndertand. If you get build errors then build does not work. If build works then you do ot get any build errors. Its binary thing: builds/does not build. There is no third state. – Mike Petrichenko Jul 24 '20 at 12:07
  • I've added an image of my successfully failed code – Static Jul 24 '20 at 12:31
  • BLEScanner and SimpleBLEScanner are different projects. So one of them has errors. – Mike Petrichenko Jul 24 '20 at 12:41
  • Since it didnt work as downloaded i got WinRT template and copied the code to the new template. The errors are the same, but the name is different. – Static Jul 24 '20 at 12:49
  • Its not possible to get sucessful build and errors at the same time for the same project. It looks like your solutions has 2 or more projects and one of them built with success and other(s) with errors. Show all your solutions with all your projects and code and do not put code that you actually do not use. – Mike Petrichenko Jul 24 '20 at 12:50
  • It looks exactly as in the first picture. 1 Solution with 1 Project. – Static Jul 24 '20 at 13:03
  • Upload it on github as complete solution – Mike Petrichenko Jul 24 '20 at 13:06
  • Ok, i had to create an account on GitHub, but i uploaded it now: https://github.com/Static1985/SimpleBLEscanner – Static Jul 24 '20 at 13:16
  • Ok, the very first thing is you mixed code from /clr and standard C++. Chose one of them. Then will see. – Mike Petrichenko Jul 24 '20 at 13:37
  • I switched the support common language runtime from "" to "no". That fixed 1 or 2 errors but i still get the 88 errors in vccorlib.h, that you partly see in image 1. – Static Jul 24 '20 at 13:44
  • I do not have such errors. Probably Community Edition doe snot include some headers or something. – Mike Petrichenko Jul 24 '20 at 13:54
  • @Mike Hello again. The Code seems to be somehow working (still got the errors). I get to connect to the device, but now to my second question, the reading: As you mentioned before i tried the ReadValueAsync() function, but this just returns another object, with no value i get to read. I have researched for a while now, and i find no useful documentation other than the Microsoft page. It is nowhere to be found how i actually get the value of the characteristic. When i use the toString() function and print i get: Windows.Foundation.IAsyncOperation`1 – Static Jul 27 '20 at 08:51
  • Analize error. Probably wrong service or device requires pairing. – Mike Petrichenko Jul 27 '20 at 15:20

0 Answers0