Windows 蓝牙自动配对或禁用身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6998072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:45:37  来源:igfitidea点击:

Windows bluetooth autopairing or disable authentication

windowsbluetooth

提问by jhnclvr

I need windows to automatically pair with bluetooth devices. I don't want the user to have to click anything on the windows side. The server will be physically located somewhere the user cannot get to. Having to pair on the user side is fine. Windows just needs to accept any requests that come in without user input.

我需要 Windows 来自动与蓝牙设备配对。我不希望用户必须单击 Windows 侧的任何内容。服务器将位于用户无法到达的物理位置。必须在用户端配对很好。Windows 只需要接受没有用户输入的任何请求。

How can I accomplish this? Registry hacks? Replace a dll? A Hardware change (autopairing dongle or something)?

我怎样才能做到这一点?注册表黑客?替换一个dll?硬件更改(自动配对加密狗之类的)?

Is there any SDK that will give me the tools take care of this?

是否有任何 SDK 可以为我提供解决此问题的工具?

Currently I am using bluecove on the windows machine on top of Microsoft stack. I tried the Widcomm stack also with no luck.

目前,我在 Microsoft 堆栈顶部的 Windows 机器上使用 bluecove。我也尝试了 Widcomm 堆栈,但没有成功。

The primary protocol that devices will use to connect is RFCOMM.

设备用于连接的主要协议是 RFCOMM。

EDIT: using the accepted answer below I came up with this code, that auto-pairs

编辑:使用下面接受的答案我想出了这个代码,自动配对

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;
        }


    }
}

回答by alanjmcf

For the Microsoft Bluetooth stack: To support both traditional Bluetooth pairing as well as v2.1's Secure Simple Pairing use the BluetoothRegisterForAuthenticationExfunction and in your callback function respond by calling BluetoothSendAuthenticationResponseEx.

对于 Microsoft 蓝牙堆栈:要同时支持传统蓝牙配对以及 v2.1 的安全简单配对,请使用该BluetoothRegisterForAuthenticationEx函数并在您的回调函数中通过调用BluetoothSendAuthenticationResponseEx.

See more at BluetoothWin32Authentication 32feet.NET docswhich describes the way to handle that in the 32feet.NET Bluetooth library for .NET, my doc Bluetooth in Windows 7, and MSDN e.g. BluetoothRegisterForAuthenticationEx etc.

BluetoothWin32Authentication 32feet.NET 文档中查看更多信息,该文档描述了在 .NET 的 32feet.NET 蓝牙库、Windows 7 中的我的文档蓝牙和 MSDN(例如BluetoothRegisterForAuthenticationEx等)中处理该问题的方法。

BTW Widcomm does nothave a programatic way to respond to pairing (it does have a method to initiate pairing). BlueSoleil does have an API apparently.

BTW的Widcomm并没有有一个程序化的方式来配对响应(它确实有初始化配对的方法)。BlueSoleil 显然有一个 API。