Wireless Communication Library Support Forum
Frameworks => Bluetooth Framework => Topic started by: Veldrin on March 08, 2010, 01:40:57 PM
-
Hi,
I have encountered strange behaviour while trying to list services in descovered bluetooth device.
I modified some samples delivered with library to discover devices in the area and list only those of them that supports SPP service. So for every detected device I check if it have service SPP active by using function !wclErrors.wclShowError(wclBluetoothDevice.EnumServices(Radio, Services, wclUUIDs.SerialPortServiceClass_UUID))).
It works fine, but... it really rare happens that following window appears while executing EnumServices function:
(http://img534.imageshack.us/img534/7231/addbtdevice.png)
If I cancel it I have an "Internal driver error" message shown.
Why does it happen? Can it be somehow prevented by my application? It happens on Microsoft stack, I haven't tested it on any other stack.
-
Hi,
It appears because your device requires pairing to enumerate its services. Some devices need it. Just pair with device before check its services. To be sure try to enumerate ALL services. It it will not ask for PIN when you try to enumerate all services then it looks like a WCL bug. So let us know about result and:
1. OS?
2. Device?
3. BT Drivers?
-
Hi.
Enumerating all services generates same problem.
I would like to avoid situation that I have to pair devices before I really want to have conection with them. Is this totally device dependent?
OS: Windows XP Pro SP2,
BT Drivers:Microsoft 5.1.2600.2180
Device detected that needs pairing to list services: not sure, it's not mine
-
It depends on device model/settings. If device requires for pairing then there is no way to avoid it. Usualy it is Bluetooth HandsFree. Also it can be Fly or BlackBerry phones. However, you can use wclAuthenticator to avoid that message box and provide default PIN for such situations.
-
What will wclAuthenticator do if it fail to authenticate? Will it throw any exception or what?
-
It will do nothing but you will get error from method which cause authentication (EnumService for your case).
-
Well... I have to check it.
thanks for help.
-
Is there sample code to solve this? I have the same issue and it is also in the BT Discovery sample.
-
Yes. Check BluetoothDiscovery demo and Pair method. Also you can use wclAuthenticator,
-
Thanks for the quick response. I tried the BluethoothDiscovery demo before posting my question and it prompts for a PIN. I have tried the wclAuthenticator cannot get the syntax correct. This is what I have:
for (uint i = 0; i < e.Devices.Count; i++)
{
wcl.wclBluetoothDevice Device = e.Devices;
wcl.wclBluetoothServices Services = new wcl.wclBluetoothServices();
wcl.wclBluetoothRadio Radio = GetSelectedRadio();
if (Radio != null)
{
//Dim a As Integer = e.Device.EnumServices(Radio, Services, wcl.wclUUIDs.OBEXObjectPushServiceClass_UUID)
//e.Accept = ((a = wcl.wclErrors.WCL_E_SUCCESS) And (Services.Count > 0))
wcl.wclAuthenticator Authenticate = Radio;
if (!wcl.wclErrors.wclShowError(Device.EnumServices(Radio, Services, null)))
if (Services.Count == 0)
toolStripStatusLabelDiscovery.Text = "No Services found";
else
-
Hello,
You lost Authenticator.Open()
Please refer to Authenticator demo to see how it works.