javax.bluetooth
Interface DiscoveryListener

All Known Implementing Classes:
SelectServiceHandler

public interface DiscoveryListener

The DiscoveryListener interface allows an application to receive device discovery and service discovery events. This interface provides four methods, two for discovering devices and two for discovering services. The JSR 82 specification does not require that implementations create individual threads for event delivery. Thus, if a DiscoveryListener method does not return or the return is delayed, the system may be blocked. So the following note is given for application developers :

The following DiscoveryListener methods SHOULD return immediately :


Field Summary
static int INQUIRY_COMPLETED
          Indicates the normal completion of device discovery.
static int INQUIRY_ERROR
          Indicates that the inquiry request failed to complete normally, but was not cancelled.
static int INQUIRY_TERMINATED
          Indicates device discovery has been canceled by the application and did not complete.
static int SERVICE_SEARCH_COMPLETED
          Indicates the normal completion of service discovery.
static int SERVICE_SEARCH_DEVICE_NOT_REACHABLE
          Indicates the service search could not be completed because the remote device provided to DiscoveryAgent.searchServices() could not be reached.
static int SERVICE_SEARCH_ERROR
          Indicates the service search terminated with an error.
static int SERVICE_SEARCH_NO_RECORDS
          Indicates the service search has completed with no service records found on the device.
static int SERVICE_SEARCH_TERMINATED
          Indicates the service search has been canceled by the application and did not complete.
 
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.
 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.
 

Field Detail

INQUIRY_COMPLETED

static final int INQUIRY_COMPLETED
Indicates the normal completion of device discovery. Used with the inquiryCompleted(int) method.

The value of INQUIRY_COMPLETED is 0x00 (0).

See Also:
inquiryCompleted(int), DiscoveryAgent.startInquiry(int, javax.bluetooth.DiscoveryListener), Constant Field Values

INQUIRY_TERMINATED

static final int INQUIRY_TERMINATED
Indicates device discovery has been canceled by the application and did not complete. Used with the inquiryCompleted(int) method.

The value of INQUIRY_TERMINATED is 0x05 (5).

See Also:
inquiryCompleted(int), DiscoveryAgent.startInquiry(int, javax.bluetooth.DiscoveryListener), DiscoveryAgent.cancelInquiry(javax.bluetooth.DiscoveryListener), Constant Field Values

INQUIRY_ERROR

static final int INQUIRY_ERROR
Indicates that the inquiry request failed to complete normally, but was not cancelled.

The value of INQUIRY_ERROR is 0x07 (7).

See Also:
inquiryCompleted(int), DiscoveryAgent.startInquiry(int, javax.bluetooth.DiscoveryListener), Constant Field Values

SERVICE_SEARCH_COMPLETED

static final int SERVICE_SEARCH_COMPLETED
Indicates the normal completion of service discovery. Used with the serviceSearchCompleted(int, int) method.

The value of SERVICE_SEARCH_COMPLETED is 0x01 (1).

See Also:
serviceSearchCompleted(int, int), DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener), Constant Field Values

SERVICE_SEARCH_TERMINATED

static final int SERVICE_SEARCH_TERMINATED
Indicates the service search has been canceled by the application and did not complete. Used with the serviceSearchCompleted(int, int) method.

The value of SERVICE_SEARCH_TERMINATED is 0x02 (2).

See Also:
serviceSearchCompleted(int, int), DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener), DiscoveryAgent.cancelServiceSearch(int), Constant Field Values

SERVICE_SEARCH_ERROR

static final int SERVICE_SEARCH_ERROR
Indicates the service search terminated with an error. Used with the serviceSearchCompleted(int, int) method.

The value of SERVICE_SEARCH_ERROR is 0x03 (3).

See Also:
serviceSearchCompleted(int, int), DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener), Constant Field Values

SERVICE_SEARCH_NO_RECORDS

static final int SERVICE_SEARCH_NO_RECORDS
Indicates the service search has completed with no service records found on the device. Used with the serviceSearchCompleted(int, int) method.

The value of SERVICE_SEARCH_NO_RECORDS is 0x04 (4).

See Also:
serviceSearchCompleted(int, int), DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener), Constant Field Values

SERVICE_SEARCH_DEVICE_NOT_REACHABLE

static final int SERVICE_SEARCH_DEVICE_NOT_REACHABLE
Indicates the service search could not be completed because the remote device provided to DiscoveryAgent.searchServices() could not be reached. Used with the serviceSearchCompleted(int, int) method.

The value of SERVICE_SEARCH_DEVICE_NOT_REACHABLE is 0x06 (6).

See Also:
serviceSearchCompleted(int, int), DiscoveryAgent.searchServices(int[], javax.bluetooth.UUID[], javax.bluetooth.RemoteDevice, javax.bluetooth.DiscoveryListener), Constant Field Values
Method Detail

deviceDiscovered

void deviceDiscovered(RemoteDevice btDevice,
                      DeviceClass cod)
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.

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)

servicesDiscovered

void servicesDiscovered(int transID,
                        ServiceRecord[] servRecord)
Called when service(s) are found during a service search.

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)

serviceSearchCompleted

void serviceSearchCompleted(int transID,
                            int respCode)
Called when a service search is completed or was terminated because of an error. Legal status values in the respCode argument include SERVICE_SEARCH_COMPLETED, SERVICE_SEARCH_TERMINATED, SERVICE_SEARCH_ERROR, SERVICE_SEARCH_NO_RECORDS and SERVICE_SEARCH_DEVICE_NOT_REACHABLE. The following table describes when each respCode will be used:
respCodeReason
SERVICE_SEARCH_COMPLETED if the service search completed normally
SERVICE_SEARCH_TERMINATED if the service search request was cancelled by a call to DiscoveryAgent.cancelServiceSearch(int)
SERVICE_SEARCH_ERROR if an error occurred while processing the request
SERVICE_SEARCH_NO_RECORDS if no records were found during the service search
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

Parameters:
transID - the transaction ID identifying the request which initiated the service search
respCode - the response code that indicates the status of the transaction

inquiryCompleted

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

Parameters:
discType - the type of request that was completed; either INQUIRY_COMPLETED, INQUIRY_TERMINATED, or INQUIRY_ERROR
See Also:
INQUIRY_COMPLETED, INQUIRY_TERMINATED, INQUIRY_ERROR


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.