How to detect Bluetooth activated laptops in range in Windows using C# - c#

I'm interested in creating a wireless network of laptops using Bluetooth developed in C#.
I want to get the list of Bluetooth activated devices in range ( preferable computers, not dongles, headsets or phones). I don't think I need to use a Bluetooth adapter specific stack coz I have seen Windows searching for Bluetooth devices in range. How can I run such a search in my C# app and list the computers in range?
Please help me to do this, also let me know if my effort is wrong. Thank you.

There is a nice C# Bluetooth library available in 32feet.NET.
If you have no need for any of the additional features it offers and you wish to do the P/Invoke on your own, documentation can be found here; specifically the BluetoothFindFirstDevice and BluetoothFindNextDevice for device discovery.
Additionally, you can use windows sockets to do device/service discovery. Information on that can be found here.
If you wish to specifically filter out types of Bluetooth devices, you will want to look at the ulClassOfDevice field in the BluetoothDeviceInfo.

Related

Get Bluetooth Devices sorted by strength/proximity

I am trying to build a solution in C# which allows the identification of a laptop based on the Bluetooth devices around it. I hope to preferably use Bluetooth LE and have the ability to know which devices are more likely relevant by their strength.
My first idea was to use RSSI, but it seems that path is near impossible due to how Microsoft's Bluetooth Stack doesn't support reading the RSSI values. I've even looked into using Nobel with edge.js, however, that requires you to replace your Bluetooth driver entirely (making it useless for anything else) in order to support RSSI readings which is currently my last resort, as it would make it difficult for users to adopt.
However, I only really need which devices are more relevant/closer.
Is there any way I could get the Bluetooth devices in range ordered from closest to furthest in C#? Or maybe even in JS?
Thank you.

On and off bluetooth connection in Windows 10

I am trying to create an application that has a functionality to search for and turn-on (if available) the bluetooth device. How can I find a bluetooth device is available or not? If available I want to check is that enabled. If disabled I need to enable it.
I want to do this from my C# application.
I haven't used it but there is a library exposing Personal Area Networks to C#. Take a look at:
https://32feet.codeplex.com/
It may contain what you are looking for.

C#: Find out if the Bluetooth adapter is turned On/Off + the type of the STACK used (Programmatically)

How to programmatically tell if the Bluetooth adapter on the device which is the code is running at, is turned On or Off?
Discovery methods such as "cli.DiscoverDevices()" using 32feet simply return no device found in both situations which
The Bluetooth adapter in On but no device is available.
The Bluetooth adapter is Off.
Also, I know the visual approach of finding a type of Bluetooth stack in-used from device manager in Windows but would like to find out if this is possible to recognize in the code as well.
https://32feet.codeplex.com/wikipage?title=Local%20Radio%20Information
e.g. BluetoothRadio.Mode, and Modes in recent dev versions.
The only way off the top of my head is to check the device power state. There is a decent writeup here on power states:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff554397(v=vs.85).aspx
You will need to use pinvoke as the only way to manage power states is via native code.

Microsoft Bluetooth Stack into Widcomm Bluetooth Stack?

I have the following problem:
I implemented a managed mobile application for Windows Mobile devices using the C# Bluetooth library of InTheHand.
Now I figured out that the new devices of HTC will all have the Widcomm Bluetooth stack instead of the Microsoft Bluetooth stack...
Does anybody know some working C# library for the Widcomm Bluetooth stack? And also how limited the widcomm api is, concerning e.g. being able to turn bluetooth on/off or having an Obex listener?
Thanks for any hints!
Firstly the disclaimer, I'm the maintainer of the 32feet.NET library. :-)
Version 2.4 of 32feet.NET from InTheHand includes Widcomm/Broadcom support. Have you tried that? I get the feeling you might have...
To run ObexListener firstly we'd need a way to disable Widcomm's built-in OBEX server (if that can be done I can make the changes necessary to have ObexListener run). There might be support for enabling/disabling the radio on CE/WM -- I think that API is missing on Win32 however.
The other options with ObexListener are to run it on a personal Service Class Id, as long as the client app knows that it will work. Or perhaps you could use the Widcomm API directly, which might allow you to intercept the PUT objects you need...

Bluetooth APIs in Windows/.Net?

I am in the process of writing a Bluetooth scanner that locates and identifies mobile devices in the local vicinity. Is this something that I can accomplish using C#, or do I need to drop down into the C/C++ APIs? My application is targeting Windows XP and Vista. Pointers are appreciated.
Thanks!
One problem with Bluetooth on the PC is that there are several BT stacks in use and you can never quite know which one is available on a given machine. The most common ones are Widcomm (now Broadcom) and Microsoft (appeared in XP, maybe one of the service packs). However, some BT hardware vendors package BlueSoleil and some use Toshiba. Most dongles will work with the MS stack so the .NET libs I've seen tend to use that.
Each of the stacks has a totally different way of doing the discovery part where you browse for nearby devices and inquire their services.
If I had to pick one approach today I'd probably do the discovery in C++ and add an interface for .NET.
The 32feet.net stuff worked pretty well when I tried it but didn't support the Widcomm stack.
There is also Peter Foot's 32feet.net
http://inthehand.com/content/32feet.aspx
I've played around with this back when it was v1.5 and it worked well.
Mike Petrichenko has a nice BT framework. It works with BlueSoleil, Widcomm, Toshiba and Microsoft.
It is now called the Wireless Communications Library and works with Bluetooth 802.11 and Infrared. Mike named the company Soft Service Company and sells non-commercial and commercial licenses with and without source code in prices ranging between $100 and $2050.

Categories