1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-01 19:06:06 +02:00

Garmin: Map more global fit messages

* Events
* Goals
* Gps Metadata
* Laps
* Record
* Respiration rate
* Sessions
* SpO2
* Time in Zone
This commit is contained in:
José Rebelo 2024-05-01 22:16:02 +01:00
parent 2e68d9f12a
commit 11850f819f
28 changed files with 556 additions and 52 deletions

View File

@ -21,6 +21,7 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(6, BaseType.UINT16, "manufacturer_partner"),
new FieldDefinitionPrimitive(8, BaseType.STRING, 20, "product_name")
));
public static GlobalFITMessage DEVICE_SETTINGS = new GlobalFITMessage(2, "DEVICE_SETTINGS", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT8, "active_time_zone"),
new FieldDefinitionPrimitive(1, BaseType.UINT32, "utc_offset"),
@ -39,6 +40,7 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(86, BaseType.ENUM, "ble_auto_upload_enabled"),
new FieldDefinitionPrimitive(90, BaseType.UINT32, "auto_activity_detect")
));
public static GlobalFITMessage USER_PROFILE = new GlobalFITMessage(3, "USER_PROFILE", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.STRING, 8, "friendly_name"),
new FieldDefinitionPrimitive(1, BaseType.ENUM, "gender"),
@ -64,6 +66,7 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(31, BaseType.UINT16, "user_running_step_length"),
new FieldDefinitionPrimitive(32, BaseType.UINT16, "user_walking_step_length")
));
public static GlobalFITMessage ZONES_TARGET = new GlobalFITMessage(7, "ZONES_TARGET", Arrays.asList(
new FieldDefinitionPrimitive(3, BaseType.UINT16, "functional_threshold_power"),
new FieldDefinitionPrimitive(1, BaseType.UINT8, "max_heart_rate"),
@ -71,6 +74,7 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(5, BaseType.ENUM, "hr_calc_type"), //1=percent_max_hr
new FieldDefinitionPrimitive(7, BaseType.ENUM, "pwr_calc_type") //1=percent_ftp
));
public static GlobalFITMessage SPORT = new GlobalFITMessage(12, "SPORT", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.ENUM, "sport"),
new FieldDefinitionPrimitive(1, BaseType.ENUM, "sub_sport"),
@ -83,10 +87,46 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(11, BaseType.ENUM, "source", FieldDefinitionFactory.FIELD.GOAL_SOURCE)
));
public static GlobalFITMessage RECORD = new GlobalFITMessage(20, "RECORD", Arrays.asList(
new FieldDefinitionPrimitive(3, BaseType.UINT8, "heart_rate"),
public static GlobalFITMessage SESSION = new GlobalFITMessage(18, "SESSION", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.ENUM, "event"), // 9 lap
new FieldDefinitionPrimitive(1, BaseType.ENUM, "event_type"), // 1 stop
new FieldDefinitionPrimitive(2, BaseType.UINT32, "start_time"),
new FieldDefinitionPrimitive(3, BaseType.SINT32, "start_latitude"),
new FieldDefinitionPrimitive(4, BaseType.SINT32, "start_longitude"),
new FieldDefinitionPrimitive(7, BaseType.UINT32, "total_elapsed_time"), // with pauses
new FieldDefinitionPrimitive(8, BaseType.UINT32, "total_timer_time"), // no pauses
new FieldDefinitionPrimitive(9, BaseType.UINT32, "total_distance"),
new FieldDefinitionPrimitive(11, BaseType.UINT16, "total_calories"),
new FieldDefinitionPrimitive(22, BaseType.UINT16, "total_ascent"),
new FieldDefinitionPrimitive(23, BaseType.UINT16, "total_descent"),
new FieldDefinitionPrimitive(110, BaseType.STRING, 64, "sport_profile_name"),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage LAP = new GlobalFITMessage(19, "LAP", Arrays.asList(
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage RECORD = new GlobalFITMessage(20, "RECORD", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.SINT32, "latitude"),
new FieldDefinitionPrimitive(1, BaseType.SINT32, "longitude"),
new FieldDefinitionPrimitive(3, BaseType.UINT8, "heart_rate"),
new FieldDefinitionPrimitive(5, BaseType.UINT32, "distance"), // cm
new FieldDefinitionPrimitive(73, BaseType.UINT32, "enhanced_speed"), // mm/s
new FieldDefinitionPrimitive(78, BaseType.UINT32, "enhanced_altitude"), // dm
new FieldDefinitionPrimitive(136, BaseType.UINT8, "wrist_heart_rate"),
new FieldDefinitionPrimitive(143, BaseType.UINT8, "body_battery"),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage EVENT = new GlobalFITMessage(21, "EVENT", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.ENUM, "event"), // 0 timer, 74 sleep
new FieldDefinitionPrimitive(1, BaseType.ENUM, "event_type"), // sleep: 0 start 1 stop, timer: 0 start 4 stop all
new FieldDefinitionPrimitive(3, BaseType.UINT32, "data"), // in sleep they're timestamps in garmin epoch? in timer, 0 for manual
new FieldDefinitionPrimitive(4, BaseType.UINT8, "event_group"), // 0?
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage DEVICE_INFO = new GlobalFITMessage(23, "DEVICE_INFO", Arrays.asList(
new FieldDefinitionPrimitive(2, BaseType.UINT16, "manufacturer"),
new FieldDefinitionPrimitive(3, BaseType.UINT32Z, "serial_number"),
@ -94,10 +134,12 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(5, BaseType.UINT16, "software_version"),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage FILE_CREATOR = new GlobalFITMessage(49, "FILE_CREATOR", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT16, "software_version"),
new FieldDefinitionPrimitive(1, BaseType.UINT8, "hardware_version")
));
public static GlobalFITMessage MONITORING = new GlobalFITMessage(55, "MONITORING", Arrays.asList(
new FieldDefinitionPrimitive(2, BaseType.UINT32, "distance"),
new FieldDefinitionPrimitive(3, BaseType.UINT32, "cycles"),
@ -110,6 +152,7 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(27, BaseType.UINT8, "heart_rate"),
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"),
@ -143,11 +186,17 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(17, BaseType.ENUM, "air_quality"),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage WATCHFACE_SETTINGS = new GlobalFITMessage(159, "WATCHFACE_SETTINGS", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.ENUM, "mode"), //1=analog
new FieldDefinitionPrimitive(1, BaseType.BASE_TYPE_BYTE, "layout")
));
public static GlobalFITMessage GPS_METADATA = new GlobalFITMessage(160, "GPS_METADATA", Arrays.asList(
new FieldDefinitionPrimitive(3, BaseType.UINT32, "enhanced_altitude"),
new FieldDefinitionPrimitive(4, BaseType.UINT32, "enhanced_speed")
));
public static GlobalFITMessage FIELD_DESCRIPTION = new GlobalFITMessage(206, "FIELD_DESCRIPTION", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT8, "developer_data_index"),
new FieldDefinitionPrimitive(1, BaseType.UINT8, "field_definition_number"),
@ -155,23 +204,50 @@ public class GlobalFITMessage {
new FieldDefinitionPrimitive(3, BaseType.STRING, 64, "field_name"),
new FieldDefinitionPrimitive(8, BaseType.STRING, 16, "units")
));
public static GlobalFITMessage DEVELOPER_DATA = new GlobalFITMessage(207, "DEVELOPER_DATA", Arrays.asList(
new FieldDefinitionPrimitive(1, BaseType.BASE_TYPE_BYTE, 16, "application_id"),
new FieldDefinitionPrimitive(3, BaseType.UINT8, "developer_data_index")
));
// UNK_216(216, null), //activity
public static GlobalFITMessage TIME_IN_ZONE = new GlobalFITMessage(216, "TIME_IN_ZONE", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT16, "reference_message"),
new FieldDefinitionPrimitive(1, BaseType.UINT16, "reference_index"),
new FieldDefinitionPrimitive(2, BaseType.UINT32, "time_in_zone"), // seconds
new FieldDefinitionPrimitive(6, BaseType.UINT8, "hr_zone_high_boundary"), // bpm
new FieldDefinitionPrimitive(10, BaseType.ENUM, "hr_calc_type"), // 1 percent max hr
new FieldDefinitionPrimitive(11, BaseType.UINT8, "max_heart_rate"),
new FieldDefinitionPrimitive(12, BaseType.UINT8, "resting_heart_rate"),
new FieldDefinitionPrimitive(13, BaseType.UINT8, "threshold_heart_rate"),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage ALARM_SETTINGS = new GlobalFITMessage(222, "ALARM_SETTINGS", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT16, "time", FieldDefinitionFactory.FIELD.ALARM)
));
public static GlobalFITMessage STRESS_LEVEL = new GlobalFITMessage(227, "STRESS_LEVEL", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.SINT16, "stress_level_value"),
new FieldDefinitionPrimitive(1, BaseType.UINT32, "stress_level_time", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage SPO2 = new GlobalFITMessage(269, "SPO2", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.UINT8, "reading_spo2"),
new FieldDefinitionPrimitive(1, BaseType.UINT8, "reading_confidence"),
new FieldDefinitionPrimitive(2, BaseType.UINT8, "mode"), // 3 periodic
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage SLEEP_STAGE = new GlobalFITMessage(275, "SLEEP_STAGE", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.ENUM, "sleep_stage", FieldDefinitionFactory.FIELD.SLEEP_STAGE),
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage RESPIRATION_RATE = new GlobalFITMessage(297, "RESPIRATION_RATE", Arrays.asList(
new FieldDefinitionPrimitive(0, BaseType.SINT16, "respiration_rate"), // breaths / min, scaled by 100
new FieldDefinitionPrimitive(253, BaseType.UINT32, "timestamp", FieldDefinitionFactory.FIELD.TIMESTAMP)
));
public static GlobalFITMessage SLEEP_STATS = new GlobalFITMessage(346, "SLEEP_STATS", Arrays.asList(
));
@ -182,18 +258,25 @@ public class GlobalFITMessage {
put(7, ZONES_TARGET);
put(12, SPORT);
put(15, GOALS);
put(18, SESSION);
put(19, LAP);
put(20, RECORD);
put(21, EVENT);
put(23, DEVICE_INFO);
put(49, FILE_CREATOR);
put(55, MONITORING);
put(127, CONNECTIVITY);
put(128, WEATHER);
put(159, WATCHFACE_SETTINGS);
put(160, GPS_METADATA);
put(206, FIELD_DESCRIPTION);
put(207, DEVELOPER_DATA);
put(216, TIME_IN_ZONE);
put(222, ALARM_SETTINGS);
put(227, STRESS_LEVEL);
put(269, SPO2);
put(275, SLEEP_STAGE);
put(297, RESPIRATION_RATE);
put(346, SLEEP_STATS);
}};
private final int number;
@ -237,32 +320,21 @@ public class GlobalFITMessage {
for (FieldDefinitionPrimitive fieldDefinitionPrimitive :
fieldDefinitionPrimitives) {
if (fieldDefinitionPrimitive.number == id) {
subset.add(FieldDefinitionFactory.create(fieldDefinitionPrimitive.number, fieldDefinitionPrimitive.size, fieldDefinitionPrimitive.type, fieldDefinitionPrimitive.baseType, fieldDefinitionPrimitive.name, fieldDefinitionPrimitive.scale, fieldDefinitionPrimitive.offset));
subset.add(FieldDefinitionFactory.create(
fieldDefinitionPrimitive.number,
fieldDefinitionPrimitive.size,
fieldDefinitionPrimitive.type,
fieldDefinitionPrimitive.baseType,
fieldDefinitionPrimitive.name,
fieldDefinitionPrimitive.scale,
fieldDefinitionPrimitive.offset
));
}
}
}
return subset;
}
@Nullable
public FieldDefinition getFieldDefinition(String name) {
for (FieldDefinitionPrimitive fieldDefinitionPrimitive :
fieldDefinitionPrimitives) {
if (fieldDefinitionPrimitive.name.equals(name)) {
return FieldDefinitionFactory.create(
fieldDefinitionPrimitive.number,
fieldDefinitionPrimitive.size,
fieldDefinitionPrimitive.type,
fieldDefinitionPrimitive.baseType,
fieldDefinitionPrimitive.name,
fieldDefinitionPrimitive.scale,
fieldDefinitionPrimitive.offset
);
}
}
return null;
}
@Nullable
public FieldDefinition getFieldDefinition(int id, int size) {
if (null == fieldDefinitionPrimitives)
@ -270,7 +342,15 @@ public class GlobalFITMessage {
for (GlobalFITMessage.FieldDefinitionPrimitive fieldDefinitionPrimitive :
fieldDefinitionPrimitives) {
if (fieldDefinitionPrimitive.number == id) {
return FieldDefinitionFactory.create(fieldDefinitionPrimitive.number, size, fieldDefinitionPrimitive.type, fieldDefinitionPrimitive.baseType, fieldDefinitionPrimitive.name, fieldDefinitionPrimitive.scale, fieldDefinitionPrimitive.offset);
return FieldDefinitionFactory.create(
fieldDefinitionPrimitive.number,
size,
fieldDefinitionPrimitive.type,
fieldDefinitionPrimitive.baseType,
fieldDefinitionPrimitive.name,
fieldDefinitionPrimitive.scale,
fieldDefinitionPrimitive.offset
);
}
}
return null;

View File

@ -16,8 +16,12 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.GlobalFITMessage;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData;
@ -97,9 +101,12 @@ public class FitCodeGen {
imports.add(RecordDefinition.class.getCanonicalName());
imports.add(RecordHeader.class.getCanonicalName());
//imports.add(GBToStringBuilder.class.getCanonicalName());
imports.addAll(getImports(outputFile));
Collections.sort(imports);
final Set<String> uniqueImports =new LinkedHashSet<>(imports);
for (final GlobalFITMessage.FieldDefinitionPrimitive primitive : globalFITMessage.getFieldDefinitionPrimitives()) {
final Class<?> fieldType = getFieldType(primitive);
if (!Objects.requireNonNull(fieldType.getCanonicalName()).startsWith("java.lang")) {
@ -119,7 +126,7 @@ public class FitCodeGen {
sb.append("\n");
boolean anyImport = false;
for (final String i : imports) {
for (final String i : uniqueImports) {
if (i.startsWith("androidx")) {
sb.append("import ").append(i).append(";\n");
anyImport = true;
@ -130,7 +137,7 @@ public class FitCodeGen {
sb.append("\n");
anyImport = false;
}
for (final String i : imports) {
for (final String i : uniqueImports) {
if (i.startsWith("nodomain.freeyourgadget")) {
sb.append("import ").append(i).append(";\n");
anyImport = true;
@ -141,7 +148,7 @@ public class FitCodeGen {
sb.append("\n");
anyImport = false;
}
for (final String i : imports) {
for (final String i : uniqueImports) {
if (!i.startsWith("androidx") && !i.startsWith("nodomain.freeyourgadget")) {
sb.append("import ").append(i).append(";\n");
anyImport = true;
@ -161,7 +168,7 @@ public class FitCodeGen {
sb.append("\n");
sb.append(" final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();\n");
sb.append(" if (globalNumber != ").append(globalFITMessage.getNumber()).append(") {\n");
sb.append(" throw new IllegalArgumentException(\"FitFileId expects global messages of \" + ").append(globalFITMessage.getNumber()).append(" + \", got \" + globalNumber);\n");
sb.append(" throw new IllegalArgumentException(\"").append(className).append(" expects global messages of \" + ").append(globalFITMessage.getNumber()).append(" + \", got \" + globalNumber);\n");
sb.append(" }\n");
sb.append(" }\n");
@ -294,4 +301,20 @@ public class FitCodeGen {
return "";
}
public List<String> getImports(final File file) throws IOException {
if (file.exists()) {
final String fileContents = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
final List<String> imports = new ArrayList<>();
final Matcher m = Pattern.compile("import (.+);")
.matcher(fileContents);
while (m.find()) {
imports.add(m.group(1));
}
return imports;
}
return Collections.emptyList();
}
}

View File

@ -18,7 +18,7 @@ public class FitAlarmSettings extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 222) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 222 + ", got " + globalNumber);
throw new IllegalArgumentException("FitAlarmSettings expects global messages of " + 222 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitConnectivity extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 127) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 127 + ", got " + globalNumber);
throw new IllegalArgumentException("FitConnectivity expects global messages of " + 127 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitDeveloperData extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 207) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 207 + ", got " + globalNumber);
throw new IllegalArgumentException("FitDeveloperData expects global messages of " + 207 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitDeviceInfo extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 23) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 23 + ", got " + globalNumber);
throw new IllegalArgumentException("FitDeviceInfo expects global messages of " + 23 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitDeviceSettings extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 2) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 2 + ", got " + globalNumber);
throw new IllegalArgumentException("FitDeviceSettings expects global messages of " + 2 + ", got " + globalNumber);
}
}

View File

@ -0,0 +1,47 @@
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 FitEvent extends RecordData {
public FitEvent(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 21) {
throw new IllegalArgumentException("FitEvent expects global messages of " + 21 + ", got " + globalNumber);
}
}
@Nullable
public Integer getEvent() {
return (Integer) getFieldByNumber(0);
}
@Nullable
public Integer getEventType() {
return (Integer) getFieldByNumber(1);
}
@Nullable
public Long getData() {
return (Long) getFieldByNumber(3);
}
@Nullable
public Integer getEventGroup() {
return (Integer) getFieldByNumber(4);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -16,7 +16,7 @@ public class FitFieldDescription extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 206) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 206 + ", got " + globalNumber);
throw new IllegalArgumentException("FitFieldDescription expects global messages of " + 206 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitFileCreator extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 49) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 49 + ", got " + globalNumber);
throw new IllegalArgumentException("FitFileCreator expects global messages of " + 49 + ", got " + globalNumber);
}
}

View File

@ -5,8 +5,8 @@ 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;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionGoalType.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionGoalSource.Source;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionGoalType.Type;
//
// WARNING: This class was auto-generated, please avoid modifying it directly.
@ -18,7 +18,7 @@ public class FitGoals extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 15) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 15 + ", got " + globalNumber);
throw new IllegalArgumentException("FitGoals expects global messages of " + 15 + ", got " + globalNumber);
}
}

View File

@ -0,0 +1,32 @@
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 FitGpsMetadata extends RecordData {
public FitGpsMetadata(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 160) {
throw new IllegalArgumentException("FitGpsMetadata expects global messages of " + 160 + ", got " + globalNumber);
}
}
@Nullable
public Long getEnhancedAltitude() {
return (Long) getFieldByNumber(3);
}
@Nullable
public Long getEnhancedSpeed() {
return (Long) getFieldByNumber(4);
}
}

View File

@ -0,0 +1,27 @@
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 FitLap extends RecordData {
public FitLap(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 19) {
throw new IllegalArgumentException("FitLap expects global messages of " + 19 + ", got " + globalNumber);
}
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -16,7 +16,7 @@ public class FitMonitoring extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 55) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 55 + ", got " + globalNumber);
throw new IllegalArgumentException("FitMonitoring expects global messages of " + 55 + ", got " + globalNumber);
}
}
@ -81,4 +81,27 @@ public class FitMonitoring extends RecordData {
}
return computedTimestamp;
}
public Integer getComputedActivityType() {
final Integer activityType = getActivityType();
if (activityType != null) {
return activityType;
}
final Integer currentActivityTypeIntensity = getCurrentActivityTypeIntensity();
if (currentActivityTypeIntensity != null) {
return currentActivityTypeIntensity & 0x1F;
}
return null;
}
public Integer getComputedIntensity() {
final Integer currentActivityTypeIntensity = getCurrentActivityTypeIntensity();
if (currentActivityTypeIntensity != null) {
return (currentActivityTypeIntensity >> 5) & 0x7;
}
return null;
}
}

View File

@ -16,15 +16,50 @@ public class FitRecord extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 20) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 20 + ", got " + globalNumber);
throw new IllegalArgumentException("FitRecord expects global messages of " + 20 + ", got " + globalNumber);
}
}
@Nullable
public Long getLatitude() {
return (Long) getFieldByNumber(0);
}
@Nullable
public Long getLongitude() {
return (Long) getFieldByNumber(1);
}
@Nullable
public Integer getHeartRate() {
return (Integer) getFieldByNumber(3);
}
@Nullable
public Long getDistance() {
return (Long) getFieldByNumber(5);
}
@Nullable
public Long getEnhancedSpeed() {
return (Long) getFieldByNumber(73);
}
@Nullable
public Long getEnhancedAltitude() {
return (Long) getFieldByNumber(78);
}
@Nullable
public Integer getWristHeartRate() {
return (Integer) getFieldByNumber(136);
}
@Nullable
public Integer getBodyBattery() {
return (Integer) getFieldByNumber(143);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);

View File

@ -27,8 +27,14 @@ public class FitRecordDataFactory {
return new FitSport(recordDefinition, recordHeader);
case 15:
return new FitGoals(recordDefinition, recordHeader);
case 18:
return new FitSession(recordDefinition, recordHeader);
case 19:
return new FitLap(recordDefinition, recordHeader);
case 20:
return new FitRecord(recordDefinition, recordHeader);
case 21:
return new FitEvent(recordDefinition, recordHeader);
case 23:
return new FitDeviceInfo(recordDefinition, recordHeader);
case 49:
@ -41,16 +47,24 @@ public class FitRecordDataFactory {
return new FitWeather(recordDefinition, recordHeader);
case 159:
return new FitWatchfaceSettings(recordDefinition, recordHeader);
case 160:
return new FitGpsMetadata(recordDefinition, recordHeader);
case 206:
return new FitFieldDescription(recordDefinition, recordHeader);
case 207:
return new FitDeveloperData(recordDefinition, recordHeader);
case 216:
return new FitTimeInZone(recordDefinition, recordHeader);
case 222:
return new FitAlarmSettings(recordDefinition, recordHeader);
case 227:
return new FitStressLevel(recordDefinition, recordHeader);
case 269:
return new FitSpo2(recordDefinition, recordHeader);
case 275:
return new FitSleepStage(recordDefinition, recordHeader);
case 297:
return new FitRespirationRate(recordDefinition, recordHeader);
case 346:
return new FitSleepStats(recordDefinition, recordHeader);
}

View File

@ -0,0 +1,32 @@
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 FitRespirationRate extends RecordData {
public FitRespirationRate(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 297) {
throw new IllegalArgumentException("FitRespirationRate expects global messages of " + 297 + ", got " + globalNumber);
}
}
@Nullable
public Integer getRespirationRate() {
return (Integer) getFieldByNumber(0);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -0,0 +1,87 @@
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 FitSession extends RecordData {
public FitSession(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 18) {
throw new IllegalArgumentException("FitSession expects global messages of " + 18 + ", got " + globalNumber);
}
}
@Nullable
public Integer getEvent() {
return (Integer) getFieldByNumber(0);
}
@Nullable
public Integer getEventType() {
return (Integer) getFieldByNumber(1);
}
@Nullable
public Long getStartTime() {
return (Long) getFieldByNumber(2);
}
@Nullable
public Long getStartLatitude() {
return (Long) getFieldByNumber(3);
}
@Nullable
public Long getStartLongitude() {
return (Long) getFieldByNumber(4);
}
@Nullable
public Long getTotalElapsedTime() {
return (Long) getFieldByNumber(7);
}
@Nullable
public Long getTotalTimerTime() {
return (Long) getFieldByNumber(8);
}
@Nullable
public Long getTotalDistance() {
return (Long) getFieldByNumber(9);
}
@Nullable
public Integer getTotalCalories() {
return (Integer) getFieldByNumber(11);
}
@Nullable
public Integer getTotalAscent() {
return (Integer) getFieldByNumber(22);
}
@Nullable
public Integer getTotalDescent() {
return (Integer) getFieldByNumber(23);
}
@Nullable
public String getSportProfileName() {
return (String) getFieldByNumber(110);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -17,7 +17,7 @@ public class FitSleepStage extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 275) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 275 + ", got " + globalNumber);
throw new IllegalArgumentException("FitSleepStage expects global messages of " + 275 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitSleepStats extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 346) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 346 + ", got " + globalNumber);
throw new IllegalArgumentException("FitSleepStats expects global messages of " + 346 + ", got " + globalNumber);
}
}
}

View File

@ -0,0 +1,42 @@
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 FitSpo2 extends RecordData {
public FitSpo2(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 269) {
throw new IllegalArgumentException("FitSpo2 expects global messages of " + 269 + ", got " + globalNumber);
}
}
@Nullable
public Integer getReadingSpo2() {
return (Integer) getFieldByNumber(0);
}
@Nullable
public Integer getReadingConfidence() {
return (Integer) getFieldByNumber(1);
}
@Nullable
public Integer getMode() {
return (Integer) getFieldByNumber(2);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -16,7 +16,7 @@ public class FitSport extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 12) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 12 + ", got " + globalNumber);
throw new IllegalArgumentException("FitSport expects global messages of " + 12 + ", got " + globalNumber);
}
}

View File

@ -32,7 +32,7 @@ public class FitStressLevel extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 227) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 227 + ", got " + globalNumber);
throw new IllegalArgumentException("FitStressLevel expects global messages of " + 227 + ", got " + globalNumber);
}
}

View File

@ -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 FitTimeInZone extends RecordData {
public FitTimeInZone(final RecordDefinition recordDefinition, final RecordHeader recordHeader) {
super(recordDefinition, recordHeader);
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 216) {
throw new IllegalArgumentException("FitTimeInZone expects global messages of " + 216 + ", got " + globalNumber);
}
}
@Nullable
public Integer getReferenceMessage() {
return (Integer) getFieldByNumber(0);
}
@Nullable
public Integer getReferenceIndex() {
return (Integer) getFieldByNumber(1);
}
@Nullable
public Long getTimeInZone() {
return (Long) getFieldByNumber(2);
}
@Nullable
public Integer getHrZoneHighBoundary() {
return (Integer) getFieldByNumber(6);
}
@Nullable
public Integer getHrCalcType() {
return (Integer) getFieldByNumber(10);
}
@Nullable
public Integer getMaxHeartRate() {
return (Integer) getFieldByNumber(11);
}
@Nullable
public Integer getRestingHeartRate() {
return (Integer) getFieldByNumber(12);
}
@Nullable
public Integer getThresholdHeartRate() {
return (Integer) getFieldByNumber(13);
}
@Nullable
public Long getTimestamp() {
return (Long) getFieldByNumber(253);
}
}

View File

@ -7,11 +7,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordDef
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordHeader;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionLanguage.Language;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.fieldDefinitions.FieldDefinitionMeasurementSystem.Type;
//
// WARNING: This class was auto-generated, please avoid modifying it directly.
@ -23,7 +18,7 @@ public class FitUserProfile extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 3) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 3 + ", got " + globalNumber);
throw new IllegalArgumentException("FitUserProfile expects global messages of " + 3 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitWatchfaceSettings extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 159) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 159 + ", got " + globalNumber);
throw new IllegalArgumentException("FitWatchfaceSettings expects global messages of " + 159 + ", got " + globalNumber);
}
}

View File

@ -19,7 +19,7 @@ public class FitWeather extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 128) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 128 + ", got " + globalNumber);
throw new IllegalArgumentException("FitWeather expects global messages of " + 128 + ", got " + globalNumber);
}
}

View File

@ -16,7 +16,7 @@ public class FitZonesTarget extends RecordData {
final int globalNumber = recordDefinition.getGlobalFITMessage().getNumber();
if (globalNumber != 7) {
throw new IllegalArgumentException("FitFileId expects global messages of " + 7 + ", got " + globalNumber);
throw new IllegalArgumentException("FitZonesTarget expects global messages of " + 7 + ", got " + globalNumber);
}
}