我需要 Windows 自动与蓝牙设备配对。我不希望用户必须单击 Windows 端的任何内容。服务器物理上将位于用户无法到达的地方。必须在用户端进行配对就可以了。 Windows 只需接受任何无需用户输入的请求。
我怎样才能做到这一点?注册表黑客?替换一个dll?硬件发生变化(自动配对适配器或其他东西)?
是否有任何 SDK 可以为我提供处理此问题的工具?
目前,我在 Microsoft 堆栈之上的 Windows 计算机上使用 bluecove。我也尝试过 Widcomm 堆栈,但没有成功。
设备用于连接的主要协议(protocol)是 RFCOMM。
编辑: 使用下面接受的答案我想出了这个代码,自动配对
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InTheHand.Net.Bluetooth;
using System.Threading;
namespace BT
{
class BluetoothAutoSSP
{
public static void Main()
{
BluetoothAutoSSP c = new BluetoothAutoSSP();
EventHandler<BluetoothWin32AuthenticationEventArgs> handler = new EventHandler<BluetoothWin32AuthenticationEventArgs>(c.handleRequests);
BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(handler);
while (true)
{
Thread.Sleep(10);
}
}
public void handleRequests(Object thing, BluetoothWin32AuthenticationEventArgs args)
{
args.Confirm = true;
}
}
}
最佳答案
对于 Microsoft 蓝牙堆栈:要支持传统蓝牙配对以及 v2.1 的安全简单配对,请使用 BluetoothRegisterForAuthenticationEx
函数,并在回调函数中通过调用 BluetoothSendAuthenticationResponseEx
进行响应>.
查看更多信息 BluetoothWin32Authentication 32feet.NET docs它描述了在 .NET 的 32feet.NET 蓝牙库中处理该问题的方法,我的文档 Bluetooth in Windows 7和 MSDN 例如BluetoothRegisterForAuthenticationEx 等等
顺便说一句,Widcomm 没有有一种编程方式来响应配对(它有一种启动配对的方法)。 BlueSoleil 显然有一个 API。
关于Windows 蓝牙自动配对或禁用身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6998072/