Zum Inhalt

Bluetooth Scanner

If you’ve got any questions regarding this small piece of code, feel free to contact me!


1. BluetoothDeviceListener.java

package de.ifgi.ss2007.dwilmsmann.RIDE;

import javax.bluetooth.*;

public class BluetoothDeviceListener implements DiscoveryListener {

public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass deviceClass) {
 System.out.println(remoteDevice.getBluetoothAddress());
 }

public void inquiryCompleted(int complete) {
 }

public void servicesDiscovered(int transId, ServiceRecord[] records) {
 }

public void serviceSearchCompleted(int transId, int complete) {
 }

}

2. BluetoothScanner.java

package de.ifgi.ss2007.dwilmsmann.RIDE;

public class BluetoothScanner {

private static LocalDevice localDevice = null;
 private static DiscoveryAgent agent = null;

public void scanForDevices() {
 try {
 localDevice = LocalDevice.getLocalDevice();
 agent = localDevice.getDiscoveryAgent();
 agent.startInquiry(DiscoveryAgent.GIAC, new BluetoothDeviceListener());
 } catch (BluetoothStateException e) {
 e.printStackTrace();
 }
 }

public static void main(String[] args) {

BluetoothScanner bs = new BluetoothScanner();
 bs.scanForDevices();

}

}

3. Sources & sample application.

BluetoothScanner.zip

4. Kontakt / Contact

https://www.denniswilmsmann.de/bluetooth-scanner/
mailto:denniswilmsmann_AT_gmx.de

Schreibe den ersten Kommentar

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.