1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-26 17:47:34 +01:00

Start to support activity summary version 518

Incomplete, lot of missing stuff. no swimming, etc.
This commit is contained in:
Andreas Shimokawa 2020-08-10 00:19:13 +02:00
parent b31fab1efc
commit 555eb34575

View File

@ -203,26 +203,73 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
summary.setBaseLatitude(baseLatitude); summary.setBaseLatitude(baseLatitude);
summary.setBaseAltitude(baseAltitude); summary.setBaseAltitude(baseAltitude);
// unused data (for now) int steps;
float distanceMeters = buffer.getFloat(); int activeSeconds;
float ascentMeters = buffer.getFloat(); int maxLatitude;
float descentMeters = buffer.getFloat(); int minLatitude;
float maxAltitude = buffer.getFloat(); int maxLongitude;
float minAltitude = buffer.getFloat(); int minLongitude;
int maxLatitude = buffer.getInt(); // format? float caloriesBurnt;
int minLatitude = buffer.getInt(); // format? float distanceMeters;
int maxLongitude = buffer.getInt(); // format? float ascentMeters = 0;
int minLongitude = buffer.getInt(); // format? float descentMeters = 0;
int steps = buffer.getInt(); float maxAltitude = 0;
int activeSeconds = buffer.getInt(); float minAltitude = 0;
float caloriesBurnt = buffer.getFloat(); float maxSpeed = 0;
float maxSpeed = buffer.getFloat(); float minPace;
float minPace = buffer.getFloat(); // format? float maxPace;
float maxPace = buffer.getFloat(); // format? float totalStride = 0;
float totalStride = buffer.getFloat(); float averageStride;
short averageHR;
short averageKMPaceSeconds;
// Just assuming, Bip has 259 which seems like 256+x
// Bip S now has 518 so assuming 512+x, might be wrong
if (version >= 512) {
steps = buffer.getInt();
activeSeconds = buffer.getInt();
//unknown
buffer.getLong();
buffer.getLong();
caloriesBurnt = buffer.getFloat();
distanceMeters = buffer.getFloat();
//unknown
buffer.getLong();
buffer.getLong();
buffer.getLong();
buffer.getLong();
maxPace = buffer.getFloat();
minPace = buffer.getFloat();
//unknown
buffer.getLong();
buffer.getLong();
buffer.getLong();
buffer.getLong();
buffer.getInt();
averageHR = buffer.getShort();
averageKMPaceSeconds = buffer.getShort();
averageStride = buffer.getShort();
buffer.getShort(); // unknown
} else {
distanceMeters = buffer.getFloat();
ascentMeters = buffer.getFloat();
descentMeters = buffer.getFloat();
maxAltitude = buffer.getFloat();
minAltitude = buffer.getFloat();
maxLatitude = buffer.getInt(); // format?
minLatitude = buffer.getInt(); // format?
maxLongitude = buffer.getInt(); // format?
minLongitude = buffer.getInt(); // format?
steps = buffer.getInt();
activeSeconds = buffer.getInt();
caloriesBurnt = buffer.getFloat();
maxSpeed = buffer.getFloat();
minPace = buffer.getFloat();
maxPace = buffer.getFloat();
totalStride = buffer.getFloat();
buffer.getInt(); // unknown buffer.getInt(); // unknown
if (activityKind == ActivityKind.TYPE_SWIMMING) { if (activityKind == ActivityKind.TYPE_SWIMMING) {
// 28 bytes // 28 bytes
float averageStrokeDistance = buffer.getFloat(); float averageStrokeDistance = buffer.getFloat();
@ -236,16 +283,6 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
buffer.getInt(); // unknown buffer.getInt(); // unknown
buffer.getShort(); // unknown buffer.getShort(); // unknown
LOG.debug("unused swim data:" +
"\naverageStrokeDistance=" + averageStrokeDistance +
"\naverageStrokesPerSecond=" + averageStrokesPerSecond +
"\naverageLapPace" + averageLapPace +
"\nstrokes=" + strokes +
"\nswolfIndex=" + swolfIndex +
"\nswimStyle=" + swimStyle + // 1 = breast, 2 = freestyle
"\nlaps=" + laps +
""
);
addSummaryData("averageStrokeDistance", averageStrokeDistance, "meter", "Strokes"); addSummaryData("averageStrokeDistance", averageStrokeDistance, "meter", "Strokes");
addSummaryData("averageStrokesPerSecond", averageStrokesPerSecond, "strokes_second", "Strokes"); addSummaryData("averageStrokesPerSecond", averageStrokesPerSecond, "strokes_second", "Strokes");
addSummaryData("averageLapPace", averageLapPace, "second", "Laps"); addSummaryData("averageLapPace", averageLapPace, "second", "Laps");
@ -263,44 +300,17 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
int descentSeconds = buffer.getInt() / 1000; //ms? int descentSeconds = buffer.getInt() / 1000; //ms?
buffer.getInt(); // unknown; buffer.getInt(); // unknown;
int flatSeconds = buffer.getInt() / 1000; // ms? int flatSeconds = buffer.getInt() / 1000; // ms?
LOG.debug("unused non-swim data:" +
"\nascentSeconds=" + ascentSeconds +
"\ndescentSeconds=" + descentSeconds +
"\nflatSeconds=" + flatSeconds +
""
);
addSummaryData("ascentSeconds", ascentSeconds, "seconds", "Elevation"); addSummaryData("ascentSeconds", ascentSeconds, "seconds", "Elevation");
addSummaryData("descentSeconds", descentSeconds, "seconds", "Elevation"); addSummaryData("descentSeconds", descentSeconds, "seconds", "Elevation");
addSummaryData("flatSeconds", flatSeconds, "seconds", "Elevation"); addSummaryData("flatSeconds", flatSeconds, "seconds", "Elevation");
} }
short averageHR = buffer.getShort(); averageHR = buffer.getShort();
short averageKMPaceSeconds = buffer.getShort(); averageKMPaceSeconds = buffer.getShort();
short averageStride = buffer.getShort(); averageStride = buffer.getShort();
}
LOG.debug("unused common:" +
"\ndistanceMeters=" + distanceMeters +
"\nascentMeters=" + ascentMeters +
"\ndescentMeters=" + descentMeters +
"\nmaxAltitude=" + maxAltitude +
"\nminAltitude=" + minAltitude +
//"\nmaxLatitude=" + maxLatitude + // not useful
//"\nminLatitude=" + minLatitude + // not useful
//"\nmaxLongitude=" + maxLongitude + // not useful
//"\nminLongitude=" + minLongitude + // not useful
"\nsteps=" + steps +
"\nactiveSeconds=" + activeSeconds +
"\ncaloriesBurnt=" + caloriesBurnt +
"\nmaxSpeed=" + maxSpeed +
"\nminPace=" + minPace +
"\nmaxPace=" + maxPace +
"\ntotalStride=" + totalStride +
"\naverageHR=" + averageHR +
"\naverageKMPaceSeconds=" + averageKMPaceSeconds +
"\naverageStride=" + averageStride +
""
);
// summary.setBaseCoordinate(new GPSCoordinate(baseLatitude, baseLongitude, baseAltitude)); // summary.setBaseCoordinate(new GPSCoordinate(baseLatitude, baseLongitude, baseAltitude));
// summary.setDistanceMeters(distanceMeters); // summary.setDistanceMeters(distanceMeters);
@ -329,8 +339,12 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
addSummaryData("distanceMeters", distanceMeters, "meters", "Activity"); addSummaryData("distanceMeters", distanceMeters, "meters", "Activity");
addSummaryData("ascentMeters", ascentMeters, "meters", "Elevation"); addSummaryData("ascentMeters", ascentMeters, "meters", "Elevation");
addSummaryData("descentMeters", descentMeters, "meters", "Elevation"); addSummaryData("descentMeters", descentMeters, "meters", "Elevation");
if (maxAltitude != -100000) {
addSummaryData("maxAltitude", maxAltitude, "meters", "Elevation"); addSummaryData("maxAltitude", maxAltitude, "meters", "Elevation");
}
if (minAltitude != 100000) {
addSummaryData("minAltitude", minAltitude, "meters", "Elevation"); addSummaryData("minAltitude", minAltitude, "meters", "Elevation");
}
addSummaryData("steps", steps, "steps_unit", "Activity"); addSummaryData("steps", steps, "steps_unit", "Activity");
addSummaryData("activeSeconds", activeSeconds, "seconds", "Activity"); addSummaryData("activeSeconds", activeSeconds, "seconds", "Activity");
addSummaryData("caloriesBurnt", caloriesBurnt, "calories_unit", "Activity"); addSummaryData("caloriesBurnt", caloriesBurnt, "calories_unit", "Activity");