mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Huawei: Fixed workout data parser
This commit is contained in:
parent
d2cf281b00
commit
0e00d74913
@ -1411,7 +1411,7 @@ public class GBDaoGenerator {
|
|||||||
workoutDataSample.addByteProperty("midFootLanding").notNull();
|
workoutDataSample.addByteProperty("midFootLanding").notNull();
|
||||||
workoutDataSample.addByteProperty("backFootLanding").notNull();
|
workoutDataSample.addByteProperty("backFootLanding").notNull();
|
||||||
workoutDataSample.addByteProperty("eversionAngle").notNull();
|
workoutDataSample.addByteProperty("eversionAngle").notNull();
|
||||||
workoutDataSample.addByteProperty("swolf").notNull();
|
workoutDataSample.addShortProperty("swolf").notNull();
|
||||||
workoutDataSample.addShortProperty("strokeRate").notNull();
|
workoutDataSample.addShortProperty("strokeRate").notNull();
|
||||||
|
|
||||||
workoutDataSample.addByteArrayProperty("dataErrorHex");
|
workoutDataSample.addByteArrayProperty("dataErrorHex");
|
||||||
|
@ -276,7 +276,7 @@ public class Workout {
|
|||||||
public byte backFootLanding = -1;
|
public byte backFootLanding = -1;
|
||||||
public byte eversionAngle = -1;
|
public byte eversionAngle = -1;
|
||||||
|
|
||||||
public byte swolf = -1;
|
public short swolf = -1;
|
||||||
public short strokeRate = -1;
|
public short strokeRate = -1;
|
||||||
|
|
||||||
public short calories = -1;
|
public short calories = -1;
|
||||||
@ -313,9 +313,8 @@ public class Workout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// I'm not sure about the lengths, but we haven't gotten any complaints so they probably are fine
|
private final byte[] bitmapLengths = {1, 2, 1, 2, 2, 4, -1, 2, 2, 2};
|
||||||
private final byte[] bitmapLengths = {1, 2, 1, 2, 2, 4, -1, 2, 2, 2, 1, 1, 1, 1, 1, 1};
|
private final byte[] innerBitmapLengths = {2, 2, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2};
|
||||||
private final byte[] innerBitmapLengths = {2, 2, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1};
|
|
||||||
|
|
||||||
public short workoutNumber;
|
public short workoutNumber;
|
||||||
public short dataNumber;
|
public short dataNumber;
|
||||||
@ -332,6 +331,7 @@ public class Workout {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is to be able to easily reparse the error data, only accepts tlv bytes
|
* This is to be able to easily reparse the error data, only accepts tlv bytes
|
||||||
|
*
|
||||||
* @param rawData The TLV bytes
|
* @param rawData The TLV bytes
|
||||||
*/
|
*/
|
||||||
public Response(byte[] rawData) throws ParseException {
|
public Response(byte[] rawData) throws ParseException {
|
||||||
@ -355,7 +355,7 @@ public class Workout {
|
|||||||
innerBitmap = 0x01FF; // This seems to be the default
|
innerBitmap = 0x01FF; // This seems to be the default
|
||||||
|
|
||||||
int innerDataLength = 0;
|
int innerDataLength = 0;
|
||||||
for (byte i = 0; i < 16; i++) {
|
for (byte i = 0; i < innerBitmapLengths.length; i++) {
|
||||||
if ((innerBitmap & (1 << i)) != 0) {
|
if ((innerBitmap & (1 << i)) != 0) {
|
||||||
innerDataLength += innerBitmapLengths[i];
|
innerDataLength += innerBitmapLengths[i];
|
||||||
}
|
}
|
||||||
@ -380,7 +380,7 @@ public class Workout {
|
|||||||
|
|
||||||
// Check data lengths from bitmap
|
// Check data lengths from bitmap
|
||||||
int dataLength = 0;
|
int dataLength = 0;
|
||||||
for (byte i = 0; i < 16; i++) {
|
for (byte i = 0; i < bitmapLengths.length; i++) {
|
||||||
if ((header.bitmap & (1 << i)) != 0) {
|
if ((header.bitmap & (1 << i)) != 0) {
|
||||||
if (i == 6) {
|
if (i == 6) {
|
||||||
dataLength += innerDataLength;
|
dataLength += innerDataLength;
|
||||||
@ -398,7 +398,7 @@ public class Workout {
|
|||||||
for (short i = 0; i < header.dataCount; i++) {
|
for (short i = 0; i < header.dataCount; i++) {
|
||||||
Data data = new Data();
|
Data data = new Data();
|
||||||
data.timestamp = header.timestamp + header.interval * i;
|
data.timestamp = header.timestamp + header.interval * i;
|
||||||
for (byte j = 0; j < 16; j++) {
|
for (byte j = 0; j < bitmapLengths.length; j++) {
|
||||||
if ((header.bitmap & (1 << j)) != 0) {
|
if ((header.bitmap & (1 << j)) != 0) {
|
||||||
switch (j) {
|
switch (j) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -411,7 +411,7 @@ public class Workout {
|
|||||||
data.stepRate = buf.get();
|
data.stepRate = buf.get();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
data.swolf = buf.get();
|
data.swolf = buf.getShort();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
data.strokeRate = buf.getShort();
|
data.strokeRate = buf.getShort();
|
||||||
@ -422,7 +422,7 @@ public class Workout {
|
|||||||
case 6:
|
case 6:
|
||||||
// Inner data, parsing into data
|
// Inner data, parsing into data
|
||||||
// TODO: function for readability?
|
// TODO: function for readability?
|
||||||
for (byte k = 0; k < 16; k++) {
|
for (byte k = 0; k < innerBitmapLengths.length; k++) {
|
||||||
if ((innerBitmap & (1 << k)) != 0) {
|
if ((innerBitmap & (1 << k)) != 0) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case 0:
|
case 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user