I have created a simple C# .NET framework console application.
In it, I am trying to get a list of paired bluetooth devices currently connected to the computer. However, I cannot figure out, how to access any bluetooth services from within the code.
I looked around the internet, and all I could find was a way to do this in an universal windows project (UWP), where I can simply use the using Windows.Devices.Bluetooth
namespace which contains everything I would need, however in the .NET framework console application, this namespace is not available.
I don't need any advanced way to work with the bluetooth, all I need is a list of currently connected and paired bluetooth devices.
Try using below code :
BluetoothClient client = new BluetoothClient();
List<string> items = new List<string>();
BluetoothDeviceInfo[] devices = client.DiscoverDevicesInRange();
foreach (BluetoothDeviceInfo d in devices)
{
items.Add(d.DeviceName);
}
You will get the reference of BluetoothClient by installing 32feet.NET through Package Manager Console.
PM> Install-Package 32feet.NET -Version 3.5.0
After Installation you will get InTheHand.Net.Personal dll in the References and then add the namespace using InTheHand.Net.Sockets; in your code
Now you will be able to access BluetoothClient
Hope this helps!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With