小编xma*_*lax的帖子

将蓝牙设备与具有32英尺.NET蓝牙库的计算机配对

如果您想知道如何使用32feet.NET库与蓝牙设备通信,请阅读解决方案


我目前正在尝试通过蓝牙在计算机和自建的.NET Gadgeteer原型之间进行通信.

Gadgeteer原型包括主板,电源和蓝牙模块.模块处于可发现模式.

在计算机上,基于32feet .NET蓝牙的自定义蓝牙程序正在运行.程序检测范围内的所有蓝牙设备并尝试与它们配对.但是,目前还没有自动完成,我必须输入设备的配对代码.

如何在不输入配对代码的情况下配对设备?

找到设备,问题是配对部分.我做了很多实验,但没有找到解决方案......

foreach (BluetoothDeviceInfo device in this.deviceList)
{
    try
    {
        //BluetoothClient client = new BluetoothClient(this.CreateNewEndpoint(localAddress));
        //BluetoothEndPoint ep = this.CreateNewEndpoint(device.DeviceAddress);

        EventHandler<BluetoothWin32AuthenticationEventArgs> handler = new EventHandler<BluetoothWin32AuthenticationEventArgs>(HandleRequests);
        BluetoothWin32Authentication auth = new BluetoothWin32Authentication(handler);

        BluetoothSecurity.PairRequest(device.DeviceAddress, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

此代码块启动配对并且它可以工作,但Windows要求我输入设备的配对代码.我读到了关于BluetoothWin32Authentication以防止这种情况,但我没有把它弄好.

private void HandleRequests(object that, BluetoothWin32AuthenticationEventArgs e)
{
    e.Confirm = true;
}
Run Code Online (Sandbox Code Playgroud)

这是事件处理程序的代码(http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication)

如果你只想让SSP设备连接时允许配对继续,那么处理回调和设置e.Confirm = True就足够了 - 但这有点不安全......


我很困惑-.-目标是应用程序和gadgeteer模块可以在没有任何用户干扰的情况下向两个方向发送数据.

没有用户交互,我无法自动配对设备吗?

是否真的如果两个设备已经配对,他们可以在没有用户交互的情况下交换数据?

c# bluetooth .net-gadgeteer 32feet

26
推荐指数
1
解决办法
6万
查看次数

标签 统计

.net-gadgeteer ×1

32feet ×1

bluetooth ×1

c# ×1