mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-02 23:12:57 +01:00
CMF Watch Pro 2: Fix workout summary parsing
This commit is contained in:
parent
b13c1b52be
commit
2e491d91a4
@ -382,19 +382,25 @@ public class CmfActivitySync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleWorkoutSummary(final byte[] payload) {
|
private void handleWorkoutSummary(final byte[] payload) {
|
||||||
if (payload.length % 32 != 0) {
|
final int bytesPerWorkout;
|
||||||
LOG.error("Workout summary payload size {} not divisible by 32", payload.length);
|
|
||||||
|
if (payload.length % 32 == 0) {
|
||||||
|
bytesPerWorkout = 32;
|
||||||
|
} else if (payload.length % 54 == 0) {
|
||||||
|
bytesPerWorkout = 54;
|
||||||
|
} else {
|
||||||
|
LOG.error("Workout summary payload size {} not divisible by 32 or 54", payload.length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Got {} workout summary samples", payload.length / 32);
|
LOG.debug("Got {} workout summary samples", payload.length / bytesPerWorkout);
|
||||||
|
|
||||||
final ByteBuffer buf = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN);
|
final ByteBuffer buf = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
final CmfWorkoutSummaryParser summaryParser = new CmfWorkoutSummaryParser(getDevice());
|
final CmfWorkoutSummaryParser summaryParser = new CmfWorkoutSummaryParser(getDevice());
|
||||||
|
|
||||||
while (buf.remaining() > 0) {
|
while (buf.remaining() > 0) {
|
||||||
final byte[] summaryBytes = new byte[32];
|
final byte[] summaryBytes = new byte[bytesPerWorkout];
|
||||||
buf.get(summaryBytes);
|
buf.get(summaryBytes);
|
||||||
|
|
||||||
BaseActivitySummary summary = new BaseActivitySummary();
|
BaseActivitySummary summary = new BaseActivitySummary();
|
||||||
|
Loading…
Reference in New Issue
Block a user