Connect without pairing

Topics: Bluetooth - Widcomm/Broadcom
Apr 10, 2012 at 3:02 PM
Edited Apr 11, 2012 at 7:52 AM

I wrote an application in C# for Windows Mobile 5.0 on .NET CF 2.0 and 32feet v. 2.4.0.0, quite a while ago, which connects to a bluetooth device via SPP (Simple Serial Port - RFCOM) and it works perfectly.

I then ported the application to Windows Mobile 6.5 and changed to 32feet v. 3.3.909.0, as the old version did not support Windows Mobile 6.5. Both application uses the 32feetWidcomm.dll, though two different versions I am sure.

The problem is that sometimes when I attempt to connect to a device it prompts me for pairing. The prompt comes from Windows Mobile 6.5 (the OS), not 32feet, as far as I can tell, but the connect is executed from 32feet. The "old" version running on Windows Mobile 5.0 has no problem connecting to the devices which fails on the newer OS.

I have taken several of the devices I am connecting to apart and as far as I can see there is no difference between the devices or the HW bluetooth chip. The really odd thing is that it is only some of the devices I am unable to connect to, and the "old" version works perfectly. The prompt on the phone running the code is: "Pairing is required to be able to create a connection to this device", and is a Windows Mobile Bluetooth prompt.

Is there some way of forcing a Bluetooth connect on Windows Mobile 6.5 via 32feet to be created without pairing? There is no requirement for security or encryption.

I have added a part of my code below. The listBoxDevices contains a list of all devices found in the last search. Apart from making sure the Bluetooth Chip is powered on, no other attributes are set/testet.

Code:

 

BluetoothDeviceInfo bdi = (BluetoothDeviceInfo)listBoxDevices.SelectedValue;

IAsyncResult ar = bc.BeginConnect(new BluetoothEndPoint(bdi.DeviceAddress, BluetoothService.SerialPort), null, null);

while (!ar.IsCompleted && progressBarLoookup.Value < 100)
{
  ++progressBarLoookup.Value;
  Thread.Sleep(50);
}
if (ar.IsCompleted)
{
  res = CommandResult.COMMUNICATION_FAILURE;
  bc.EndConnect(ar);
  NetworkStream ns = bc.GetStream();

Thank you in advance.
Developer
Apr 18, 2012 at 9:56 PM

Don't know if you managed to find the solution. I've been a bit behind.

What stack is used?  What's BluetoothRadio.PrimaryRadio.SoftwareManufacturer ?

So the local stack has decided to auth the connection.  The only flag we have is per-connection (rather than per-device) and its BluetoothClient.Authenticate/Encrypt and they both default to false.

There's no chance the stack on WM 6.5 has BTH v2.1 support?  I thought it was only in WM 7.

Apr 19, 2012 at 2:35 PM

I know that the stack is a BT v2.1 as it supports SSP on the Windows Mobile 6.5, which is not supported in 2.0.

BluetoothRadio.PrimaryRadio.SoftwareManufacturer = Broadcom

The stack as mentioned is Widcomm, but I do not know the version. 

I have been experimenting with the Authenticate and Encrypt properties but as you mention the are false by default. If I attempt to set them to true I get an exception.

I have been looking into the difference between remembererd, paired and authenticated, as the phone / API seems to put all seen devices into the remembered and that it is the same as paired. There is room for up to 10 devices, so I though maybe it was this list that overflowed and then caused the authentication, but clearing the list and only having a few devices on still result in the error. I have tried to enable SSP on one of the devices and then it authenticates and connects, but unfortunately it prompts the user for confirmation. The Pin-authentication I can use without prompting but it introduces a delay, and I do not know what happens when the authenticated list overflow. Hopefully the old ones just get discarded - otherwise i would have to break authentication after use, and that is a further delay.

I have tried to connect to a device with an older firmware (2.0) from the windows mobile 6.5 and it still requested pairing.

Do you think it is because the BroadCom stack is BT c2.1?

Developer
Apr 19, 2012 at 10:31 PM
Edited Apr 19, 2012 at 10:32 PM

[edit]

Arggggh I'd written a reply but it failed to post!  In short...

Widcomm apparently automatically Remembers every discovered device.  We read the Registry for all Remembered/Authenticated devices and call BondQuery method for each to find if it's Authenticated or just Remembered.  (WidcommBtInterface.cs).

Yes I presume that the stack has been updated for v2.1 and in v2.1/SSP every link is to be authenticated+encrypted.  But apparently the new stack also tries to authenticate even non-v2.1 connections. Since their API has never provided a callback for handling authentication that is a bad thing for your case.  But given the lack of the callback it would appear that their philosophy has apparently always been that the user should really be the one to handle authentication.

You could try manually pairing before the connection that is by caling BluetoothSecurity.PairRequest (which results in a call to CBtIf::Bond).  That's if the device has a known PIN?  And likely that won't work if the link is v2.1/SSP.

I haven't had time to read the rest of your middle paragraph at the moment.  I'll try to find some time tomorrow or over the weekend.