Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

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.

Best way to know bluetooth devices and send file to bluetooth device from your PC is to use that code.

    public void ExecuteCommandSync(object command)
    {
        try
        {
            // create the ProcessStartInfo using "cmd" as the program to be run,
            // and "/c " as the parameters.
            // Incidentally, /c tells cmd that we want it to execute the command that follows,
            // and then exit.
            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);

            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.
            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute = false;
            // Do not create the black window.
            procStartInfo.CreateNoWindow = true;

            // Now we create a process, assign its ProcessStartInfo and start it
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();

            // Get the output into a string
            string result = proc.StandardOutput.ReadToEnd();
            // Display the command output.
            Console.WriteLine(result);
        }
        catch (Exception objException)
        {
            // Log the exception
            MessageBox.Show(objException.Message);
        }
    }

You can call this method as

                          string command = "fsquirt";
                          ExecuteCommandSync(command);

So, BluetoothFileTransferWizard appear and you can choose available device and send file for send that device. If you don't want to use that way, try 32feet.net.uk. That was great for bluetooth development for C# and VB.NET.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top