FileDocCategorySizeDatePackage
BluetoothSearch.javaAPI DocExample2195Thu Feb 16 12:35:26 GMT 2006None

BluetoothSearch

public class BluetoothSearch extends Object implements DiscoveryListener

Fields Summary
private DiscoveryAgent
agent
Constructors Summary
Methods Summary
public voiddeviceDiscovered(RemoteDevice device, DeviceClass type)

    int major = type.getMajorDeviceClass();
    int minor = type.getMinorDeviceClass();
    int services = type.getServiceClasses();
    int classIdentifier = major | minor | services;
    try {
      System.out.println("Found " + device.getFriendlyName(false)
       + " at " + device.getBluetoothAddress());
    } 
    catch (IOException ex) {
      System.out.println("Found unnamed device " 
       + " at " + device.getBluetoothAddress());
    }
    System.out.println("  Major class: 0x" + Integer.toHexString(major));
    System.out.println("  Minor class: 0x" + Integer.toHexString(minor));
    System.out.println("  Service classes: 0x" + Integer.toHexString(services));
    System.out.println("  Class identifier: 0x" 
     + Integer.toHexString(classIdentifier));
    System.out.println("  Class identifier: " 
     + Integer.toBinaryString(classIdentifier));
  
public voidinquiryCompleted(int discoveryType)

    
    switch (discoveryType) {
      case DiscoveryListener.INQUIRY_TERMINATED:
        System.out.println("Search cancelled");
        break;
      case DiscoveryListener.INQUIRY_ERROR:
        System.out.println("Bluetooth error");
        break;
      case DiscoveryListener.INQUIRY_COMPLETED:
        System.out.println("Device search complete");;
        break;
      default: 
        System.out.println("Unanticipated result: " + discoveryType);
    }
    
    System.exit(0);
  
public static voidmain(java.lang.String[] args)

 
    BluetoothSearch search = new BluetoothSearch();
    search.agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
    search.agent.startInquiry(DiscoveryAgent.GIAC, search);
  
public voidserviceSearchCompleted(int transactionID, int arg1)

public voidservicesDiscovered(int transactionID, ServiceRecord[] record)