Java Code Examples for javax.bluetooth.RemoteDevice#getBluetoothAddress()

The following examples show how to use javax.bluetooth.RemoteDevice#getBluetoothAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArdulinkDiscoveryListener.java    From Ardulink-1 with Apache License 2.0 6 votes vote down vote up
@Override
public void serviceSearchCompleted(int arg0, int arg1) {
	
	Map<String, ServiceRecord> ports = new HashMap<String, ServiceRecord>();
	
	for (Entry<RemoteDevice, ServiceRecord[]> entry : services.entrySet()) {
		RemoteDevice remoteDevice = entry.getKey();
		ServiceRecord service = findService(entry.getValue());
		if (service != null) {
			String name = "noname";
			try {
				name = remoteDevice.getFriendlyName(false);
			} catch (Exception e) {
			}

			name += " " + remoteDevice.getBluetoothAddress();
			ports.put(name, service);
		}
	}
	
	bluetoothConnection.setPorts(ports);
	
       synchronized (lock) {
           lock.notify();
       }
}
 
Example 2
Source File: BTDeviceDiscoveryService.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * transforms a {@link RemoteDevice} object from the bluecove API to our own datastructure for bluetooth devices
 * 
 * @param btDevice the device coming from the bluecove API
 * @return an instance of our own bluetooth device data structure
 */
private static BluetoothDevice toBluetoothDevice(RemoteDevice btDevice) {
    String address = btDevice.getBluetoothAddress();
    String friendlyName = "";
    try {
        friendlyName = btDevice.getFriendlyName(false);
    } catch (IOException e) {
        // no friendly name accessible, let's ignore that
    }
    boolean paired = btDevice.isTrustedDevice();
    return new BluetoothDevice(address, friendlyName, paired);
}
 
Example 3
Source File: BluetoothDiscovery.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
@Bind(aggregate = true, optional = true)
public void bindRemoteNamedDevice(RemoteDevice device) {
    ImportDeclaration iDec = null;
    String ba = null;
    String deviceName = null;
    try {
        ba = device.getBluetoothAddress();
        deviceName = device.getFriendlyName(false);
        LOG.debug("Building declaration for device " + ba);

        iDec = ImportDeclarationBuilder.empty()
                .key(ID).value(ba)
                .key(PROTOCOL_NAME).value("bluetooth")
                .key(BLUETOOTH_DEVICE_ADDRESS).value(ba)
                .key(BLUETOOTH_DEVICE_FRIENDLYNAME).value(deviceName)
                .key("scope").value("generic")
                .build();

    } catch (IOException e) {
        LOG.error("Can't get description from the device, maybe is already gone.", e);
        return;
    }

    LOG.debug("Add declaration for the device " + ba + "(" + deviceName + ")");

    registerImportDeclaration(iDec);
    bluetoothDevices.put(ba, iDec);
}
 
Example 4
Source File: BluetoothDiscovery.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
@Unbind
public void unbindRemoteNamedDevice(RemoteDevice device) {
    String ba = device.getBluetoothAddress();
    LOG.debug("Remove declaration for the device " + ba);

    unregisterImportDeclaration(bluetoothDevices.remove(ba));
}