mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-07 02:37:01 +01:00
Mi Band 4: decode swim info (not used yet)
After swimming a lot on the sofa and desk this seems right and in line with the data displayed on the band swimming styles I got so far are breast and freestyle. Others are probably missing. Might be correct for Cor also (I don't have one)
This commit is contained in:
parent
13b078aadd
commit
d7c6fad235
@ -141,7 +141,7 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((byte) (lastPacketCounter + 1) == value[0] ) {
|
||||
if ((byte) (lastPacketCounter + 1) == value[0]) {
|
||||
lastPacketCounter++;
|
||||
bufferActivityData(value);
|
||||
} else {
|
||||
@ -154,6 +154,7 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
/**
|
||||
* Buffers the given activity summary data. If the total size is reached,
|
||||
* it is converted to an object and saved in the database.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
@Override
|
||||
@ -166,7 +167,7 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(stream.toByteArray()).order(ByteOrder.LITTLE_ENDIAN);
|
||||
// summary.setVersion(BLETypeConversions.toUnsigned(buffer.getShort()));
|
||||
short version = buffer.getShort(); // version
|
||||
LOG.debug("Got sport summary version " + version);
|
||||
LOG.debug("Got sport summary version " + version + "total bytes=" + buffer.capacity());
|
||||
int activityKind = ActivityKind.TYPE_UNKNOWN;
|
||||
try {
|
||||
int rawKind = BLETypeConversions.toUnsigned(buffer.getShort());
|
||||
@ -216,21 +217,53 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
float maxPace = buffer.getFloat(); // format?
|
||||
float totalStride = buffer.getFloat();
|
||||
|
||||
buffer.getInt(); // unknown
|
||||
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?
|
||||
int averageHR = buffer.getShort();
|
||||
int averagePaceSeconds = buffer.getShort();
|
||||
int averageStride = buffer.getShort();
|
||||
buffer.getShort(); // unknown
|
||||
if (activityKind == ActivityKind.TYPE_SWIMMING) {
|
||||
// 28 bytes
|
||||
float averageStrokeDistance = buffer.getFloat();
|
||||
float averageStrokesPerSecond = buffer.getFloat();
|
||||
float averageLapPace = buffer.getFloat();
|
||||
short strokes = buffer.getShort();
|
||||
short swolfIndex = buffer.getShort();
|
||||
byte swimStyle = buffer.get();
|
||||
byte laps = buffer.get();
|
||||
buffer.getInt(); // unknown
|
||||
buffer.getInt(); // unknown
|
||||
buffer.getShort(); // unknown
|
||||
|
||||
LOG.debug("unused data:" +
|
||||
LOG.debug("unused swim data:" +
|
||||
"\naverageStrokeDistance=" + averageStrokeDistance +
|
||||
"\naverageStrokesPerSecond=" + averageStrokesPerSecond +
|
||||
"\naverageLapPace" + averageLapPace +
|
||||
"\nstrokes=" + strokes +
|
||||
"\nswolfIndex=" + swolfIndex +
|
||||
"\nswimStyle=" + swimStyle + // 1 = breast, 2 = freestyle
|
||||
"\nlaps=" + 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?
|
||||
LOG.debug("unused non-swim data:" +
|
||||
"\nascentSeconds=" + ascentSeconds +
|
||||
"\ndescentSeconds=" + descentSeconds +
|
||||
"\nflatSeconds=" + flatSeconds +
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
short averageHR = buffer.getShort();
|
||||
short averageKMPaceSeconds = buffer.getShort();
|
||||
short averageStride = buffer.getShort();
|
||||
|
||||
LOG.debug("unused common:" +
|
||||
"\ndistanceMeters=" + distanceMeters +
|
||||
"\nascentMeters=" + ascentMeters +
|
||||
"\ndescentMeters=" + descentMeters +
|
||||
@ -247,11 +280,8 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
"\nminPace=" + minPace +
|
||||
"\nmaxPace=" + maxPace +
|
||||
"\ntotalStride=" + totalStride +
|
||||
"\nascentSeconds=" + ascentSeconds +
|
||||
"\ndescentSeconds=" + descentSeconds +
|
||||
"\nflatSeconds=" + flatSeconds +
|
||||
"\naverageHR=" + averageHR +
|
||||
"\naveragePaceSeconds=" + averagePaceSeconds +
|
||||
"\naverageKMPaceSeconds=" + averageKMPaceSeconds +
|
||||
"\naverageStride=" + averageStride +
|
||||
""
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user