aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/io/trygvis/android/bt/BtDevice.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/io/trygvis/android/bt/BtDevice.java')
-rw-r--r--app/src/main/java/io/trygvis/android/bt/BtDevice.java41
1 files changed, 35 insertions, 6 deletions
diff --git a/app/src/main/java/io/trygvis/android/bt/BtDevice.java b/app/src/main/java/io/trygvis/android/bt/BtDevice.java
index e34e9ea..edad522 100644
--- a/app/src/main/java/io/trygvis/android/bt/BtDevice.java
+++ b/app/src/main/java/io/trygvis/android/bt/BtDevice.java
@@ -3,9 +3,9 @@ package io.trygvis.android.bt;
import android.bluetooth.BluetoothDevice;
import android.util.Log;
-import io.trygvis.android.Function;
+import java.util.Date;
-public class BtDevice<A> {
+public class BtDevice<A extends BtDevice.BtDeviceWrapper<A>> {
private final static String TAG = BtDevice.class.getSimpleName();
private final DefaultBtService btService;
@@ -14,18 +14,31 @@ public class BtDevice<A> {
private BtScanResult scanResult;
private A tag;
- private boolean seenNow;
+ private final long id;
+ private final boolean seenBefore;
+ private final Date firstSeen;
+ private Date lastSeen;
- public static interface BtDeviceWrapper<A> {
+ public static interface BtDeviceWrapper<A extends BtDevice.BtDeviceWrapper<A>> {
BtDevice<A> getBtDevice();
}
- BtDevice(DefaultBtService btService, BluetoothDevice bluetoothDevice, Function<BtDevice<A>, A> tagConstructor, Integer rssi, BtScanResult scanResult) {
+ BtDevice(DefaultBtService btService, BluetoothDevice bluetoothDevice,
+ BtService.BtDbIntegration<A> btDbIntegration, long id, Integer rssi,
+ BtScanResult scanResult, boolean seenBefore, Date firstSeen, Date lastSeen) {
this.btService = btService;
this.bluetoothDevice = bluetoothDevice;
- this.tag = tagConstructor.apply(this);
+ this.tag = btDbIntegration.createTag(this);
+ this.id = id;
this.rssi = rssi;
this.scanResult = scanResult;
+ this.seenBefore = seenBefore;
+ this.firstSeen = firstSeen;
+ this.lastSeen = lastSeen;
+ }
+
+ public long getId() {
+ return id;
}
public A getTag() {
@@ -44,6 +57,22 @@ public class BtDevice<A> {
return rssi;
}
+ public boolean isSeenBefore() {
+ return seenBefore;
+ }
+
+ public Date getFirstSeen() {
+ return firstSeen;
+ }
+
+ public Date getLastSeen() {
+ return lastSeen;
+ }
+
+ public void setLastSeen(Date lastSeen) {
+ this.lastSeen = lastSeen;
+ }
+
public boolean connect(BtActionExecutor executor) {
Log.i(TAG, "connect(), address=" + bluetoothDevice.getAddress() + ", queue=" + executor);
bluetoothDevice.connectGatt(btService, false, executor.asCallback());