Server-side service

Topics: Bluetooth - Microsoft, Bluetooth - Widcomm/Broadcom, Samples
Dec 14, 2012 at 4:20 PM

Will ask the question first and lament later..

So far I have worked with 32feet bt libraries for spp communication where my .net app is the master and BT devices are slaves. Now, app needs to be the slave and a BT device is the master. Device tries to connect to any slave with matching service name and COD. From what I read, I can't change my app/radio's COD. But I can create a service with the required name, and be in discoverable mode for Device to detect me. And try to connect. Device expects a specific pin.

There is no initial pairing outside the app. Since Device is master, and it specifically looks for a service name when on, my computer doesn't detect the device even if I try to pair and remember the bonding for future. So app is the only way to do the initial pairing.

So I have:

				BluetoothListener btSvc = new BluetoothListener(BluetoothService.SerialPort);
				btSvc.ServiceName = serviceName;
				Remote = btSvc.AcceptBluetoothClient();

Where do I go from here? What is the sequence of steps? How do I pair? Are there any examples of being a slave and responding with a pin?


Dec 15, 2012 at 9:48 PM

Use BluetoothWin32Authentication to handle pairing (assuming you are using the Microsoft stack).  If the device only uses a (traditional) PIN then in the callback method just do:

Debug.Assert(e.AuthenticationMethod == BluetoothAuthenticationMethod.Legacy); // check not SSP etc
e.Pin = MyFixedPinValue;


You can add to the bits set in the CoD with the BluetoothListener.ServiceClass property. There may also be a way to change the CoD via a Registry setting. I'll need to look it up.

I think those were the questions...

Dec 17, 2012 at 9:31 PM
Edited Dec 17, 2012 at 10:26 PM


BluetoothListener.ServiceClass handles get/set of Major Service Class, the first byte of the three bytes in the CoD right? I am not yet sure the octet my requirement refers to Major Service Class yet. Will check with the device vendor.

1. I tried to read the ServiceClass of my service before and after I start it, and in both cases it comes as 'None', meaning they are not set. Is that what we should expect? Or does this point to a different issue which I need to address first?

2. Registry key option as per, is only for Minor Device class. And looks like Major Device class can't be changed. 

Is there a way for me to change device class bytes also, using the library?

3. Regarding authentication (first time pairing programmatically), what are the options if I am using Widcomm stack on a windows 7 64 bit machine? Can I still be a slave and respond to connection atttempts with a valid pin? What is the sequence of steps?

4. Can you point me to any local as slave example where slave listens to incoming connections, answers with a pin, connects, etc?

Dec 17, 2012 at 11:09 PM

Ok I am confused now.. I thought I had Widcomm(when I disable bt adapter from system tray, I have to go to c:\program files\..Widcomm\bttray.exe to see icon bac again and enable it etc.

But when I select "Generic Bluetooth Adapter" under Bluetooth radios in my device manager, everything says 'Microsoft' everywhere. I have two listings under Bluetooth- 1. "Generic Bluetooth Adapter" and 2. "Microsoft Bluetooth Enumerator". 

So what stack do I have now?

Dec 18, 2012 at 8:37 AM
Edited Dec 18, 2012 at 8:43 AM So looks like Microsoft. That's good news because Widcomm supplies no API for handling pairing.  Presumably PrimaryRadio.SoftwareManufacturer concurs?

I'll get back to your previous post later...

Dec 18, 2012 at 3:03 PM
Edited Dec 18, 2012 at 3:13 PM


Hm. My bt dongle is

If you scroll all the way to the bottom, 

it says:


Profiles supported DUN, LAN, FAX, FTP, HID, HP, HCRP, SPP, GAP, GOEP, SYNCH, PAN, OPP, SDAP (uses WIDCOMM Software v1.4)


Now why does it say WIDCOMM there??

Just want to make sure I am not going on a wild goose chase with a wrong bt stack.


Edit: I read everything and from your stack identification link, and also the 'visual' identification links, looks like my targus dongle and also my belkin dongle both provide MSFT stack, even if targus dongle says (uses WIDCOMM software) and even if belkin dongle's manufacturer is shown as Broadcomm in device manager. Weird.

Dec 19, 2012 at 12:47 PM
Edited Dec 19, 2012 at 1:14 PM

In short, the Bluetooth organisation supplies a specification for dongles (e.g. using USB) and thus 99.9% of dongles can be used by all the various software stacks. Thus a dongle attached to a PC will be used by whichever stack software is installed. It is not the case thus that a dongle with Broadcom silicon can only be used by the Broadcom/Widcomm stack.  So it is not "my DDDD dongle provide MSFT stack", it's actually: "the SSSS stack installed on my PC is able to use the DDDD dongle".

In more detail: Unlike some other networking protocols the Bluetooth standards body provides a specification of the host (i.e. PC) to device protocol, it is called HCI and they also specify the USB behaviour etc as well. WiFi and IrDA for instance don't specify this which is why per-device drivers are always required there. In my experience 99.9% of Bluetooth dongles use the standard HCI and USB Bluetooth specifications (I've seen a dongle from Trust which is non-standard). And thus most Bluetooth dongles can be use by all the various Bluetooth stacks -- in particular by the Microsoft stack.

BTW The list of Profiles supported is a function of the stack (and stack extensions) used on the PC and has (almost?) nothing to do with the chip on the dongle.

I've updated the docs to explain this:

Dec 19, 2012 at 3:03 PM
Edited Dec 19, 2012 at 3:18 PM

Basics, basics, basics!!! Thank you.
BTW, you are awesome.

Just found out a few hours back, my device in question, needs SDAP apparently. So just windows stack is not sufficient because it doesn't have it out of the box. They recommend Toshiba stack but doesn't support it anyway. So we are on hold with this device integration for now.

But back to my targus dongle, which says (uses WIDCOMM software v1.4), what does it mean? WIDCOMM's sw is installed on the dongle? Or, if my computer already has WIDCOMM software 1.4, then the dongle will recognize it? Is that WIDCOMM comment mainly meant for SDAP above? Or for all other profiles listed? Is it merely stating the fact that assuming you have WIDCOMM BT stack on your machine, this dongle will support all those profiles that the stack provides?

Dec 20, 2012 at 9:38 PM

Every Bluetooth stack supports SDAP it is in effect just another name for SDP and that's the Service Database that's required to let clients connects to server services.

Maybe you mean something else? SAP? Or maybe they are confused...

If the Microsoft stack doesn't support it then that doesn't stop a third-party from developing it on top of that stack...

Dec 20, 2012 at 9:39 PM

Ohh yeh. Widcomm is on the CD in the same packet as the dongle. If you install it then it will grab hold of the dongle and thus the MSFT stack won't get loaded.

Jan 16, 2013 at 8:20 PM
Edited Jan 16, 2013 at 8:25 PM

Thank you! I am confused with different stacks and different dongles and wanted to ask couple of questions, but I started that as a new discussion here: