mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-27 02:55:50 +01:00
Garmin: Parse fit monitoring info
This commit is contained in:
parent
49750e31af
commit
1745c41da8
@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.baseTypes.BaseType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionAlarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionArray;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionCoordinate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionDayOfWeek;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionFileType;
|
||||
@ -26,6 +27,8 @@ public class FieldDefinitionFactory {
|
||||
switch (field) {
|
||||
case ALARM:
|
||||
return new FieldDefinitionAlarm(localNumber, size, baseType, name);
|
||||
case ARRAY:
|
||||
return new FieldDefinitionArray(localNumber, size, baseType, name, scale, offset);
|
||||
case DAY_OF_WEEK:
|
||||
return new FieldDefinitionDayOfWeek(localNumber, size, baseType, name);
|
||||
case FILE_TYPE:
|
||||
@ -63,6 +66,7 @@ public class FieldDefinitionFactory {
|
||||
|
||||
public enum FIELD {
|
||||
ALARM,
|
||||
ARRAY,
|
||||
DAY_OF_WEEK,
|
||||
FILE_TYPE,
|
||||
GOAL_SOURCE,
|
||||
|
@ -177,6 +177,15 @@ public class GlobalFITMessage {
|
||||
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
|
||||
));
|
||||
|
||||
public static GlobalFITMessage MONITORING_INFO = new GlobalFITMessage(103, "MONITORING_INFO", Arrays.asList(
|
||||
new FieldDefinitionPrimitive(0, BaseType.UINT32, "timestamp_in_tz"), // garmin timestamp, but in user timezone
|
||||
new FieldDefinitionPrimitive(1, BaseType.ENUM, "activity_type", FieldDefinitionFactory.FIELD.ARRAY), // 6 walking, 1 running, 13 ?
|
||||
new FieldDefinitionPrimitive(3, BaseType.UINT16, "steps_to_distance", FieldDefinitionFactory.FIELD.ARRAY, 5000, 0), // same size as activity_type?
|
||||
new FieldDefinitionPrimitive(4, BaseType.UINT16, "steps_to_calories", FieldDefinitionFactory.FIELD.ARRAY, 5000, 0), // same size as activity_type?
|
||||
new FieldDefinitionPrimitive(5, BaseType.UINT16, "resting_metabolic_rate"), // kcal/day
|
||||
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
|
||||
));
|
||||
|
||||
public static GlobalFITMessage CONNECTIVITY = new GlobalFITMessage(127, "CONNECTIVITY", Arrays.asList(
|
||||
new FieldDefinitionPrimitive(0, BaseType.ENUM, "bluetooth_enabled"),
|
||||
new FieldDefinitionPrimitive(3, BaseType.STRING, 20, "name"),
|
||||
@ -342,6 +351,7 @@ public class GlobalFITMessage {
|
||||
put(31, COURSE);
|
||||
put(49, FILE_CREATOR);
|
||||
put(55, MONITORING);
|
||||
put(103, MONITORING_INFO);
|
||||
put(127, CONNECTIVITY);
|
||||
put(128, WEATHER);
|
||||
put(140, PHYSIOLOGICAL_METRICS);
|
||||
@ -458,6 +468,10 @@ public class GlobalFITMessage {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public FieldDefinitionPrimitive(int number, BaseType baseType, String name, FieldDefinitionFactory.FIELD type, int scale, int offset) {
|
||||
this(number, baseType, baseType.getSize(), name, type, scale, offset);
|
||||
}
|
||||
|
||||
public FieldDefinitionPrimitive(int number, BaseType baseType, String name, FieldDefinitionFactory.FIELD type) {
|
||||
this(number, baseType, baseType.getSize(), name, type, 1, 0);
|
||||
}
|
||||
|
@ -240,6 +240,8 @@ public class FitCodeGen {
|
||||
switch (primitive.getType()) {
|
||||
case ALARM:
|
||||
return Calendar.class;
|
||||
case ARRAY:
|
||||
return Number[].class;
|
||||
case DAY_OF_WEEK:
|
||||
return DayOfWeek.class;
|
||||
case FILE_TYPE:
|
||||
|
@ -0,0 +1,10 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.FieldDefinition;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.baseTypes.BaseType;
|
||||
|
||||
public class FieldDefinitionArray extends FieldDefinition {
|
||||
public FieldDefinitionArray(final int localNumber, final int size, final BaseType baseType, final String name, int scale, int offset) {
|
||||
super(localNumber, size, baseType, name, scale, offset);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDefinition;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader;
|
||||
|
||||
//
|
||||
// WARNING: This class was auto-generated, please avoid modifying it directly.
|
||||
// See nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.codegen.FitCodeGen
|
||||
//
|
||||
public class FitMonitoringInfo extends RecordData {
|
||||
public FitMonitoringInfo(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
|
||||
super(recordDefinition, recordHeader);
|
||||
|
||||
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
|
||||
if (globalNumber != 103) {
|
||||
throw new IllegalArgumentException("FitMonitoringInfo expects global messages of " + 103 + ", got " + globalNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getTimestampInTz() {
|
||||
return (Long) getFieldByNumber(0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Number[] getActivityType() {
|
||||
final Object[] objectsArray = (Object[]) getFieldByNumber(1);
|
||||
final Number[] ret = new Number[objectsArray.length];
|
||||
for (int i = 0; i < objectsArray.length; i++) {
|
||||
ret[i] = (Number) objectsArray[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Number[] getStepsToDistance() {
|
||||
final Object[] objectsArray = (Object[]) getFieldByNumber(3);
|
||||
final Number[] ret = new Number[objectsArray.length];
|
||||
for (int i = 0; i < objectsArray.length; i++) {
|
||||
ret[i] = (Number) objectsArray[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Number[] getStepsToCalories() {
|
||||
final Object[] objectsArray = (Object[]) getFieldByNumber(4);
|
||||
final Number[] ret = new Number[objectsArray.length];
|
||||
for (int i = 0; i < objectsArray.length; i++) {
|
||||
ret[i] = (Number) objectsArray[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getRestingMetabolicRate() {
|
||||
return (Integer) getFieldByNumber(5);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getTimestamp() {
|
||||
return (Long) getFieldByNumber(253);
|
||||
}
|
||||
}
|
@ -43,6 +43,8 @@ public class FitRecordDataFactory {
|
||||
return new FitFileCreator(recordDefinition, recordHeader);
|
||||
case 55:
|
||||
return new FitMonitoring(recordDefinition, recordHeader);
|
||||
case 103:
|
||||
return new FitMonitoringInfo(recordDefinition, recordHeader);
|
||||
case 127:
|
||||
return new FitConnectivity(recordDefinition, recordHeader);
|
||||
case 128:
|
||||
|
Loading…
Reference in New Issue
Block a user