Author Topic: Complete Newbie needs help on sending files to Mobile phone  (Read 6603 times)

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Complete Newbie needs help on sending files to Mobile phone
« on: January 29, 2008, 01:00:44 PM »
Hi,

I hope you will bear with me as I am a complete newbie to bluetooth!!

What I would like to do is write an application that fines any bluetooth enabled phones in the area and sends a file to the phone. I need to do this all in code as it is an application that will run in the background.

I have downloaded the trial version on of your Framework VCL v5.2.2 I am using Delphi 6, I can use your demo to manually send a file to my phone no problem. I have looked at the thread named "BFFileTransferClient example, please?" I have tried the example you give in there but at the Transferclient open stage I keep getting an exception of

'Acess violiation at address 00479b75 in module 'Project1.exe'. Read of address 00000008'. Process stopped.

Can I have some help please, bearing in mind this is the first time I have ever looked at using bluetooth.

Thanks in advance.

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #1 on: January 29, 2008, 01:30:26 PM »
Good day!

The exception is raised because you are using Delphi 6 and Win XP. Dephi 5 and 6 has some bugs in TListView when it running under the IDE and the application uses XP thems (BTF includes WinXP manifest so any application uses XP thems). Simple run the application without IDE.

Regarding file sending. The better solution is using BFBluetoothMassSender. But this component works only with MS bluetooth drivers. If you need to make it working with other bluetooth drivers you may do it using BFBluetoothDiscovery and BFObjectPushClient components.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #2 on: January 29, 2008, 01:34:51 PM »
Wow that was a quick response, thank you but I am using Vista business 32 bit version. I will try it outside of the IDE.

Lee

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #3 on: January 29, 2008, 01:40:24 PM »
Mike,

Have tried it outside of the IDE and still get the exception when trying to 'Open'

Here is my code

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);

Var
  Devices: TBFBluetoothDevices;
  Loop: Integer;
  AFileName: String;

begin
  Devices := BFBluetoothDiscovery1.Discovery(Nil, False, False);
  AFileName := 'C:\Users\Lee\Pictures\kwikdata.gif';

  if Assigned(Devices) then begin
    for Loop := 0 to Devices.Count - 1 do
        with BFFileTransferClient1 do begin
          BluetoothTransport.Address := Devices[Loop].Address;
          try
            Open;
            try
              Put(AFileName); // Send file
            except
              on E : Exception do
                ShowMessage('File Send Failed'+#13+E.ClassName+' error raised, with message : '+E.Message);
            end;
            Close;
          except
            on E : Exception do
              ShowMessage('Open Falied'+#13+E.ClassName+' error raised, with message : '+E.Message);
          end;
        end;

    Devices.Free;
  end;
  Close;
end;

Thanks again

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #4 on: January 29, 2008, 01:49:51 PM »
Good day!

Ah. Now I see where is the problem :) TBFFileTransferClient requires the radio providing. It doesn't detect Radio module for use automatically. To avoid this just change this line:

BluetoothTransport.Address := Devices[Loop].Address;

to

BluetoothTransport.Device := Devices[Loop];

in your code.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #5 on: January 29, 2008, 01:55:33 PM »
Thanks Mike,

Sorry to be a pain but I am now getting a new error code

EOSError error raised, with message: System Error. Code: 10022.
An invalid argument was supplied

Cheers

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #6 on: January 29, 2008, 04:21:33 PM »
Good day!

It seems device was not paired before.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #7 on: January 29, 2008, 04:31:44 PM »
Mike,

Sorry to be totally thick but as i said i am a complete newbie to this sort of work.

In the application I wish to create I just want to scan for devices and send a file to that device, so on the users screen it will ask if they want to accept or reject a file.

Do I need to pair devices before sending a file? This could be a pain as the user won't know the PIN number as it is going to be used as a marketing tool.

Or is there a way of doing what i require so that i just find a bluetooth enabled device and try and send a file to it and hopes the receipant accepts the file.

Any examples would be greatly appreciated as Id love to be able to go back to my boss and say yes we can do it with these components and purchase them from you.

Regards,

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #8 on: January 29, 2008, 04:47:14 PM »
Good day!

I am recomend to you to change the TBFFileTransferClient component to the BFObjectPushClient component. It will usefull and easy fo your tasks.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #9 on: January 29, 2008, 05:05:02 PM »
Mike,

thanks for all your input i really appreciate it. I have changed the test application from TBfiletransferclient to the BFObjectpushclient and I get the follwoing error when trying to 'Open'.

EOSError error raised, with message.: System Error. Code 10022. An invalid argument was supplied.

Again here is my code I am using

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);

Var
  Devices: TBFBluetoothDevices;
  Loop: Integer;
  AFileName: String;

begin
  Devices := BFBluetoothDiscovery1.Discovery(Nil, False, False);
  AFileName := 'C:\Users\Lee\Pictures\kwikdata.gif';

  if Assigned(Devices) then begin
    for Loop := 0 to Devices.Count - 1 do
        with BFObjectPushClient1 do begin
          BluetoothTransport.Device := Devices[Loop];
          try
            Open;
            try
              Put(AFileName); // Send file
            except
              on E : Exception do
                ShowMessage('File Send Failed'+#13+E.ClassName+' error raised, with message : '+E.Message);
            end;
            Close;
          except
            on E : Exception do
              ShowMessage('Open Falied'+#13+E.ClassName+' error raised, with message : '+E.Message);
          end;
        end;

    Devices.Free;
  end;
  Close;
end;

Thanks again for you help.

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #10 on: January 29, 2008, 05:10:06 PM »
Hm. Its really interesting. May you test, does BTF demo application work?
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #11 on: January 29, 2008, 05:17:01 PM »
Mike,

Yes the demo works, on the first page if i remove the tick for authentication and then go to the tab for "objectpushclient" click send file then browse and find my phone (Samsung E900 just to let you know) then the phone asks do i want to connect to my pc, select yes then dem brings up box for selecting file to send and i choose a file and send it.

Sorry to be causing you problems.

Regards,

Lee

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #12 on: January 29, 2008, 05:27:14 PM »
OK. I'll post the code in 10 mins.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #13 on: January 29, 2008, 06:03:12 PM »
Mike,

I have been doing some more testing and playing around with it, and I have found that this error code 10022 as you said before is to do with the paring of the devices.  It gets curious here because I have grabbed my bosses mobile phone (Motorola raxr v3) and when I run my test it works like a charm on his phone.

On my phone (samsung E900) i can use the BFAuthentication component, set the default to say 0000 and when it trys to connect to my phone I can enter in the passkey of 0000 and then it works and sends the file. Alternativly within windows vista bluetooth components I can pre-pair the phone and my computer before running the application and it works in sending the file straight away.

Ideally I dont want to have to pair phones to PC as it is going to be used to send special offers to anybody passing by the shop to there phone automtically.

Is there any way to get round this requirement of some phones need paring and some phones don't?

Thanks again for all your time and effort on helping me with this. If I can get this cracked I'm sure by the end of this week we will purchase the components.

Regards,

Lee

Offline leekey

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Complete Newbie needs help on sending files to Mobile phone
« Reply #14 on: January 29, 2008, 06:13:41 PM »
Sorry Mike,

I dont know if this makes any difference but I have just noticed that if I use this code even after paring the samsung e999 to my pc

Code: [Select]
  BFAuthenticator1.Open;
  Devices := BFBluetoothDiscovery1.Discovery(Nil, False, False);
  AFileName := 'C:\Users\Lee\Pictures\kwikdata.gif';

  if Assigned(Devices) then begin
    for Loop := 0 to Devices.Count - 1 do
        with BFObjectPushClient1 do begin
          BluetoothTransport.Device := Devices[Loop];

          try
            Open;
            try
              Put(AFileName); // Send file
            except
              on E : Exception do
                ShowMessage('File Send Failed'+#13+E.ClassName+' error raised, with message : '+E.Message);
            end;
            Close;
          except
            on E : Exception do
              ShowMessage('Open Falied'+#13+E.ClassName+' error raised, with message : '+E.Message);
          end;
        end;

    Devices.Free;
  end;
  BFAuthenticator1.Close;
  Close;
end;

I still get the error code 10022 but if I use this code

Code: [Select]
Begin
  BFAuthenticator1.Open;
  with BFObjectPushClient1 do begin

    OpenDevice;


    if Active then begin
      try
        Put('C:\Users\Lee\Pictures\kwikdata.gif');
      finally
        Close;
      end;
    end;
  end;
  BFAuthenticator1.Close;
End;
procedure TForm1.BFAuthenticator1PINRequest(Sender: TObject;
  DeviceAddress: String; var PIN: String);
begin
  PIN := '0000';
end;

It works on my samsung E900 after paring. Ideally I could do with some code of what the BFObjectPushClient1.OpenDevice is doing so I can replicate it in code.

Thanks again and I am sorry to keep on bugging you.

Lee