首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >蓝牙监听器-如何监听来自蓝牙设备的消息

蓝牙监听器-如何监听来自蓝牙设备的消息
EN

Stack Overflow用户
提问于 2014-05-21 03:32:23
回答 2查看 7.3K关注 0票数 0

我正在尝试创建一个监听蓝牙消息的服务器(带有蓝牙的计算机)。我使用的是32英尺的库。但是我得到了一个异常,我找不到它是什么。例外情况是:找不到支持的蓝牙协议栈。

代码如下:

代码语言:javascript
复制
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();


    }
EN

回答 2

Stack Overflow用户

发布于 2014-05-23 05:39:11

这条消息就是它所说的..。你的电脑上有什么蓝牙软件?

票数 0
EN

Stack Overflow用户

发布于 2015-04-12 17:56:35

在BluetoothListener中添加本地地址,如下所示。

代码语言:javascript
复制
        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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23768384

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档