peer2me.network.bluetooth
Class BluetoothServiceDiscovery

java.lang.Object
  extended bypeer2me.network.bluetooth.BluetoothServiceDiscovery
All Implemented Interfaces:
javax.bluetooth.DiscoveryListener

public class BluetoothServiceDiscovery
extends java.lang.Object
implements javax.bluetooth.DiscoveryListener

This class is responsible for doing the low level Bluetooth discovery operations. The class initializes seqential device discovery, and searches for services (the same MIDlet built upon the Peer2Me framework) on each of the found devices.

Author:
Torbjørn Vatn & Steinar A. Hestnes

Field Summary
 
Fields inherited from interface javax.bluetooth.DiscoveryListener
INQUIRY_COMPLETED, INQUIRY_ERROR, INQUIRY_TERMINATED, SERVICE_SEARCH_COMPLETED, SERVICE_SEARCH_DEVICE_NOT_REACHABLE, SERVICE_SEARCH_ERROR, SERVICE_SEARCH_NO_RECORDS, SERVICE_SEARCH_TERMINATED
 
Constructor Summary
BluetoothServiceDiscovery()
          Constructor.
 
Method Summary
 void deviceDiscovered(javax.bluetooth.RemoteDevice remoteDevice, javax.bluetooth.DeviceClass deviceClass)
          This method is called by the javax.bluetooth.DiscoveryAgent (agent) whenever a bluetooth device is discovered
 void doDeviceDiscovery()
          This method starts the discovery process.
 void inquiryCompleted(int discType)
          This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the discovery process is completed
 void servicesDiscovered(int transId, javax.bluetooth.ServiceRecord[] serviceRecord)
          This method is called by the javax.bluetooth.DiscoveryAgent (agent) whenever one or more services (read: Peer2Me framework) are found on a remote device
 void serviceSearchCompleted(int transID, int respCode)
          This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the search for services (read: Peer2Me framework) is completed
 void startServiceSearch(java.lang.String address)
          This method is used to re-establish a connection to a device when we have the address.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothServiceDiscovery

public BluetoothServiceDiscovery()
Constructor. Called from BluetoothNetwork.init().

Method Detail

doDeviceDiscovery

public void doDeviceDiscovery()
                       throws javax.bluetooth.BluetoothStateException
This method starts the discovery process. It is called from BluetoothNetwork.searchForNodes().

Throws:
javax.bluetooth.BluetoothStateException - Error getting reference to LocalDevice

deviceDiscovered

public void deviceDiscovered(javax.bluetooth.RemoteDevice remoteDevice,
                             javax.bluetooth.DeviceClass deviceClass)
This method is called by the javax.bluetooth.DiscoveryAgent (agent) whenever a bluetooth device is discovered

Specified by:
deviceDiscovered in interface javax.bluetooth.DiscoveryListener
Parameters:
remoteDevice - The device discovered
deviceClass - The device class of the discovered device

servicesDiscovered

public void servicesDiscovered(int transId,
                               javax.bluetooth.ServiceRecord[] serviceRecord)
This method is called by the javax.bluetooth.DiscoveryAgent (agent) whenever one or more services (read: Peer2Me framework) are found on a remote device

Specified by:
servicesDiscovered in interface javax.bluetooth.DiscoveryListener
Parameters:
transId - The transaction ID of the service search that is posting the result
serviceRecord - A list of services found during the search request

serviceSearchCompleted

public void serviceSearchCompleted(int transID,
                                   int respCode)
This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the search for services (read: Peer2Me framework) is completed

Specified by:
serviceSearchCompleted in interface javax.bluetooth.DiscoveryListener
Parameters:
transID - The transaction ID of the service search that is posting the result
respCode - The response code that indicates the status of the transaction

inquiryCompleted

public void inquiryCompleted(int discType)
This method is called by the javax.bluetooth.DiscoveryAgent (agent) when the discovery process is completed

Specified by:
inquiryCompleted in interface javax.bluetooth.DiscoveryListener
Parameters:
discType - The type of request that was completed; either INQUIRY_COMPLETED, INQUIRY_TERMINATED, or INQUIRY_ERROR

startServiceSearch

public void startServiceSearch(java.lang.String address)
This method is used to re-establish a connection to a device when we have the address.

Parameters:
address - The address to the device