mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-03 03:46:17 +02:00
1a120bcd50
PredefinedLocalMessage are only useful for FIT messages and should not interfere with FIT files. The only impact of using the local message in fit files was in the textual output, but it was confusing. Add an explicit constructor to RecordHeader if PredefinedLocalMessage should be taken into account, and use this only in fit messages leaving the default constructor for fit files. Also adjusts the test case as textual output comparison needs to be fixed.
55 lines
1.7 KiB
Java
55 lines
1.7 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import java.nio.ByteOrder;
|
|
import java.util.List;
|
|
|
|
public enum PredefinedLocalMessage {
|
|
TODAY_WEATHER_CONDITIONS(6, GlobalFITMessage.WEATHER,
|
|
new int[]{0, 253, 9, 1, 14, 13, 2, 3, 5, 4, 6, 7, 10, 11, 8}
|
|
),
|
|
HOURLY_WEATHER_FORECAST(9, GlobalFITMessage.WEATHER,
|
|
new int[]{0, 253, 1, 2, 3, 4, 5, 7, 15, 16, 17}
|
|
),
|
|
DAILY_WEATHER_FORECAST(10, GlobalFITMessage.WEATHER,
|
|
new int[]{0, 253, 14, 13, 2, 5, 12}
|
|
);
|
|
|
|
private final int type;
|
|
private final GlobalFITMessage globalFITMessage;
|
|
private final int[] globalDefinitionIds;
|
|
|
|
PredefinedLocalMessage(int type, GlobalFITMessage globalFITMessage, int[] globalDefinitionIds) {
|
|
this.type = type;
|
|
this.globalFITMessage = globalFITMessage;
|
|
this.globalDefinitionIds = globalDefinitionIds;
|
|
}
|
|
|
|
@Nullable
|
|
public static PredefinedLocalMessage fromType(int type) {
|
|
for (final PredefinedLocalMessage predefinedLocalMessage : PredefinedLocalMessage.values()) {
|
|
if (predefinedLocalMessage.getType() == type) {
|
|
return predefinedLocalMessage;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public List<FieldDefinition> getLocalFieldDefinitions() {
|
|
return globalFITMessage.getFieldDefinitions(globalDefinitionIds);
|
|
}
|
|
|
|
public RecordDefinition getRecordDefinition() {
|
|
return new RecordDefinition(ByteOrder.BIG_ENDIAN, this);
|
|
}
|
|
|
|
public int getType() {
|
|
return type;
|
|
}
|
|
|
|
public GlobalFITMessage getGlobalFITMessage() {
|
|
return globalFITMessage;
|
|
}
|
|
}
|