【发布时间】:2013-05-24 01:24:02
【问题描述】:
如果您想知道如何使用 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);
}
}
此代码块启动配对并且可以正常工作,但 Windows 要求我输入设备的配对代码。我阅读了有关 BluetoothWin32Authentication 以防止这种情况的信息,但我没有做对。
private void HandleRequests(object that, BluetoothWin32AuthenticationEventArgs e)
{
e.Confirm = true;
}
这是事件处理程序的代码 (http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication)
如果您只是想在 SSP 设备连接时允许配对继续进行,那么处理回调并设置 e.Confirm=True 就足够了——但这有点不安全...
我很困惑 -.- 目标是应用程序和 gadgeteer 模块可以双向发送数据,而无需任何用户干预。
在没有用户交互的情况下我无法自动配对设备是真的吗?
如果两台设备已经配对,它们是否可以在没有用户交互的情况下交换数据?
【问题讨论】:
-
在 Windows 10 中,这不起作用。操作系统提示我“点击以设置设备” - 我从来没有使用上面的代码获得对“HandleRequests”事件处理程序的回调。关于如何绕过此提示的任何想法?
-
是的,正如 TheJeff 所说,配对在 Windows 10 中不起作用,设备已配对但在“播放设备”中不可见,有什么办法解决吗?
-
系统要求没有列出 Windows 10,只列出了 Windows 8。也许目前还不可能。
-
我还在 Windows 8.1 上收到“点击以设置设备”toast 通知。我想知道它是否与蓝牙设置中的“当有新的蓝牙设备想要连接时提醒我”选项有关。
-
你能解决这个问题吗?我也得到了相同的 TAP 来设置 toast 通知,一旦我点击,它就会正确配对。
标签: c# bluetooth 32feet .net-gadgeteer