Bluetooth device discovery
We will be only using the device discovery feature as this is the most stable part in the libraries on the Raspberry Pi. Also, there is only one mode available, which I will explain later. Let's close all tabs except for the Main
class.
In the main
method, have all the methods commented except for the runBluetoothDetectionExample();
method. Follow this method, which causes us to scroll down to the contents of this method:
/** * Runs the Bluetooth device discovery example. */ private static void runBluetoothDetectionExample(){ BluetoothDevices example = new BluetoothDevices(); example.init(); try { System.out.println("Starting device search, please wait."); example.runExample(); System.out.println("Search done"); } catch (DiscoveryFailedException ex) { System.err.println(ex.getMessage() + " because of " + ex.getCause().getMessage()); ...