Author Topic: TwclDiscovery.StopMonitoring problem  (Read 7240 times)

gomsun2

  • Guest
TwclDiscovery.StopMonitoring problem
« on: July 18, 2014, 05:17:12 PM »
Hello Mike Petrichenko.

I have two dongles.
- Toshiba
- Microsoft

A problem occurred when used Toshiba dongle/API.
My application executes a TwclBluetoothDiscovery.StartMonitoring and it handles in OnDeviceFound.
My problem is that the application freezes until "wclBlutoothDiscovery.StopMonitoring" is finished.

But if using a Microsoft dongle, the problem does not occur.

Please give me an advice to solve this problem.
Thank you for your time.

The following is my code.
Code: [Select]
procedure TbluetoothModule.wclDiscoveryDeviceFound(Sender: TObject;
  Radio: TwclBluetoothRadio; Device: TwclBluetoothDevice);
var
  LRadio: TwclBluetoothRadio;
  LDevice: TwclBluetoothDevice;
begin
  if FMonitoringActive then
  begin
    LRadio := TwclBluetoothRadio.Create;
    try
      LRadio.Assign(Radio);
      LDevice := TwclBluetoothDevice.Create;
      try
        LDevice.Address := Device.Address;
        DvcMakeAuthConnection(LDevice, Radio)
      finally
        FreeAndNil(LDevice);
      end;
    finally
      FreeAndNil(LRadio)
    end;
  end
  else if not TimerClient.Enabled then
    TimerClient.Enabled := True;
end;

function TbluetoothModule.DvcMakeAuthConnection(
  const ADevice: TwclBluetoothDevice; const ARadio: TwclBluetoothRadio): Boolean;
begin
  if Assigned(FDevice) and not FMonitoringActive then
    Exit;

  Result := ADevice.Name(ARadio).ToLower.Contains(BT_DEVICE);
  Log.Msg(Result, '  target: %s, device: %s %s', [BT_DEVICE, ADevice.Name(ARadio), ADevice.Addr]);
  if Result then
  begin
    if Assigned(FDevice) then
      FreeAndNil(FDevice);
    FDevice := TwclBluetoothDevice.Create;
    FDevice.Address := ADevice.Address;
    if wclAuth.Active then
      wclAuth.Close;
    wclAuth.Radio := ARadio;
    if wclExeLog(wclAuth.Open, 'Open Authenticator') then
    begin
      wclClient.BluetoothParams.Radio := ARadio;
      wclClient.BluetoothParams.Address := FDevice.Address;
      wclExeLog(wclClient.Connect, 'bluetooth device conntect');
    end;
  end;
end;

procedure TbluetoothModule.TimerClientTimer(Sender: TObject);
begin
  if TimerClient.Enabled then
  begin
    TimerClient.Enabled := False;

    if wclClient.State in [csConnecting, csConnected] then
      wclClient.Disconnect;

    if wclAuth.Active then
      wclAuth.Close;

    if wclDiscovery.Monitoring then
      wclExeLog(wclDiscovery.StopMonitoring, 'discovery monitoring stop');   
  end;
end;
« Last Edit: July 18, 2014, 05:21:17 PM by gomsun2 »

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: TwclDiscovery.StopMonitoring problem
« Reply #1 on: July 19, 2014, 07:13:01 AM »
Hello,

Thank you for your report. I will check it out and try to fix.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: TwclDiscovery.StopMonitoring problem
« Reply #2 on: July 19, 2014, 10:13:29 PM »
Ok, the problem has been fixed, The fix will be available in comming version.

gomsun2

  • Guest
Re: TwclDiscovery.StopMonitoring problem
« Reply #3 on: July 21, 2014, 04:44:12 AM »
Hello,

Thank you for your quick response  :)

 

Sitemap 1 2 3 4 5 6 7