Windows bluetooth autopairing or disable authentication

13,657

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

See more at BluetoothWin32Authentication 32feet.NET docs which 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.

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

Share:
13,657
jhnclvr
Author by

jhnclvr

Updated on July 29, 2022

Comments

  • jhnclvr
    jhnclvr almost 2 years

    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.

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

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

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

    The primary protocol that devices will use to connect is 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;
            }
    
    
        }
    }
    
  • jhnclvr
    jhnclvr over 12 years
    I will look into this as soon as I get time! Our bluetooth server running on Windows7 is actually written in Java, so I will have to look into incorporating the c# solution, but I am psyched that it might actually be possible in any language (since it seems it is not possible in Java)
  • alanjmcf
    alanjmcf over 12 years
    :-) Of course we P/Invoke to those two native functions from C#. I guess the same thing is possible in Java -- having the native interfacing code that is required in Java, IIRC. For a quick test, if you download 32feet.NET, compile SdpBrowserDesktop, run, and select Security->Win32Auth. When pairing is required a prompt dialog will appear... :-)
  • Mehrad
    Mehrad about 10 years
    @alanjmcf Would you be able to tell us how to do the same for BlueSeil please?