Bluetooth LE device access example needed from non-UWP program

NormS 11 Reputation points
2022-03-09T20:38:49.053+00:00

I am attempting to access data from a Bluetooth LE device from a non-UWP program. (C++ old-fashioned Windows Desktop app.)

This should be a very simple task, and would be if the apparently-being-deprecated? Win32 API supported it.

I have observed it does not: that is, here:

https://github.com/MicrosoftDocs/sdk-api/blob/docs/sdk-api-src/content/bluetoothapis/nf-bluetoothapis-bluetoothfindfirstdevice.md

it says:

"The BluetoothFindFirstDevice function does not find Bluetooth Low Energy (LE) devices. To access Bluetooth LE devices, use the Windows Runtime Bluetooth Low Energy APIs. The Windows Runtime APIs for Bluetooth work in both UWP and classic desktop apps."

(Never mind that the link to the Windows Runtime Bluetooth Low Energy APIs is bad. I've been getting a lot of that in my navigation through MS documentation, but that's not my problem!)

My problem is the MS documentation refers to the MS examples ( https://learn.microsoft.com/en-us/samples/microsoft/windows-universal-samples/bluetoothle/ ) which are all UWP examples (one in C++, one in C#).

I have spent several days trying to adapt those examples to work in a classic desktop app (and also a console app, to try for maximum simplicity), but it always fails. (All kinds of things go wrong. In one case, the compiler doesn't understand my reference to "get_weak()", and I am not able to figure out a replacement.)

Thus, since MS claims that you can access Bluetooth LE from classic desktop apps, it would be helpful for you add to the examples say a simple non-UWP console app (say in C++), and perform the same tasks as the two UWP examples.

(I have looked around for other examples which are open source on the web, and found only a UWP program.)

Further, I suspect others non-expert in the new "Windows Runtime", which is apparently superseding the good old and decently documented Win32 API are having the same problem. Thus, I've observed some science people in the brainwave-analysis world seem to have software which accesses Bluetooth LE only through the "BLE112 dongle". (For which the maker of the chip on that dongle I believe provides their own library to access bluethooth LE, keeping them away from Windows Runtime for the task.)

Thanks.

Developer technologies | C++
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.