0

I want to know if it is possible to put a device in inquiry mode permanently, using blue cove.

Here is the code actually, it only puts the device in inquiry for a short period of time.

public class DescobrirDispositivos {

    /**
     * @param args
     * @throws BluetoothStateException
     * @throws InterruptedException
     */
    public static final Vector/*<RemoteDevice>*/ devicesDiscovered = new Vector();

    public static void main(String[] args) throws BluetoothStateException,
            InterruptedException {

        final Object inquiryCompletedEvent = new Object();

        DiscoveryListener listener = new DiscoveryListener() {

            @Override
            public void servicesDiscovered(int arg0, ServiceRecord[] arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void serviceSearchCompleted(int arg0, int arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void inquiryCompleted(int discType) {
                synchronized (inquiryCompletedEvent) {
                    inquiryCompletedEvent.notifyAll();
                }
            }

            @Override
            public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
                devicesDiscovered.addElement(btDevice);
                System.out.println("Device " + btDevice.getBluetoothAddress()
                        + " found");
                try {
                    System.out.println("Name " + btDevice.getFriendlyName(false));
                } catch (IOException cantGetDeviceName) {
                    // TODO Auto-generated catch block

                }

            }
        };
        synchronized (inquiryCompletedEvent) {

            boolean started = LocalDevice.getLocalDevice().getDiscoveryAgent()
                    .startInquiry(DiscoveryAgent.GIAC, listener);        
        if (started) {
                inquiryCompletedEvent.wait();
            }
        }
    }

}
szegedi
  • 863
  • 8
  • 20

1 Answers1

0

No, there is no concept of permanent inquiry. There's not much use case for it, as it burns ridiculous amounts of power, and a single inquiry period is sufficient to discover most nearby devices. But if you want to keep doing inquiry, it's trivial to just restart inquiry each time it ends.

TJD
  • 11,800
  • 1
  • 26
  • 34