Search in sources :

Example 1 with BlueGigaBluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice in project smarthome by eclipse.

the class BlueGigaBridgeHandler method bluegigaEventReceived.

@SuppressWarnings({ "unused", "null" })
@Override
public void bluegigaEventReceived(@Nullable BlueGigaResponse event) {
    if (event instanceof BlueGigaScanResponseEvent) {
        BlueGigaScanResponseEvent scanEvent = (BlueGigaScanResponseEvent) event;
        // We use the scan event to add any devices we hear to the devices list
        // The device gets created, and then manages itself for discovery etc.
        BluetoothAddress sender = new BluetoothAddress(scanEvent.getSender());
        BlueGigaBluetoothDevice device;
        if (devices.get(sender) == null) {
            logger.debug("BlueGiga adding new device to adaptor {}: {}", address, sender);
            device = new BlueGigaBluetoothDevice(this, new BluetoothAddress(scanEvent.getSender()), scanEvent.getAddressType());
            devices.put(sender, device);
            deviceDiscovered(device);
        }
        return;
    }
    if (event instanceof BlueGigaConnectionStatusEvent) {
        BlueGigaConnectionStatusEvent connectionEvent = (BlueGigaConnectionStatusEvent) event;
        connections.put(connectionEvent.getConnection(), new BluetoothAddress(connectionEvent.getAddress()));
    }
    if (event instanceof BlueGigaDisconnectedEvent) {
        BlueGigaDisconnectedEvent disconnectedEvent = (BlueGigaDisconnectedEvent) event;
        connections.remove(disconnectedEvent.getConnection());
    }
}
Also used : BluetoothAddress(org.eclipse.smarthome.binding.bluetooth.BluetoothAddress) BlueGigaBluetoothDevice(org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice) BlueGigaDisconnectedEvent(org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.connection.BlueGigaDisconnectedEvent) BlueGigaConnectionStatusEvent(org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.connection.BlueGigaConnectionStatusEvent) BlueGigaScanResponseEvent(org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.gap.BlueGigaScanResponseEvent)

Example 2 with BlueGigaBluetoothDevice

use of org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice 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)

Aggregations

BlueGigaBluetoothDevice (org.eclipse.smarthome.binding.bluetooth.bluegiga.BlueGigaBluetoothDevice)2 BluetoothAddress (org.eclipse.smarthome.binding.bluetooth.BluetoothAddress)1 BluetoothDevice (org.eclipse.smarthome.binding.bluetooth.BluetoothDevice)1 BlueGigaConnectionStatusEvent (org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.connection.BlueGigaConnectionStatusEvent)1 BlueGigaDisconnectedEvent (org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.connection.BlueGigaDisconnectedEvent)1 BlueGigaScanResponseEvent (org.eclipse.smarthome.binding.bluetooth.bluegiga.internal.command.gap.BlueGigaScanResponseEvent)1