mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-07 02:37:01 +01:00
Hexdump sports activity packets for better analysis
type 2 seems to be pause, 3 resume. type 8 and seems to be related to swimming activites
This commit is contained in:
parent
f99bc0de64
commit
b5ea3ca591
@ -33,32 +33,28 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GPSCoordinate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class HuamiActivityDetailsParser {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HuamiActivityDetailsParser.class);
|
||||
|
||||
private static final byte TYPE_GPS = 0;
|
||||
private static final byte TYPE_HR = 1;
|
||||
private static final byte TYPE_UNKNOWN2 = 2;
|
||||
private static final byte TYPE_PAUSE = 3;
|
||||
private static final byte TYPE_PAUSE = 2;
|
||||
private static final byte TYPE_RESUME = 3;
|
||||
private static final byte TYPE_SPEED4 = 4;
|
||||
private static final byte TYPE_SPEED5 = 5;
|
||||
private static final byte TYPE_GPS_SPEED6 = 6;
|
||||
private static final byte TYPE_SPEED6 = 6;
|
||||
private static final byte TYPE_SWIMMING = 8;
|
||||
|
||||
public static final BigDecimal HUAMI_TO_DECIMAL_DEGREES_DIVISOR = new BigDecimal(3000000.0);
|
||||
private final BaseActivitySummary summary;
|
||||
private static final BigDecimal HUAMI_TO_DECIMAL_DEGREES_DIVISOR = new BigDecimal(3000000.0);
|
||||
private final ActivityTrack activityTrack;
|
||||
// private final int version;
|
||||
private final Date baseDate;
|
||||
private long baseLongitude;
|
||||
private long baseLatitude;
|
||||
private int baseAltitude;
|
||||
private ActivityPoint lastActivityPoint;
|
||||
|
||||
public boolean getSkipCounterByte() {
|
||||
return skipCounterByte;
|
||||
}
|
||||
|
||||
public void setSkipCounterByte(boolean skipCounterByte) {
|
||||
this.skipCounterByte = skipCounterByte;
|
||||
}
|
||||
@ -66,10 +62,6 @@ public class HuamiActivityDetailsParser {
|
||||
private boolean skipCounterByte;
|
||||
|
||||
public HuamiActivityDetailsParser(BaseActivitySummary summary) {
|
||||
this.summary = summary;
|
||||
// this.version = version;
|
||||
// this.baseDate = baseDate;
|
||||
//
|
||||
this.baseLongitude = summary.getBaseLongitude();
|
||||
this.baseLatitude = summary.getBaseLatitude();
|
||||
this.baseAltitude = summary.getBaseAltitude();
|
||||
@ -109,21 +101,24 @@ public class HuamiActivityDetailsParser {
|
||||
case TYPE_HR:
|
||||
i += consumeHeartRate(bytes, i, totalTimeOffset);
|
||||
break;
|
||||
case TYPE_UNKNOWN2:
|
||||
i += consumeUnknown2(bytes, i);
|
||||
break;
|
||||
case TYPE_PAUSE:
|
||||
i += consumePause(bytes, i);
|
||||
break;
|
||||
case TYPE_RESUME:
|
||||
i += consumeResume(bytes, i);
|
||||
break;
|
||||
case TYPE_SPEED4:
|
||||
i += consumeSpeed4(bytes, i);
|
||||
break;
|
||||
case TYPE_SPEED5:
|
||||
i += consumeSpeed5(bytes, i);
|
||||
break;
|
||||
case TYPE_GPS_SPEED6:
|
||||
case TYPE_SPEED6:
|
||||
i += consumeSpeed6(bytes, i);
|
||||
break;
|
||||
case TYPE_SWIMMING:
|
||||
i += consumeSwimming(bytes, i);
|
||||
break;
|
||||
default:
|
||||
LOG.warn("unknown packet type" + type);
|
||||
i+=6;
|
||||
@ -213,7 +208,6 @@ public class HuamiActivityDetailsParser {
|
||||
|
||||
if (v2 == 0 && v3 == 0 && v4 == 0 && v5 == 0 && v6 == 0) {
|
||||
// new version
|
||||
// LOG.info("detected heart rate in 'new' version, where version is: " + summary.getVersion());
|
||||
LOG.info("detected heart rate in 'new' version format");
|
||||
ActivityPoint ap = getActivityPointFor(timeOffsetSeconds);
|
||||
ap.setHeartRate(v1);
|
||||
@ -270,23 +264,33 @@ public class HuamiActivityDetailsParser {
|
||||
}
|
||||
}
|
||||
|
||||
private int consumeUnknown2(byte[] bytes, int offset) {
|
||||
return 6; // just guessing...
|
||||
private int consumePause(byte[] bytes, int offset) {
|
||||
LOG.debug("got pause packet: " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
|
||||
private int consumePause(byte[] bytes, int i) {
|
||||
return 6; // just guessing...
|
||||
private int consumeResume(byte[] bytes, int offset) {
|
||||
LOG.debug("got resume package: " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
|
||||
private int consumeSpeed4(byte[] bytes, int offset) {
|
||||
LOG.debug("got packet type 4 (speed): " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
|
||||
private int consumeSpeed5(byte[] bytes, int offset) {
|
||||
LOG.debug("got packet type 5 (speed): " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
|
||||
private int consumeSpeed6(byte[] bytes, int offset) {
|
||||
LOG.debug("got packet type 6 (speed): " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
|
||||
private int consumeSwimming(byte[] bytes, int offset) {
|
||||
LOG.debug("got packet type 8 (swimming?): " + GB.hexdump(bytes, offset, 6));
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user