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());
}
}
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;
}
Aggregations