Author Topic: OBEX session is not active  (Read 35621 times)

luis

  • Guest
OBEX session is not active
« on: March 15, 2011, 12:43:34 PM »
Good morning Mike,

I'm having doubts about his example vcl demo (IrDAOPPClientDemo.dpr). I managed to run your demo without any problems, but did not want to open a OpenDialog to fetch the file that I send to the destination device. I want to send directly, since I have my file in the c: \ file.txt.

His example is

TfmMain.btPutClick procedure (Sender: TObject);
var
  Stream: TFileStream;
begin
  then begin if OpenDialog.Execute
    Stream: = TFileStream.Create (OpenDialog.FileName, or fmOpenRead fmShareDenyWrite);
    wclShowError (wclOPPClient.Put (ExtractFileName (OpenDialog.FileName), Stream));
    Stream.Free;
  end;
end;

I wanted something so bad, but it's error OpenDialog obex but is operating normally:

  if FileExists ('c:\file.txt') then begin
    Stream: TFileStream.Create = ('c:\file.txt' or fmOpenRead fmShareDenyWrite);
    wclShowError (wclOPPClient.Put (ExtractFileName ('c:\file.txt'), Stream));
    Stream.Free;
  end;

It's this error, if I put OpenDialog works, what am I doing wrong?
---------------------------
Error
---------------------------
OBEX session is not active.
---------------------------
OK
---------------------------



Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: OBEX session is not active
« Reply #1 on: March 15, 2011, 12:47:08 PM »
You didn't call wclOPPClienbt.OpenOBEX.

luis

  • Guest
Re: OBEX session is not active
« Reply #2 on: March 15, 2011, 06:29:56 PM »
As I said, the obex was on but why the component works OpenDialog and if I pass the path to the file does not?

Thus the error yet, but if I change the path to OpenDialog work? Why?

  if Error = WCL_E_SUCCESS then
  begin
    wclShowError(wclOPPClient.OpenOBEXSession);

    //if OpenDialog.Execute then
    if FileExists('c:\file.txt') then
    begin

      Stream := TFileStream.Create('c:\file.txt', fmOpenRead or fmShareDenyWrite);
      {error}
      wclShowError(wclOPPClient.Put(ExtractFileName('c:\file.txt'), Stream));
      Stream.Free;
    end
    else
    begin
      wclShowError(wclOPPClient.CloseOBEXSession);
      wclOPPClient.Disconnect;
    end;
end;

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: OBEX session is not active
« Reply #3 on: March 15, 2011, 08:20:19 PM »
It appears because OBEX session is not opened yet as WCL is async. library. You have to wait OnOBEXOpen event.

 

Sitemap 1 2 3 4 5 6 7