Author Topic: Sending a file  (Read 2716 times)

Offline Hussain

  • Moderator
  • Newbie
  • *****
  • Posts: 43
  • Karma: 0
Sending a file
« on: April 13, 2007, 03:23:12 PM »
The BFFileTransferClient Object

For this you use the BFFileTransferClient as the simple approach. In this method you open the connection, send a file and close the connection. Your program will also get events on the progress.


Should be

The BFObjectPushClient Object

For this you use the BFObjectPushClient as the simple approach. In this method you open the connection, send a file and close the connection. Your program will also get events on the progress.


Modified: Mike Petrichenko

The progress events are as follows:
  • OnData
  • OnDisconnect
  • OnProgress: There is an ?Abort? parameter which will stop the transfer if set

Using this object to send a file is quite straightforward:

Sample: Send a file
Code: [Select]
    BFObjectPushClientX1.BluetoothTransport.Address = strDeviceAddress
    BFObjectPushClientX1.Open

    Debug.Print "Connected with " & BFObjectPushClientX1.BluetoothTransport.Address & _
        ". Service: " & BFObjectPushClientX1.BluetoothTransport.Service
    BFObjectPushClientX1.Put "C:\Temp\me.jpg"
    BFObjectPushClientX1.Close

As mentioned above, the OnProgress event will be fired multiple times showing how much of the file has been sent. You can change the ?Abort? parameter to stop sending a file.
« Last Edit: April 13, 2007, 04:53:01 PM by Mike Petrichenko »

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2467
  • Karma: 1000
    • Wireless Communication Library
Re: Sending a file
« Reply #1 on: April 14, 2007, 01:45:21 AM »
5.2 changes

Since 5.2 version Bluetooth Framework supports multi APIs. It mean, you should specify which Bluetooth dongle (radio module) the library must use to send file.

BFObjectPushClientX (as well as all other components which has BluetoothTransport property or which designed to use with Bluetooth (such as BFBluetoothCOMPOrtCreator)) now has Radio property.

Code: [Select]
BFObjectPushClientX.BluetoothTransport.Radio
How to specified the working radio? It is very easy. Firstly, you can use BFBluetoothDiscovery to enumerate installed radio modules and then assign one to this property. (See http://forum.btframework.com/index.php?topic=182.0 for more details)

Code: [Select]
BFObjectPushClientX.BluetoothTransport.Radio = Radio
Secondly, you can just assign selected (discvoered) device to Device property

Code: [Select]
BFObjectPushClient.BluetoothTRansport.Device = Device
If you are using BFObjectPushClient with other transport (not with Bluetooth) you do not need specify radio.

Also, you can refer to following topics (about radios and MultiAPIs(tm))

http://forum.btframework.com/index.php?topic=161.0
http://forum.btframework.com/index.php?topic=188.0


Modified: Mike Petrichenko
« Last Edit: April 14, 2007, 04:56:18 PM by Mike Petrichenko »
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager

Offline Hussain

  • Moderator
  • Newbie
  • *****
  • Posts: 43
  • Karma: 0
Re: Sending a file
« Reply #2 on: April 14, 2007, 04:20:15 PM »
Mike

Thanks. I shall update my document. As I said, I hadn't proof-read what I had written. I had posted the snippet here from my main Word document where I am documenting all the classes and how to use them to show people what I've been doing.

My original code had been written using BTF 5.1.5. I have been changing the code for 5.2.0.

The problem is that I had no idea just how much stuff I would have to write. I really need other volunteers to help me. People, step forward please.