syntax = "proto3";

option java_package = "nodomain.freeyourgadget.gadgetbridge.proto";
option java_outer_classname = "HuamiProtos";

message WorkoutSummary {
    string version = 1;
    Location location = 2;
    Type type = 3;
    Distance distance = 4;
    Steps steps = 11;
    Time time = 7;
    SwimmingData swimmingData = 9;
    Pace pace = 10;
    Altitude altitude = 13;
    HeartRate heartRate = 19;
    Calories calories = 16;
    TrainingEffect trainingEffect = 21;
    HeartRateZones heartRateZones = 22;
    Elevation elevation = 23;
}

message Location {
    // TODO 2, 3
    uint32 startTimestamp = 1; // unix epoch, seconds
    int32 baseLatitude = 5; // /6000000 -> coords
    int32 baseLongitude = 6; // /-6000000 -> coords
    int32 baseAltitude = 7; // /2 -> meters
    int32 maxLatitude = 8; // /3000000 -> coords
    int32 minLatitude = 9; // /3000000 -> coords
    int32 maxLongitude = 10; // /3000000 -> coords
    int32 minLongitude = 11; // /3000000 -> coords
}

message HeartRate {
    int32 avg = 1; // bpm
    int32 max = 2; // bpm
    int32 min = 3; // bpm
}

message Steps {
    float avgCadence = 1; // steps/sec
    float maxCadence = 2; // steps/sec
    int32 avgStride = 3; // cm
    int32 steps = 4; // count
}

message Type {
    int32 type = 1; // 1 = running, 4 = bike, 3 = walk
    int32 ai = 2; // 0 = normal, 1 = ai/automatic
}

message Distance {
    float distance = 1; // meters
}

message Time {
    int32 totalDuration = 1; // seconds
    int32 workoutDuration = 2; // seconds
    int32 pauseDuration = 3; // seconds
}

message Pace {
    float avg = 1; // val * 1000 / 60 -> min/km
    float best = 2; // val * 1000 / 60 -> min/km
}

message Altitude {
    int32 maxAltitude = 1; // /200 -> meters
    int32 minAltitude = 2; // /200 -> meters
    int32 avgAltitude = 3; // /200 -> meters
    int32 totalClimbing = 4; // cm
    int32 elevationGain = 5; // cm
    int32 elevationLoss = 6; // cm
}

message Calories {
    int32 calories = 1; // kcal
}

message HeartRateZones {
    // TODO 1, is always = 1?
    // Zones: N/A, Warm-up, Fat-burn time, Aerobic, Anaerobic, Extreme
    repeated int32 zoneMax = 2; // bpm
    repeated int32 zoneTime = 3; // seconds
}

message Elevation {
    // TODO 1, 2?
    uint32 uphillTime = 3; // sec
    uint32 downhillTime = 4; // sec
}

message TrainingEffect {
    float aerobicTrainingEffect = 4;
    float anaerobicTrainingEffect = 5;
    int32 currentWorkoutLoad = 6;
    int32 maximumOxygenUptake = 7; // ml/kg/min
}

message SwimmingData {
    uint32 style = 1; // 1: breaststroke, 2: freestyle
    uint32 laps = 2;
    uint32 strokes = 3;
    uint32 avgDps = 4; // cm
    uint32 swolf = 5;
    uint32 avgStrokeRate = 6;  // stroke/min
    uint32 maxStrokeRate = 7;  // stroke/min
    uint32 laneLength = 8;
    uint32 laneLengthUnit = 9; // 0: meter, 1: yard
}
