2022-08-18 23:03:28 +02:00
|
|
|
/* Copyright (C) 2022 José Rebelo
|
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami;
|
|
|
|
|
2022-09-18 12:04:50 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
|
|
|
|
2022-08-18 23:03:28 +02:00
|
|
|
/**
|
|
|
|
* The workout types, used to start / when workout tracking starts on the band.
|
|
|
|
*/
|
|
|
|
public enum Huami2021WorkoutTrackActivityType {
|
2022-09-18 13:19:23 +02:00
|
|
|
AerobicCombo(0x33),
|
|
|
|
Aerobics(0x6d),
|
|
|
|
AirWalker(0x90),
|
|
|
|
Archery(0x5d),
|
|
|
|
ArtisticSwimming(0x9c),
|
2022-08-18 23:03:28 +02:00
|
|
|
Badminton(0x5c),
|
2022-09-18 13:19:23 +02:00
|
|
|
Ballet(0x47),
|
|
|
|
BallroomDance(0x4b),
|
|
|
|
Baseball(0x4f),
|
|
|
|
Basketball(0x55),
|
|
|
|
BattleRope(0xa7),
|
|
|
|
BeachVolleyball(0x7a),
|
|
|
|
BellyDance(0x48),
|
|
|
|
Billiards(0x97),
|
|
|
|
bmx(0x30),
|
|
|
|
BoardGame(0xb1),
|
|
|
|
Bocce(0xaa),
|
|
|
|
Bowling(0x50),
|
|
|
|
Boxing(0x61),
|
|
|
|
Breaking(0xa8),
|
|
|
|
Bridge(0xb0),
|
|
|
|
CardioCombat(0x72),
|
|
|
|
Checkers(0xae),
|
|
|
|
Chess(0xad),
|
|
|
|
CoreTraining(0x32),
|
|
|
|
Cricket(0x4e),
|
|
|
|
CrossTraining(0x82),
|
|
|
|
Curling(0x29),
|
2022-08-18 23:03:28 +02:00
|
|
|
Dance(0x4c),
|
2022-09-18 13:19:23 +02:00
|
|
|
Darts(0x75),
|
|
|
|
Dodgeball(0x99),
|
|
|
|
DragonBoat(0x8a),
|
2022-08-18 23:03:28 +02:00
|
|
|
Elliptical(0x09),
|
2022-09-18 13:19:23 +02:00
|
|
|
Esports(0xbd),
|
|
|
|
Esquestrian(0x5e),
|
|
|
|
Fencing(0x94),
|
|
|
|
Finswimming(0x9b),
|
|
|
|
Fishing(0x40),
|
|
|
|
Flexibility(0x37),
|
|
|
|
Flowriding(0xac),
|
|
|
|
FolkDance(0x92),
|
2022-08-18 23:03:28 +02:00
|
|
|
Freestyle(0x05),
|
2022-09-18 13:19:23 +02:00
|
|
|
Frisbee(0x74),
|
|
|
|
Futsal(0xa4),
|
|
|
|
Gateball(0x57),
|
|
|
|
Gymnastics(0x3b),
|
|
|
|
HackySack(0xa9),
|
|
|
|
Handball(0x5b),
|
|
|
|
HIIT(0x31),
|
|
|
|
HipHop(0xa5),
|
|
|
|
HorizontalBar(0x95),
|
|
|
|
HulaHoop(0x73),
|
|
|
|
IceHockey(0x9e),
|
|
|
|
IceSkating(0x2c),
|
2022-08-18 23:03:28 +02:00
|
|
|
IndoorCycling(0x08),
|
|
|
|
IndoorFitness(0x18),
|
2022-09-18 13:19:23 +02:00
|
|
|
IndoorIceSkating(0x2d),
|
|
|
|
JaiAlai(0xab),
|
|
|
|
JazzDance(0x71),
|
|
|
|
Judo(0x62),
|
|
|
|
Jujitsu(0x93),
|
2022-08-18 23:03:28 +02:00
|
|
|
JumpRope(0x15),
|
2022-09-18 13:19:23 +02:00
|
|
|
Karate(0x60),
|
|
|
|
Kayaking(0x8c),
|
|
|
|
Kendo(0x5f),
|
|
|
|
Kickboxing(0x68),
|
|
|
|
KiteFlying(0x76),
|
|
|
|
LatinDance(0x70),
|
|
|
|
MartialArts(0x67),
|
|
|
|
MassGymnastics(0x6f),
|
|
|
|
ModernDance(0xb9),
|
|
|
|
MuayThai(0x65),
|
2022-08-18 23:03:28 +02:00
|
|
|
OutdoorCycling(0x04),
|
|
|
|
OutdoorRunning(0x01),
|
2022-09-18 13:19:23 +02:00
|
|
|
ParallelBars(0x96),
|
|
|
|
Parkour(0x81),
|
|
|
|
Pilates(0x3d),
|
|
|
|
PoleDance(0xa6),
|
2022-08-18 23:03:28 +02:00
|
|
|
PoolSwimming(0x06),
|
2022-09-18 13:19:23 +02:00
|
|
|
RaceWalking(0x83),
|
|
|
|
RockClimbing(0x46),
|
|
|
|
RollerSkating(0x45),
|
2022-08-18 23:03:28 +02:00
|
|
|
Rowing(0x17),
|
2022-09-18 13:19:23 +02:00
|
|
|
Sailing(0x41),
|
|
|
|
SepakTakraw(0x98),
|
|
|
|
Shuffleboard(0xa0),
|
|
|
|
Shuttlecock(0xa2),
|
|
|
|
Skateboarding(0x43),
|
|
|
|
Snorkeling(0x9d),
|
2022-08-18 23:03:28 +02:00
|
|
|
Soccer(0xbf),
|
2022-09-18 13:19:23 +02:00
|
|
|
Softball(0x56),
|
|
|
|
SomatosensoryGame(0xa3),
|
|
|
|
Spinning(0x8f),
|
|
|
|
SquareDance(0x49),
|
|
|
|
Squash(0x51),
|
|
|
|
StairClimber(0x36),
|
|
|
|
Stepper(0x39),
|
|
|
|
StreetDance(0x4a),
|
|
|
|
Strength(0x34),
|
|
|
|
Stretching(0x35),
|
|
|
|
Swinging(0x9f),
|
|
|
|
TableFootball(0xa1),
|
|
|
|
TableTennis(0x59),
|
|
|
|
TaiChi(0x64),
|
|
|
|
Taekwondo(0x66),
|
|
|
|
Tennis(0x11),
|
2022-08-18 23:03:28 +02:00
|
|
|
Treadmill(0x02),
|
2022-09-18 13:19:23 +02:00
|
|
|
TugOfWar(0x77),
|
|
|
|
Volleyball(0x58),
|
2022-08-18 23:03:28 +02:00
|
|
|
Walking(0x03),
|
2022-09-18 13:19:23 +02:00
|
|
|
WallBall(0x91),
|
|
|
|
WaterPolo(0x9a),
|
|
|
|
WaterRowing(0x42),
|
|
|
|
Weiqi(0xaf),
|
|
|
|
Wrestling(0x63),
|
2022-08-18 23:03:28 +02:00
|
|
|
Yoga(0x3c),
|
2022-09-18 13:19:23 +02:00
|
|
|
Zumba(0x4d),
|
2022-08-18 23:03:28 +02:00
|
|
|
;
|
|
|
|
|
2022-09-18 12:04:50 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(Huami2021WorkoutTrackActivityType.class);
|
|
|
|
|
2022-08-18 23:03:28 +02:00
|
|
|
private final byte code;
|
|
|
|
|
|
|
|
Huami2021WorkoutTrackActivityType(final int code) {
|
|
|
|
this.code = (byte) code;
|
|
|
|
}
|
|
|
|
|
|
|
|
public byte getCode() {
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
2022-09-18 12:04:50 +02:00
|
|
|
public int toActivityKind() {
|
|
|
|
switch (this) {
|
|
|
|
case Badminton:
|
|
|
|
return ActivityKind.TYPE_BADMINTON;
|
2022-10-23 21:46:14 +02:00
|
|
|
case Basketball:
|
|
|
|
return ActivityKind.TYPE_BASKETBALL;
|
|
|
|
case Cricket:
|
|
|
|
return ActivityKind.TYPE_CRICKET;
|
2022-09-18 12:04:50 +02:00
|
|
|
case Elliptical:
|
|
|
|
return ActivityKind.TYPE_ELLIPTICAL_TRAINER;
|
2022-09-18 13:19:23 +02:00
|
|
|
case Freestyle:
|
|
|
|
case IndoorFitness:
|
|
|
|
return ActivityKind.TYPE_EXERCISE;
|
2022-09-18 12:04:50 +02:00
|
|
|
case IndoorCycling:
|
|
|
|
return ActivityKind.TYPE_INDOOR_CYCLING;
|
|
|
|
case JumpRope:
|
|
|
|
return ActivityKind.TYPE_JUMP_ROPING;
|
|
|
|
case OutdoorCycling:
|
|
|
|
return ActivityKind.TYPE_CYCLING;
|
|
|
|
case OutdoorRunning:
|
|
|
|
return ActivityKind.TYPE_RUNNING;
|
|
|
|
case PoolSwimming:
|
|
|
|
return ActivityKind.TYPE_SWIMMING;
|
|
|
|
case Rowing:
|
|
|
|
return ActivityKind.TYPE_ROWING_MACHINE;
|
|
|
|
case Soccer:
|
|
|
|
return ActivityKind.TYPE_SOCCER;
|
|
|
|
case Treadmill:
|
|
|
|
return ActivityKind.TYPE_TREADMILL;
|
|
|
|
case Walking:
|
2022-09-18 13:19:23 +02:00
|
|
|
case RaceWalking:
|
2022-09-18 12:04:50 +02:00
|
|
|
return ActivityKind.TYPE_WALKING;
|
2022-10-23 21:46:14 +02:00
|
|
|
case Strength:
|
|
|
|
return ActivityKind.TYPE_STRENGTH_TRAINING;
|
2022-09-18 12:04:50 +02:00
|
|
|
case Yoga:
|
|
|
|
return ActivityKind.TYPE_YOGA;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.warn("Unmapped workout type {}", this);
|
|
|
|
|
|
|
|
return ActivityKind.TYPE_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2022-08-18 23:03:28 +02:00
|
|
|
public static Huami2021WorkoutTrackActivityType fromCode(final byte code) {
|
|
|
|
for (final Huami2021WorkoutTrackActivityType type : values()) {
|
|
|
|
if (type.getCode() == code) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|