javax.bluetooth
Interface DiscoveryListener


public interface DiscoveryListener

The DiscoveryListener interface allows an application to receive device discovery (but not service discovery) events. The reason for omitting service discovery is because NXT only allows one service: SPP (Serial Port Profile). It would be possible to implement the two service discovery methods but it would be complicated, require more memory usage (ServiceRecord and DataElement) and is not very useful. This interface provides two methods for discovering devices.

Version:
1.0 November 30, 2008 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 canceled.
static int INQUIRY_TERMINATED
          Indicates device discovery 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.
 

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 canceled.

The value of INQUIRY_ERROR is 0x07 (7).

See Also:
inquiryCompleted(int), DiscoveryAgent.startInquiry(int, 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. NOTE: If a device is found that has not yet been paired with the NXT brick, the name field of RemoteDevice will be blank. Make sure to pair your devices through the leJOS NXJ Bluetooth menu on your NXT.

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

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