0

I'm trying to create a server (a computer with Bluetooth) that listen to Bluetooth messages. I'm using 32 feet library. But I'm getting a exception, and I cannot find what it is. The exception is: No supported Bluetooth protocol stack found.

here is the code:

using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using InTheHand;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Ports;
using InTheHand.Net.Sockets;
using System.IO;


namespace Bluetoot_Tutorial
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void bGo_Click(object sender, EventArgs e)
    {

            connectAsServer();

    }

    private void connectAsServer()
    {
        Thread bluetoothServerThread = new Thread(new ThreadStart(ServerConnectThread));
        bluetoothServerThread.Start();
    }



    private void connectAsClient()
    {
        throw new NotImplementedException();
    }

    Guid uUUID = new Guid("00001101-0000-1000-8000-00805F9B34FB");

    public void ServerConnectThread()
    {
        BluetoothListener blueListener = new BluetoothListener(uUUID);
        blueListener.Start();
        BluetoothClient conn = blueListener.AcceptBluetoothClient();


    }
Diego Unanue
  • 6,576
  • 8
  • 47
  • 67
  • On a side note, I would recommend you don't try to re-use the same GUID for each attempt as you are here, instead use Guid.NewGuid(), then share that newly instantiated GUID for your (attempted)session. – GEEF May 20 '14 at 19:38
  • Thanks, can the exception have something to do with the library? – Diego Unanue May 20 '14 at 19:41
  • I tried VP solution but I still have the same exception in the same line. This is the line where I get the exception: BluetoothListener blueListener = new BluetoothListener(uUUID); – Diego Unanue May 20 '14 at 19:49
  • Changing the GUID will not fix the issue, it is just a side note for something you may want to change. However it does look like there is a bit more code you still may need. I might suggest you look at a couple other SO posts similar to this which may give you a good foothold: http://stackoverflow.com/questions/16802791/pair-bluetooth-devices-to-a-computer-with-32feet-net-bluetooth-library – GEEF May 20 '14 at 19:52
  • Have you checked google? – Sergey Krusch May 20 '14 at 20:15
  • Yes, nothing that helps. – Diego Unanue May 21 '14 at 12:44
  • To add information to the exception. The title of the exception is platform not supported exception. – Diego Unanue May 21 '14 at 12:54
  • @VP: The UUID identifies the service to connect to. It must be specified precisely. Please explain how using random UUIDs would help... Or are you saying he should create one UUID to use for his new service? – alanjmcf May 22 '14 at 21:40
  • If that is the exact GUID he is required to give to the BluetoothListener then my comment is incorrect. However, if that is just a session ID or something of the such, it should be new each time. Depends on what that constructor is using it for – GEEF May 23 '14 at 00:00

2 Answers2

0

The message means what it says... What Bluetooth software do you have on your PC?

alanjmcf
  • 3,430
  • 1
  • 17
  • 14
0

Add Local address in BluetoothListener like below.

        BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio;
        if (myRadio == null)
        {
            Console.WriteLine("No radio hardware or unsupported software stack");
            return;
        }
        RadioMode mode = myRadio.Mode;
        var lsnr = new BluetoothListener(myRadio.LocalAddress, serviceClass);
        lsnr.Start();
Majid gharaei
  • 281
  • 3
  • 11