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