Author Topic: Catastrophic failure while Pairing  (Read 28006 times)

servel333

  • Guest
Catastrophic failure while Pairing
« on: June 03, 2008, 03:30:45 PM »
While attempting to pair, we are getting the following error:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
ErrorCode   -2147418113
StackTrace   
   at WCLX.wclBluetoothDevicexClass.Pair(wclBluetoothRadiox Radio, String PIN)
   at wclnet.wclBluetoothDevice.Pair(wclBluetoothRadio Radio, String PIN)

During testing, we have been pairing and unpairing over and over.  We are not pairing with a PDA or phone.

Also sometimes, after getting the previous error, I am also getting the following error while attempting to pair:

ErrorCode   -2147422205
Message     "Bluetooth API is not available"
StackTrace
   at WCLX.wclBluetoothDevicexClass.Pair(wclBluetoothRadiox Radio, String PIN)
   at wclnet.wclBluetoothDevice.Pair(wclBluetoothRadio Radio, String PIN)

Language: Visual Basic 2005
Stack: Microsoft
Driver: Microsoft
   Version: 5.1.2600.2180
   C:\WINDOWS\system32\bthprops.cpl
   C:\WINDOWS\system32\DRIVERS\bthport.sys
   C:\WINDOWS\system32\DRIVERS\BTHUSB.SYS
   C:\WINDOWS\system32\fsquirt.exe
Dongle:  Abe
   USB Version: 1.1
   USB PID: 0x0400
   USB VID: 0x080A
   Bluetooth Version:1.2
   Bluetooth Class: 2
   Chipset: National Semiconductor

When I posted this question before, you asked for sample code.  I will discuss this with my coworker and see what we can share.  Hopefully the information above will help you anyway.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Catastrophic failure while Pairing
« Reply #1 on: June 03, 2008, 04:25:45 PM »
Thank you for report the question.

How do you do pairing? What is the Radio object you passed to the Pair method? How do you get the Radio object? Do you call API.Load before call pair?

I need only code part wich actually do pairing. Nothing more

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #2 on: June 04, 2008, 06:30:25 PM »
We've been very busy over the past few days.  Sorry about posting this and then not getting back to you.  I should be able to give more details over the next few days and figure out if I think it's something my code is doing.

I will pay more attention to the Radio object that is passed into WCL functions and see if it's invalid in some way.

To answer some of the questions:
 - I do call API.Load() and make sure the API is loaded before calling any other methods.
 - I get the Radio object by calling EnumRadios() and then caching one of the radios in the list for future use during our pairing.

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #3 on: June 16, 2008, 10:59:04 PM »
I've modified the code to generate log files with details about the radio and also further examined the radio object being passed into the WCL classes and they seem fine to me.

------------------------------------------------------------
BluetoothDevice.IsPaired failed.
radio : BluetoothRadio: Name 'ROMEO', Address '(00:15:83:BF:8B:B9)', BluetoothStack 'Microsoft', Connectable 'True', Discoverable 'False', ;
Exception Message: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

Stack Trace:
   at WCLX.wclBluetoothDevicexClass.get_Paired(wclBluetoothRadiox Radio)
   at wclnet.wclBluetoothDevice.Paired(wclBluetoothRadio Radio)
   at AgaMatrix.BluetoothDevice.IsPaired(BluetoothRadio radio, Boolean& value)

If this helps at all, I was able to examine the WCLX.wclBluetoothRadioxClass object and found the following values about it:
      __DoFree   False   Boolean
      __Radio   105072940   Integer

This error seems to come up frequently and inconsistently.

I've also switched Bluetooth dongles since my last post:
   AluraTek  ABD2020
   USB Version 2.0
   VID 0x0A12
   PID 0x0001
   Bluetooth Version 2.0
   Class 2

My computer is
   Dell Optiplex 745

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #4 on: June 16, 2008, 11:06:36 PM »
Another note: I only seem to get this error when calling the Paired method.  I have been using it to determine if a device is paired with a specified radio.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Catastrophic failure while Pairing
« Reply #5 on: June 16, 2008, 11:20:00 PM »
Thank you for the very detailed report. With that information I have found the problem and now fixing it. I didn't "lock" the Radio object in memory before access it. So it passed to unmanaged code and then the NET decrease the usage count of object. So when I do actually call of Paired the object already destroyed.

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #6 on: June 17, 2008, 05:12:14 PM »
Thank you very much.  I've been hunting through my code over and over trying to find this issue (and I found some unrelated bugs in the process) but couldn't figure out where it was coming from.  I look forward to the next release.

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #7 on: July 31, 2008, 06:24:45 PM »
I seem to be getting this error again and have been seeing it for a while now, but I have not had time to report it to you.  Here is as much detail as I can figure out.

My coworker and I both agree this error has something to do with an object being disposed or odd memory usage, but cannot find it in our code.  I've examined the Radio object that is passed around and cannot find anything wrong with it at any point.  The WCL.Radio has no function to determine if it is disposed however, all the other properties in the class return valid values.

Here is a flow to get to this error:
 - Device is put into Discoverable mode
 - Application begins discovering over and over until the user enters a passkey and selects a device to pair with in the UI
 - Application calls Pair ( radio, passkey )
 - If Pair was successful, the application calls IsPaired ( radio )
 --  This is the call to WCL.Device.Paired that gives the "Catastrophic failure" error, oddly after another call to WCL.Device.Paired immediatly before.

Here is the flow of each of the specific wrapper functions involved:

Pair ( radio, passkey )
    If IsPaired(radio)
        Unpair(radio)
    WCL.Device.Pair(radio)

UnPair ( radio )
    If IsPaired(radio)
        WCL.Device.Unpair(radio)

IsPaired ( radio )
    WCL.Device.Paired(radio)

I usually see the Catastrophic failure message, about 3 out of every 4 pair attempts, however I saw this Out of Memory error once today and am not sure if it is related.

    System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
       at WCLX.wclBluetoothDevicexClass.get_Paired(wclBluetoothRadiox Radio)
       at wclnet.wclBluetoothDevice.Paired(wclBluetoothRadio Radio)

    System.Runtime.InteropServices.COMException (0x8000FFFF): Out of memory
       at WCLX.wclBluetoothDevicexClass.get_Paired(wclBluetoothRadiox Radio)
       at wclnet.wclBluetoothDevice.Paired(wclBluetoothRadio Radio)

This error happens on the latest release of the WCL, the version released on July 16th.

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #8 on: July 31, 2008, 06:30:36 PM »
After changing the below 3 function's flow, I found that this error now occurs when WCL.Device.Pair is called.


Pair ( radio, passkey )
    WCL.Device.Pair(radio)

UnPair ( radio )
    WCL.Device.Unpair(radio)

IsPaired ( radio )
    WCL.Device.Paired(radio)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Catastrophic failure while Pairing
« Reply #9 on: July 31, 2008, 07:04:55 PM »
Can you please send me all your code part executes Pair function (with the code part establishes radio object and device object) as a forum private message (to protect your code from public).

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Catastrophic failure while Pairing
« Reply #10 on: August 01, 2008, 11:39:55 AM »
Good day!

Did you receive my e-mail regarding the problem yesterday?

servel333

  • Guest
Re: Catastrophic failure while Pairing
« Reply #11 on: August 01, 2008, 03:26:20 PM »
I have received the email and found your suggestion to be correct.  For other forum readers:

The wclnet.wclBluetoothDevices list and wclnet.wclBluetoothDevice objects that are returned by the wclnet.wclBluetoothDiscovery.DiscoveryStarted event are not valid outside of the event.  To use the wclnet.wclBluetoothDevice objects outside of this context, you must create a new wclnet.wclBluetoothDevice and then call wclnet.wclBluetoothDevice.Asslign method.


    Dim deviceUsedOutsideDiscoveryCompleteEvent As wclnet.wclBluetoothDevice

    Private Sub _discovery_DiscoveryComplete(ByVal sender As Object, ByVal e As wclnet.BluetoothDiscoveryCompleteEventArgs) Handles _discovery.DiscoveryComplete

        deviceUsedOutsideDiscoveryCompleteEvent = New wclnet.wclBluetoothDevice
        deviceUsedOutsideDiscoveryCompleteEvent.Assign(e.Devices(0))
       
    End Sub


In addition, here is a question about the Assign method:

Good day!

wclBluetoothDevice.Assign - what does this do?

The Assign method of any class simple copy the one class, passed as parameter into current one. Let say you have the instance of the wclBluetoothDevice class. And also you have the global variable represents the currently used device. So you may fast copy the instance to the global variable by using Assign method.

Actually, it is mostly usefull for VCL version (because unmanaged code). For .NET version you may simple store the required instance in the any other variable (and the CLR will manage the instances).

Thank you Mike for your help.

 

Sitemap 1 2 3 4 5 6 7