Author Topic: Application Error when terminating discovery  (Read 7600 times)

OneEng

  • Guest
Application Error when terminating discovery
« on: August 14, 2014, 07:02:46 PM »
See the code below (using the Toshiba bluetooth stack):

First, start the discovery.  After discovery starts attempt to stop discovery.

The code below captures the error and makes it invisible to the user.  The discovery appears to work if you try again after termination, so the effect appears minimal (but annoying).


// terminate the discovery
void __fastcall TMTSBTTool::StopFindBtnClick(TObject *Sender)
{
   int Rc;
   if (wclBluetoothDiscovery->Active)
   {
      try
      {
         LstBx->Items->Insert(0,"Requesting terminate of discovery");
         Rc = wclBluetoothDiscovery->Terminate();
         LstBx->Items->Insert(0,"Termination Complete with return code = "+String(Rc));
         if (Rc!=WCL_E_SUCCESS)
            wclShowError(Rc);
      }
      catch(...)
      {
         // dont do anything since it seems to be a bug that doesn't have an effect
      }
   }
   else
      LstBx->Items->Insert(0,"Terminate requested, but discovery is not active.");

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Application Error when terminating discovery
« Reply #1 on: August 14, 2014, 09:05:49 PM »
Hello,

WCL version and error message?

OneEng

  • Guest
Re: Application Error when terminating discovery
« Reply #2 on: August 18, 2014, 09:27:22 PM »
I am an idiot Mike.

I was causing it by accessing the Devices object in the bluetooth discover event when it was Null.  Funny that the issue caused an exception in the terminate call though.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Application Error when terminating discovery
« Reply #3 on: August 18, 2014, 09:39:21 PM »
It happes with any of us :)

It is becasue OnDiscoveryComplete called from Terminate in this case.

 

Sitemap 1 2 3 4 5 6 7