private HashMap<MeasurementLevel, Integer> initLevels(Sensor sensor) { HashMap<MeasurementLevel, Integer> values = new HashMap<MeasurementLevel, Integer>(); for (MeasurementLevel level : MeasurementLevel.OBTAINABLE_LEVELS) { int threshold = settings.getThreshold(sensor, level); values.put(level, threshold); } thresholds.put(sensor, values); return values; }
@Inject public void init() { eventBus.register(this); Iterable<ExternalSensorDescriptor> descriptors = settings.knownSensors(); Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices(); for (ExternalSensorDescriptor descriptor : descriptors) { if (isPaired(descriptor, bondedDevices)) { if (sensors.containsKey(descriptor.getAddress())) { continue; } AbstractSensor sensor = createExternalSensor(descriptor); sensors.put(descriptor.getAddress(), sensor); } } }
public void disconnect(String address) { if (sensors.containsKey(address)) { sensors.remove(address).stop(); settings.knownSensorsWithout(address); } }