This project has moved. For the latest updates, please go here.

Simple pairing on Windows

Topics: Bluetooth - Microsoft
Oct 23, 2012 at 5:15 PM

Hi,

After pairing device (phone) with my computer, windows installs all drivers needed to handle all device's bluetooth profiles (?). And then the device appears in Control Panel\Hardware and Sound\Devices and Printers.

Is it possible to not install this stuff while pairing? Or to uninstall from code after some work? Or not to install all services/profiles?

I'm using this code:

if (!device.Authenticated)
  if (!BluetoothSecurity.PairRequest(device.DeviceAddress, key))
    return false;
return true;

Developer
Oct 24, 2012 at 8:44 AM

I do not know of a way to tell Windows not to install services for the new device.

BluetoothDeviceInfo.SetServiceState could probably be used to disable them afterward. BluetoothDeviceInfo.InstalledServices will hopefully list all the services that have been installed.  http://32feet.codeplex.com/wikipage?title=Peer Device Information

Oct 24, 2012 at 9:49 AM
Edited Oct 24, 2012 at 9:50 AM

Thank you alanjmcf, your post was very helpful. I've found everything what I need.

To handle any bluetooth service Windows must install a proper driver. After BluetoothDeviceInfo.SetServiceState sets service state to true, Windows installs the service driver.

If using BluetoothSecurity.PairRequest when there is no active services, windows sets all services states to true and installs all drivers.

This code works perfect for me:

BluetoothDeviceInfo d = ...
d.SetServiceState(BluetoothService.ObexObjectPush, true);
...
if(BluetoothSecurity.PairRequest(d.DeviceAddress, key))
  ...
...
d.SetServiceState(BluetoothService.ObexObjectPush, false);
BluetoothSecurity.RemoveDevice(d.DeviceAddress);
Developer
Oct 25, 2012 at 9:30 AM

I don't think there's a service for profile ObexObjectPush. So the code to do with that probably isn't required.

On the Microsoft stack for Windows OPP is handled by the "Bluetooth File Transfer" (fsquirt.exe) program so no service involved AFAIK.