32feet icon indicating copy to clipboard operation
32feet copied to clipboard

How do I get a list of already connected BLE devices on my Win10?

Open Ugobyte opened this issue 1 year ago • 14 comments

Hello,

I am using VS2022, my application is .NET6.0 and I want to get a list of all the BLE devices that are already connected to my Windows 10 PC. These BLE devices are mice, keyboard and Gamepads.

My code looks like this: image_2023-07-06_134152987

However, it never finds any BLE device. When I debug my code, I get this: image_2023-07-06_134252079

What am I doing wrong? Can someone help point me in the right direction? Any code samples will be greatly appreciated.

Ugobyte avatar Jul 06 '23 17:07 Ugobyte

I was able to get it to work. However, the search only returns my neighbors Samsung TV, hahaha. I want the search to include BLE devices that are ALREADY connected to my Win10 PC.

The image below shows I have a Bluetooth Touch Mouse and a Bluetooth Gamepad already connected, how can I find the Touch Mouse and Gamepad using inthehand? My goal is to make a Windows app that allows me communicate with an ALREADY connected/paired device. I don't want to scan for a device that is still advertising. image_2023-07-06_151352955

Ugobyte avatar Jul 06 '23 19:07 Ugobyte

BluetoothClient is part of the Bluetooth Classic API. The separate InTheHand.BluetoothLE contains Bluetooth LE functionality.

peterfoot avatar Jul 06 '23 21:07 peterfoot

InTheHand.BluetoothLE

Thanks Peter. I've gone ahead and downloaded the inthehand.BluetoothLE package. Can you point me where I can see example code or some documentation? I've looked all over but I can't find a thing.

Ugobyte avatar Jul 07 '23 01:07 Ugobyte

There is a very rough sample here - Samples/BluetoothClientApp

The API documentation is here - https://inthehand.github.io/html/N_InTheHand_Bluetooth.htm

peterfoot avatar Jul 07 '23 08:07 peterfoot

There is a very rough sample here - Samples/BluetoothClientApp

The API documentation is here - https://inthehand.github.io/html/N_InTheHand_Bluetooth.htm

Pardon me for asking such questions. But when I call Bluetooth.ScanForDevicesAsync() i get a System.PlatformNotSupportedException: 'Operation is not supported on this platform.'

I'm on a Win10 PC, using VS2022 with .NET6.0 and I'm trying to make a ClassLibrary project (I'm writing a custom .dll) Am i getting this exception due to the fact that I'm writing a .dll? and not a WPF or Windows form project?

Also, I see in the remarks where you guys mentioned " Windows - Add the Bluetooth permission" Perhaps I'm getting this exception because I did not add Bluetooth permission. If so, how do I "add" Bluetooth permission?

Thanks Peter, you've been great thus far.

Ugobyte avatar Jul 07 '23 18:07 Ugobyte

It sounds like the wrong DLL is being deployed. Does the consuming app target net6.0-windows10.x or higher?

peterfoot avatar Jul 07 '23 19:07 peterfoot

Yes. image_2023-07-08_131011099

Ugobyte avatar Jul 08 '23 17:07 Ugobyte

image_2023-07-08_135515555

Ugobyte avatar Jul 08 '23 17:07 Ugobyte

I have the latest InTheHand.BluetoothLE which is version 4.0.33. And my target platform is net-3.0-windows10.017763.0. Are these incompatible ?

Ugobyte avatar Jul 10 '23 11:07 Ugobyte

@peterfoot Do you have any ideas? or suggestions?

Ugobyte avatar Jul 12 '23 03:07 Ugobyte

@Ugobyte confirm Same error when trying to call ScanForDevicesAsync with BLE

berkut0 avatar Jul 26 '23 17:07 berkut0

@berkut0 I will try it shortly and report back.

Ugobyte avatar Jul 28 '23 04:07 Ugobyte

@Ugobyte confirm Same error when trying to call ScanForDevicesAsync with BLE

@berkut0 Yes i can confirm I'm using .ScanForDevicesAsync. Here is my code image . . . . . When I run, I get this error. image

Ugobyte avatar Aug 17 '23 16:08 Ugobyte

Can you look at the InTheHand.BluetoothLE.dll in the output folder, right click, properties and see what is shown in the File Description field? this should look like InTheHand.BluetoothLE-monoandroid10.0 or equivalent depending on the platform version deployed.

peterfoot avatar Sep 05 '23 09:09 peterfoot