package io.trygvis.soilmoisture; import java.util.Date; class SmSensor { private final SmDevice device; public final long id; public final int index; private String name; private Date timestamp; private Integer lastValue; SmSensor(SmDevice device, long id, int index) { this.device = device; this.id = id; this.index = index; this.name = "Sensor #" + index; } public SmDevice getDevice() { return device; } public long getId() { return id; } public int getIndex() { return index; } public String getName() { return name; } public Integer getLastValue() { return lastValue; } public Date getTimestamp() { return timestamp; } // ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- public String toString() { return "SmSensor[id=" + id + ", " + "device=" + device.getBtDevice().getAddress() + ", " + "index=" + getIndex() + "]"; } public void readCurrentValue() { device.smService.readCurrentValue(this); } void updateLastValue(Date timestamp, int lastValue) { this.timestamp = timestamp; this.lastValue = lastValue; } }