Search in sources :

Example 1 with BluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.BluetoothDevice in project smarthome by eclipse.

the class BlueGigaBridgeHandler method getDevice.

@SuppressWarnings({ "null", "unused" })
@Override
public BluetoothDevice getDevice(BluetoothAddress address) {
    BluetoothDevice device = devices.get(address);
    if (device == null) {
        // This method always needs to return a device, even if we don't currently know about it.
        device = new BlueGigaBluetoothDevice(this, address, BluetoothAddressType.UNKNOWN);
        devices.put(address, device);
    }
    return device;
}
Also used : BluetoothDevice(org.eclipse.smarthome.binding.bluetooth.BluetoothDevice) BlueGigaBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice) BlueGigaBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice)

Example 2 with BluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.BluetoothDevice in project smarthome by eclipse.

the class BluetoothDiscoveryService method addBluetoothAdapter.

@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addBluetoothAdapter(BluetoothAdapter adapter) {
    this.adapters.add(adapter);
    BluetoothDiscoveryListener listener = new BluetoothDiscoveryListener() {

        @Override
        public void deviceDiscovered(BluetoothDevice device) {
            BluetoothDiscoveryService.this.deviceDiscovered(adapter, device);
        }
    };
    adapter.addDiscoveryListener(listener);
    registeredListeners.put(adapter.getUID(), listener);
}
Also used : BluetoothDevice(org.eclipse.smarthome.binding.bluetooth.BluetoothDevice) BluetoothDiscoveryListener(org.eclipse.smarthome.binding.bluetooth.BluetoothDiscoveryListener) Reference(org.osgi.service.component.annotations.Reference)

Example 3 with BluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.BluetoothDevice in project smarthome by eclipse.

the class BlueGigaBridgeHandler method scanStart.

@Override
public void scanStart() {
    // Stop the passive scan
    bgStopProcedure();
    // Start a active scan
    bgStartScanning(true, activeScanInterval, activeScanWindow);
    for (BluetoothDevice device : devices.values()) {
        deviceDiscovered(device);
    }
}
Also used : BluetoothDevice(org.eclipse.smarthome.binding.bluetooth.BluetoothDevice) BlueGigaBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice)

Example 4 with BluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.BluetoothDevice in project smarthome by eclipse.

the class BlueZBridgeHandler method dispose.

@Override
public void dispose() {
    if (discoveryJob != null) {
        discoveryJob.cancel(true);
        discoveryJob = null;
    }
    for (BluetoothDevice device : devices.values()) {
        ((BlueZBluetoothDevice) device).dispose();
    }
    devices.clear();
}
Also used : BluetoothDevice(org.eclipse.smarthome.binding.bluetooth.BluetoothDevice) BlueZBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluez.BlueZBluetoothDevice) BlueZBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluez.BlueZBluetoothDevice)

Example 5 with BluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.BluetoothDevice in project smarthome by eclipse.

the class BlueZBridgeHandler method scanStart.

@Override
public void scanStart() {
    if (adapter != null) {
        if (!adapter.getDiscovering()) {
            adapter.setRssiDiscoveryFilter(-96);
            adapter.startDiscovery();
        }
        for (tinyb.BluetoothDevice tinybDevice : adapter.getDevices()) {
            synchronized (devices) {
                logger.debug("Device {} has RSSI {}", tinybDevice.getAddress(), tinybDevice.getRSSI());
                BluetoothDevice device = devices.get(tinybDevice.getAddress());
                if (device == null) {
                    createAndRegisterBlueZDevice(tinybDevice);
                } else {
                    // let's update the rssi and txpower values
                    device.setRssi(tinybDevice.getRSSI());
                    device.setTxPower(tinybDevice.getTxPower());
                    // The Bluetooth discovery expects a complete list on every scan,
                    // so we also have to report the already known devices.
                    notifyDiscoveryListeners(device);
                }
            }
        }
    }
}
Also used : BluetoothDevice(org.eclipse.smarthome.binding.bluetooth.BluetoothDevice) BlueZBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluez.BlueZBluetoothDevice)

Aggregations

BluetoothDevice (org.eclipse.smarthome.binding.bluetooth.BluetoothDevice)5 BlueGigaBluetoothDevice (org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice)2 BlueZBluetoothDevice (org.eclipse.smarthome.binding.bluetooth.bluez.BlueZBluetoothDevice)2 BluetoothDiscoveryListener (org.eclipse.smarthome.binding.bluetooth.BluetoothDiscoveryListener)1 Reference (org.osgi.service.component.annotations.Reference)1