'Bluetooth listener - how to listen messages from Bluetooth devices
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();
}
Solution 1:[1]
The message means what it says... What Bluetooth software do you have on your PC?
Solution 2:[2]
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();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alanjmcf |
| Solution 2 | Majid gharaei |
