Author Topic: BTF documentation project  (Read 2021 times)

Offline Hussain

  • Moderator
  • Newbie
  • *****
  • Posts: 43
  • Karma: 0
BTF documentation project
« on: April 12, 2007, 02:35:52 PM »
After seeing how much effort Mike is putting in, I felt compelled to help out and have started a document that will help people get started in using BTF as well as a reference guide for those who are experienced. Once the first draft is done, I'll post it here.

Firstly: Who is interested in chipping in and writing the document?
Secondly: What's the easiest way of posting it in a place where multiple people can edit it? If I put it on Google docs, I don't think I'll be able to put in images.

Also, I hope Mike won't object to this, but if he does I won't post it here.

Anyway, here's a sample from my document. Note, I haven't proof read it yet:

The BFAPIInfo Object
The first control to use is ?BFAPIInfo? and check that the needed transport is available.

Take note that if you remove or add a Bluetooth radio, GSM modem or cell phone via serial or infrared link, this object will keep showing old values unless and until the ?Redetect? method is called.

The methods of use are given below.

The BluetoothAPIs method returns a BFBluetoothAPIsX object which has four properties: baBlueSoleil, baToshiba, baWidComm and baWinsock. This shows which API is available on your system.

Use either HasBluetooth, HasSerial or HasIrDA properties or call the CheckTransport method for a particular transport. You can use Transports.Bluetooth etc. properties as well.

The EnumServices method is used to return the services offered by a device. When you use the BFBluetoothDiscovery object (see below) and don?t search for services, or when you just have the address of a device, use this method to discover its services.

Sample code: Getting API info
Code: [Select]
If BFAPIInfoX1.BluetoothAPIs.baBlueSoleil Then
  lblBTAPI.Caption = "BlueSoleil API"
ElseIf BFAPIInfoX1.BluetoothAPIs.baWidComm Then
  lblBTAPI.Caption = "WidComm API"
ElseIf BFAPIInfoX1.BluetoothAPIs.baWinSock Then
  lblBTAPI.Caption = "Microsoft API"
ElseIf BFAPIInfoX1.BluetoothAPIs.baToshiba Then
  lblBTAPI.Caption = "Toshiba API"
Else
  lblBTAPI.Caption = "No BT API"
End If

chkTransportBluetooth.Value = IIf(BFAPIInfoX1.HasBluetooth, vbChecked, vbUnchecked)
chkTransportIrDA.Value = IIf(BFAPIInfoX1.HasIrDA, vbChecked, vbUnchecked)
chkTransportSerial.Value = IIf(BFAPIInfoX1.HasSerial, vbChecked, vbUnchecked)

The BFBluetoothDiscovery Object
This object discovers Bluetooth devices such as cell phones and PDA?s as well as the computer?s own serial ports and Bluetooth adapters.

To list the computer?s Bluetooth adapters, use the EnumRadios method that returns a BFBluetoothRadiosX collection object. To list serial communication ports use the EnumCOMPorts method.

To use devices ? connected via Bluetooth or serial ? there are three options. Each option has a ?Fast? property which controls whether an actual search is made or to merely return the list of devices already discovered. If you use the fast method on the first try it won?t return anything because it won?t actually search.

The first option is to use the SelectDevice method. This will not raise any events but show a built-in window to select the transport, search for and show devices. It will then return a BFBluetoothDevice object.

The second option is to use the Discovery method. This option has three parameters other than the ?Fast? parameter mentioned above. The first is which radio to use. This is where you specify the radio object returned from the enumeration of radios. The second parameter is ?Fast?. The third is ?NeedServices? which controls whether to discover the services offered by each device. The fourth parameter is ?Blocking?. In blocking mode, your application will pause while discovery is made and a BFBluetoothDevicesX collection object will be returned. In non-blocking mode nothing will be returned and your application will continue executing. Your application will get events as each device is discovered.

The events sent by the object in non-blocking mode are:
  • OnComplete: This event is fired when all devices are discovered. A parameter within the event is BFBluetoothDevicesX which is a collection. Loop through the collection and you?ll get all the discovered devices.

The main advantage of using non-blocking mode is that your application can do other things while discovery is going on and that you can abort a search.

The third option is to run the background Monitoring method. This will keep running in the background and send events not just when a device is found, but also when it is lost. The events that you get when you call the Monitor
  • OnStartMonitoring: This event is fired when monitoring is started
  • OnStartSearch: This event is fired when searching starts
  • OnDeviceFound: This event is fired when a device is found
  • OnDeviceLost: This event is fired when a previously discovered device doesn?t respond within the search loop
  • OnStopSearch: This event is fired when searching finishes
  • OnStopMonitoring: This event is fired when monitoring is stopped

The search works in loops so that you?ll get multiple OnStartSearch and OnStopSearch events.