使用Winforms C#32Feet库的蓝牙控制GUI

时间:2017-09-27 11:22:09

标签: c# winforms user-interface bluetooth

我目前正在开发用于机器人控制的模块化Winforms C#GUI。蓝牙将成为通信的方法,因此我编写了一个蓝牙控制gui,它将被打包为自定义工具箱。

我的问题是,程序在行

之后不执行任何操作
BluetoothListener bluelistener = new BluetoothListener(uuid);

下面我的整个代码都粘贴在下面。任何人都可以帮我这个。提前谢谢。

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

    private void buttonStart_Click(object sender, EventArgs e)
    {
        if(rbClient.Checked)
        {
            connectAsClient();
        }
        else
        {
            connectAsServer();
        }
    }

    private void connectAsServer()
    {
        Thread bluetoothServerthread = new Thread(new ThreadStart(serverConnectThread));
        bluetoothServerthread.Start();
    }

    Guid uuid = new Guid("e0cbf06c-cd8b-4647-bb8a-263b43f0f974");

    public void serverConnectThread()
    {
        updateUI("Server Started, Waiting for client...");
        BluetoothListener bluelistener = new BluetoothListener(uuid);
        bluelistener.Start();
        BluetoothClient conn = bluelistener.AcceptBluetoothClient();

        updateUI("Client has connected...");
    }

    private void updateUI(string message)
    {
        Func<int> del = delegate () { tbOutput.AppendText(message + System.Environment.NewLine);
            return 0;
        };

        Invoke(del);
    }

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

0 个答案:

没有答案