BluetoothSensorManager: on initiate connect to sensor, report address to be shown on UI.

Fixes #64.
This commit is contained in:
Dennis Guse
2020-10-31 08:42:20 +01:00
parent 08b9cb31fa
commit b6850eb46f
6 changed files with 56 additions and 6 deletions
@@ -1,5 +1,7 @@
package de.dennisguse.opentracks.content.sensor;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import de.dennisguse.opentracks.services.sensors.BluetoothRemoteSensorManager;
@@ -11,6 +13,10 @@ public class SensorData {
private final long timestamp_ms;
SensorData(String sensorAddress) {
this(sensorAddress, null, System.currentTimeMillis());
}
SensorData(String sensorAddress, String sensorName) {
this(sensorAddress, sensorName, System.currentTimeMillis());
}
@@ -22,14 +28,20 @@ public class SensorData {
this.timestamp_ms = timestamp_ms;
}
@NonNull
public String getSensorAddress() {
return sensorAddress;
}
@Nullable
public String getSensorName() {
return sensorName;
}
public String getSensorNameOrAddress() {
return sensorName != null ? sensorName : sensorAddress;
}
/**
* Is the data recent considering the current time.
*/
@@ -29,6 +29,12 @@ public final class SensorDataCycling {
private final int crankRevolutionsTime; // UINT16; 1/1024s
private float cadence_rpm = INVALID_VALUE_FLOAT;
public Cadence(String sensorAddress) {
super(sensorAddress);
this.crankRevolutionsCount = INVALID_VALUE_INT;
this.crankRevolutionsTime = INVALID_VALUE_INT;
}
public Cadence(String sensorAddress, String sensorName, long crankRevolutionsCount, int crankRevolutionsTime) {
super(sensorAddress, sensorName);
this.crankRevolutionsCount = crankRevolutionsCount;
@@ -97,6 +103,12 @@ public final class SensorDataCycling {
private final int wheelRevolutionsTime; // UINT16; 1/1024s
private float speed_mps = INVALID_VALUE_FLOAT;
public Speed(String sensorAddress) {
super(sensorAddress);
this.wheelRevolutionsCount = INVALID_VALUE_INT;
this.wheelRevolutionsTime = INVALID_VALUE_INT;
}
public Speed(String sensorAddress, String sensorName, int wheelRevolutionsCount, int wheelRevolutionsTime) {
super(sensorAddress, sensorName);
this.wheelRevolutionsCount = wheelRevolutionsCount;
@@ -6,6 +6,11 @@ public class SensorDataHeartRate extends SensorData {
private final float heartRate_bpm;
public SensorDataHeartRate(String address) {
super(address);
heartRate_bpm = Float.NaN;
}
public SensorDataHeartRate(String name, String address, float heartRate_bpm) {
super(name, address);
this.heartRate_bpm = heartRate_bpm;