This project has moved. For the latest updates, please go here.

"No supported Bluetooth protocol stack found" WinForms

Topics: Bluetooth - Microsoft
Jun 5, 2012 at 7:04 PM

Hi,

I am trying to build a Bluetooth application that will do the following, discover all Bluetooth devices near me, select one and connected to it, and store the COM port in a variable.

I have using a Windows Tablet PC, Windows 7, and it has a built in Bluetooth radio.

I am using the following code just a quick test.



    public void BTConnection()
        {
            try
            {
                BluetoothClient aBluetoothClient = new BluetoothClient();
                BluetoothDeviceInfo[] bluetoothDevices = aBluetoothClient.DiscoverDevices();

                foreach (BluetoothDeviceInfo btDevice in bluetoothDevices)
                {
                    MessageBox.Show(btDevice.DeviceName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);    
            }
        }

I am getting an error on the BluetoothClient() line.
I noticed that I have the Toshiba BT Stack installed, so I removed it, and now the Windows stack is being used.
I tried my code again and got the same error. 
I have also tried a laptop with the Toshiba stack and it also gave me the same error. "No support Bluetooth protocol stack found".
Kindly advise on what I should do?
Thanks,
Akhil P.
 
Jun 6, 2012 at 1:31 PM

I got the same error but with WinCE 5 and .NetCF2. The installed protocol stack itself works fine. It seems that 32feet.Net has problems.

So, I checked the protocol stack but I'm not sure which one is installed on my device.

  1. This site didn't helped me to identify the protocol: http://32feet.codeplex.com/wikipage?title=Stack%20Identification
  2. I checked the registry entry... found it in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Bluetooth". In this case it must be the Microsoft stack, not? 
  3. If it is the Microsoft stack, what could be the problem?

My other question is how to get another protocol stack?!

I would be happy for every advise.

Thank a lot,
Marco

Jun 6, 2012 at 4:39 PM

Hi,

I just wanted to give an update.

I have 3 mobile computer (2 Tablet PCs running Win 7, 1 Win XP laptop).

I uninstalled the Toshiba BT Stack on one of my Tablet PCs, I made a small mistake in running my application, I forgot to copy the dlls.

With the dlls properly copied over, the application did work perfectly. I managed to have several messageboxes appear with the name of the bluetooth devices in my area. In this case there were 4 devices.

I then tested the same application on both my laptop and the other tablet pc and the following error appeared "No supported Bluetooth protocol stack found".

I will be uninstalling the Toshiba BT stack from the laptop (where I write code in VS) so I can add more functionality.

I will keep this thread updated in terms of what happens.

Here are the things I need to do.

1) Uninstall the Toshiba BT stack on my laptop.

2) Test the application, if it works continue programming.

3) I need the application to allow the user to connection to a BT Device, deal with the pin.

4) Store the COM port number in a variable and then test another application which has the protocols to read from a particular BT device upon knowing the COM port number.

I believe most of the code I need is given here.

http://dickchiang.blogspot.ca/2008/09/bluetooth-programming-with-c.html

 

@gmlo, the only thing I can think of for you, is to double check that you uninstalled any other stack. From my experience you want to have the Windows Stack, not a 3rd party stack installed. I believe that the 3rd party stack prevents anyone else from accessing the BT Stack, whereas the Windows BT stack allows others (including your application) to interact with the BT stack.
Good Luck.

If anyone has any suggestions for the tasks I am about to complete, please let me know.

 

Thanks,

Akhil P.

Jun 7, 2012 at 6:34 PM

An update for the tasks I have completed:

I did uninstall the Toshiba BT stack on my laptop, but I still get the following error "No supported Bluetooth protocol stack found". My laptop is running Win XP SP3.


I did manage to pair a device to my Tablet PC, using this guide, http://www.alanjmcf.me.uk/comms/bluetooth/32feet.NET%20--%20User%20Guide.html.
The method is BluetoothSecurity.PairRequest( BluetoothAddress device, string pin).

I was able to get the newest COM port by following the documentation, http://32feet.codeplex.com/wikipage?title=Bluetooth%20Serial%20Ports&referringTitle=Documentation.
In particular, device.SetServiceState(BluetoothService.SerialPort, state, true);
Then doing this: One way to find the name of the port created is to call the System.IO.Ports.SerialPort.GetPortNames method before and after the SetServiceState call and see which name is new.

The code I used to get the new COM is the following:

string[] oldSerialPorts = System.IO.Ports.SerialPort.GetPortNames();
                device.SetServiceState(BluetoothService.SerialPort, true, true);
                System.Threading.Thread.Sleep(500); // Need otherwise both arrays will be identical.
                string[] newSerialPorts = System.IO.Ports.SerialPort.GetPortNames();                
 
private void FindNewPort(string[] oldSerialPorts, string[] newSerialPorts)
        {
            string newCOM = "no";
            foreach (string newport in newSerialPorts)
            {
                if (!oldSerialPorts.Contains<string>(newport))
                {
                    newCOM = newport;
                    break;
                }
            }
            MessageBox.Show(newCOM.Substring(0,newCOM.Length -1));
        } 



Once again, that delay of 500 milliseconds is needed, without it, both arrays will be the same and when the FindNewPort method is executed, no new com port will be found. But with the delay, you will see the new com port being added.

For the message box in the FindNewPort method, I had to remove the last character from the com port number because it was a random character.
For example, it would return "COM10x", by removing the last character I would get "COM10".

I have checked the connection between my Tablet PC and the device and they can communicate with each other.

Thank you so much for the 32feet.dll, this has been a great experience. I still got a lot of polishing up to do with this new code and I am confident everything will work out.

Thanks,

 

Akhil P.