com.intel.bluetooth
Class SelectServiceHandler

java.lang.Object
  extended by com.intel.bluetooth.SelectServiceHandler
All Implemented Interfaces:
DiscoveryListener

public class SelectServiceHandler
extends Object
implements DiscoveryListener

Implementation of DiscoveryAgent.selectService().

Your application should not use this class directly.


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
SelectServiceHandler(DiscoveryAgent agent)
           
 
Method Summary
 void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
          Called when a device is found during an inquiry.
 void inquiryCompleted(int discType)
          Called when an inquiry is completed.
 String selectService(UUID uuid, int security, boolean master)
          Attempts to locate a service that contains uuid in the ServiceClassIDList of its service record.
 void servicesDiscovered(int transID, ServiceRecord[] servRecord)
          Called when service(s) are found during a service search.
 void serviceSearchCompleted(int transID, int respCode)
          Called when a service search is completed or was terminated because of an error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectServiceHandler

public SelectServiceHandler(DiscoveryAgent agent)
Method Detail

selectService

public String selectService(UUID uuid,
                            int security,
                            boolean master)
                     throws BluetoothStateException
Attempts to locate a service that contains uuid in the ServiceClassIDList of its service record. This method will return a string that may be used in Connector.open() to establish a connection to the service. How the service is selected if there are multiple services with uuid and which devices to search is implementation dependent.

Parameters:
uuid - the UUID to search for in the ServiceClassIDList
security - specifies the security requirements for a connection to this service; must be one of ServiceRecord.NOAUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_NOENCRYPT, or ServiceRecord.AUTHENTICATE_ENCRYPT
master - determines if this client must be the master of the connection; true if the client must be the master; false if the client can be the master or the slave
Returns:
the connection string used to connect to the service with a UUID of uuid; or null if no service could be found with a UUID of uuid in the ServiceClassIDList
Throws:
BluetoothStateException - if the Bluetooth system cannot start the request due to the current state of the Bluetooth system
NullPointerException - if uuid is null
IllegalArgumentException - if security is not ServiceRecord.NOAUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_NOENCRYPT, or ServiceRecord.AUTHENTICATE_ENCRYPT
See Also:
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_NOENCRYPT, ServiceRecord.AUTHENTICATE_ENCRYPT

deviceDiscovered

public void deviceDiscovered(RemoteDevice btDevice,
                             DeviceClass cod)
Description copied from interface: DiscoveryListener
Called when a device is found during an inquiry. An inquiry searches for devices that are discoverable. During Bluetooth inquiry, a Bluetooth API implementation MUST report each discovered remote Bluetooth device only once. In other words, a Bluetooth API implementation MUST call the DiscoveryListener.deviceDiscovered() method only once for each individual discovered remote device.

Specified by:
deviceDiscovered in interface DiscoveryListener
Parameters:
btDevice - the device that was found during the inquiry
cod - - the service classes, major device class, and minor device class of the remote device
See Also:
DiscoveryAgent.startInquiry(int, javax.bluetooth.DiscoveryListener)

inquiryCompleted

public void inquiryCompleted(int discType)
Description copied from interface: DiscoveryListener
Called when an inquiry is completed. The discType will be DiscoveryListener.INQUIRY_COMPLETED if the inquiry ended normally or DiscoveryListener.INQUIRY_TERMINATED if the inquiry was canceled by a call to DiscoveryAgent.cancelInquiry(DiscoveryListener). The discType will be DiscoveryListener.INQUIRY_ERROR if an error occurred while processing the inquiry causing the inquiry to end abnormally.

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

serviceSearchCompleted

public void serviceSearchCompleted(int transID,
                                   int respCode)
Description copied from interface: DiscoveryListener
Called when a service search is completed or was terminated because of an error. Legal status values in the respCode argument include DiscoveryListener.SERVICE_SEARCH_COMPLETED, DiscoveryListener.SERVICE_SEARCH_TERMINATED, DiscoveryListener.SERVICE_SEARCH_ERROR, DiscoveryListener.SERVICE_SEARCH_NO_RECORDS and DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE. The following table describes when each respCode will be used:
respCodeReason
DiscoveryListener.SERVICE_SEARCH_COMPLETED if the service search completed normally
DiscoveryListener.SERVICE_SEARCH_TERMINATED if the service search request was cancelled by a call to DiscoveryAgent.cancelServiceSearch(int)
DiscoveryListener.SERVICE_SEARCH_ERROR if an error occurred while processing the request
DiscoveryListener.SERVICE_SEARCH_NO_RECORDS if no records were found during the service search
DiscoveryListener.SERVICE_SEARCH_DEVICE_NOT_REACHABLE if the device specified in the search request could not be reached or the local device could not establish a connection to the remote device

Specified by:
serviceSearchCompleted in interface DiscoveryListener
Parameters:
transID - the transaction ID identifying the request which initiated the service search
respCode - the response code that indicates the status of the transaction

servicesDiscovered

public void servicesDiscovered(int transID,
                               ServiceRecord[] servRecord)
Description copied from interface: DiscoveryListener
Called when service(s) are found during a service search.

Specified by:
servicesDiscovered in interface DiscoveryListener
Parameters:
transID - the transaction ID of the service search that is posting the result
servRecord - a list of services found during the search request
See Also:
DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener)


JSR-82 Javadocs Apache License, Version 2.0 Copyright © 2001-2008 Motorola, Inc. ALL RIGHTS RESERVED.
BlueCove Javadocs
Apache License, Version 2.0 Copyright © 2004-2008 BlueCove Team.