com.esf.device.bluetooth.discovery.service
Interface IBluetoothDiscovery


public interface IBluetoothDiscovery

This interface is used to perform a search for Bluetooth devices implementing a specific Bluetooth service.

The discoverDevices() methods is used to initiate a search. When isDiscoveryComplete() returns true, then the device and service discovery process is complete.

The getDiscoveredDevices() method can then be used to retrieve the entire collection of available devices and services. Please note that an application should release any reference to this device collection before again calling discoverDevices(). A best practice would be to call getDiscoveredDevices() and search through the collection. Copy any useful information to another variable. Then release the device collection.

Also note that there is only a single instance of the implementation of this service. The methods are not intended to be used by multiple clients at the same time. Multiple device discoveries should not be attempted at the same time.


Method Summary
 void discoverDevices(int serviceUUID)
          Initiate a Bluetooth device and device-service discovery process.
 java.util.ArrayList getDiscoveredDevices()
          Returns the collection of discovered Bluetooth devices.
 java.io.InputStream getInputStream(java.lang.String url)
          Use a URL from a BluetoothService object to open an input stream to the Bluetooth device.
 java.io.OutputStream getOutputStream(java.lang.String url)
          Use a URL from a BluetoothService object to open an output stream to the Bluetooth device.
 boolean isDiscoveryComplete()
          Returns an indication of whether Bluetooth device discovery is completely finished.
 

Method Detail

discoverDevices

public void discoverDevices(int serviceUUID)
                     throws java.lang.Exception
Initiate a Bluetooth device and device-service discovery process. The isDiscoveryComplete() method can be used to determine when device and service discovery is completely finished.

Parameters:
serviceUUID - The UUID of the Bluetooth service to search for on each Bluetooth device
Throws:
java.lang.Exception - if device discovery was already in process, or an error occurred during discovery startup.

isDiscoveryComplete

public boolean isDiscoveryComplete()
Returns an indication of whether Bluetooth device discovery is completely finished.

Returns:
true if device and service discovery is complete.

getDiscoveredDevices

public java.util.ArrayList getDiscoveredDevices()
Returns the collection of discovered Bluetooth devices. Each device in the collection will contain a collection of Bluetooth service descriptors, which match the UUID passed to discoverDevices() method.

Returns:
collection of discovered Bluetooth devices, or null if discovery not complete, or null if no devices found.

getInputStream

public java.io.InputStream getInputStream(java.lang.String url)
                                   throws java.lang.Exception
Use a URL from a BluetoothService object to open an input stream to the Bluetooth device.

Parameters:
url - Bluetooth device/service URL
Returns:
a new InputStream
Throws:
java.lang.Exception - if an error occurred opening the input stream

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String url)
                                     throws java.lang.Exception
Use a URL from a BluetoothService object to open an output stream to the Bluetooth device.

Parameters:
url - Bluetooth device/service URL
Returns:
a new OutputStream
Throws:
java.lang.Exception - if an error occurred opening the output stream


Copyright © 2009 Eurotech Inc. All rights reserved.