1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 01:09:47 +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

@ -171,7 +171,7 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
ByteBuffer buffer = ByteBuffer.wrap(stream.toByteArray()).order(ByteOrder.LITTLE_ENDIAN); ByteBuffer buffer = ByteBuffer.wrap(stream.toByteArray()).order(ByteOrder.LITTLE_ENDIAN);
// summary.setVersion(BLETypeConversions.toUnsigned(buffer.getShort())); // summary.setVersion(BLETypeConversions.toUnsigned(buffer.getShort()));
short version = buffer.getShort(); // version short version = buffer.getShort(); // version
LOG.debug("Got sport summary version " + version + "total bytes=" + buffer.capacity()); LOG.debug("Got sport summary version " + version + " total bytes=" + buffer.capacity());
int activityKind = ActivityKind.TYPE_UNKNOWN; int activityKind = ActivityKind.TYPE_UNKNOWN;
try { try {
int rawKind = BLETypeConversions.toUnsigned(buffer.getShort()); int rawKind = BLETypeConversions.toUnsigned(buffer.getShort());
@ -203,105 +203,115 @@ 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;
buffer.getInt(); // unknown // Just assuming, Bip has 259 which seems like 256+x
// Bip S now has 518 so assuming 512+x, might be wrong
if (activityKind == ActivityKind.TYPE_SWIMMING) { if (version >= 512) {
// 28 bytes steps = buffer.getInt();
float averageStrokeDistance = buffer.getFloat(); activeSeconds = buffer.getInt();
float averageStrokesPerSecond = buffer.getFloat(); //unknown
float averageLapPace = buffer.getFloat(); buffer.getLong();
short strokes = buffer.getShort(); buffer.getLong();
short swolfIndex = buffer.getShort(); caloriesBurnt = buffer.getFloat();
byte swimStyle = buffer.get(); distanceMeters = buffer.getFloat();
byte laps = buffer.get(); //unknown
buffer.getInt(); // unknown buffer.getLong();
buffer.getInt(); // unknown 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 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("averageStrokesPerSecond", averageStrokesPerSecond, "strokes_second","Strokes");
addSummaryData("averageLapPace", averageLapPace, "second", "Laps");
addSummaryData("strokes", strokes, "strokes", "Strokes");
addSummaryData("swolfIndex", swolfIndex, "swolf_index", "Swimming");
addSummaryData("swimStyle", swimStyle, "swim_style", "Swimming");
addSummaryData("laps", laps, "laps", "Laps");
} else { } else {
// 28 bytes 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
buffer.getInt(); // unknown if (activityKind == ActivityKind.TYPE_SWIMMING) {
int ascentSeconds = buffer.getInt() / 1000; //ms? // 28 bytes
buffer.getInt(); // unknown; float averageStrokeDistance = buffer.getFloat();
int descentSeconds = buffer.getInt() / 1000; //ms? float averageStrokesPerSecond = buffer.getFloat();
buffer.getInt(); // unknown; float averageLapPace = buffer.getFloat();
int flatSeconds = buffer.getInt() / 1000; // ms? short strokes = buffer.getShort();
LOG.debug("unused non-swim data:" + short swolfIndex = buffer.getShort();
"\nascentSeconds=" + ascentSeconds + byte swimStyle = buffer.get();
"\ndescentSeconds=" + descentSeconds + byte laps = buffer.get();
"\nflatSeconds=" + flatSeconds + buffer.getInt(); // unknown
"" buffer.getInt(); // unknown
); buffer.getShort(); // unknown
addSummaryData("ascentSeconds", ascentSeconds, "seconds", "Elevation");
addSummaryData("descentSeconds", descentSeconds, "seconds", "Elevation"); addSummaryData("averageStrokeDistance", averageStrokeDistance, "meter", "Strokes");
addSummaryData("flatSeconds", flatSeconds, "seconds", "Elevation"); addSummaryData("averageStrokesPerSecond", averageStrokesPerSecond, "strokes_second", "Strokes");
addSummaryData("averageLapPace", averageLapPace, "second", "Laps");
addSummaryData("strokes", strokes, "strokes", "Strokes");
addSummaryData("swolfIndex", swolfIndex, "swolf_index", "Swimming");
addSummaryData("swimStyle", swimStyle, "swim_style", "Swimming");
addSummaryData("laps", laps, "laps", "Laps");
} else {
// 28 bytes
buffer.getInt(); // unknown
buffer.getInt(); // unknown
int ascentSeconds = buffer.getInt() / 1000; //ms?
buffer.getInt(); // unknown;
int descentSeconds = buffer.getInt() / 1000; //ms?
buffer.getInt(); // unknown;
int flatSeconds = buffer.getInt() / 1000; // ms?
addSummaryData("ascentSeconds", ascentSeconds, "seconds", "Elevation");
addSummaryData("descentSeconds", descentSeconds, "seconds", "Elevation");
addSummaryData("flatSeconds", flatSeconds, "seconds", "Elevation");
}
averageHR = buffer.getShort();
averageKMPaceSeconds = buffer.getShort();
averageStride = buffer.getShort();
} }
short averageHR = buffer.getShort();
short averageKMPaceSeconds = buffer.getShort();
short 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);
// summary.setAscentMeters(ascentMeters); // summary.setAscentMeters(ascentMeters);
@ -327,11 +337,15 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
// summary.setAverageStride(BLETypeConversions.toUnsigned(averageStride); // summary.setAverageStride(BLETypeConversions.toUnsigned(averageStride);
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");
addSummaryData("maxAltitude", maxAltitude,"meters", "Elevation"); if (maxAltitude != -100000) {
addSummaryData("minAltitude", minAltitude,"meters", "Elevation"); addSummaryData("maxAltitude", maxAltitude, "meters", "Elevation");
addSummaryData("steps", steps,"steps_unit", "Activity"); }
if (minAltitude != 100000) {
addSummaryData("minAltitude", minAltitude, "meters", "Elevation");
}
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");
addSummaryData("maxSpeed", maxSpeed, "meters_second", "Speed"); addSummaryData("maxSpeed", maxSpeed, "meters_second", "Speed");