diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java index 35fcc33e9..6f9e07d66 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java @@ -528,7 +528,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport { * @return */ - private HuamiSupport setFitnessGoal(TransactionBuilder transaction) { + protected HuamiSupport setFitnessGoal(TransactionBuilder transaction) { LOG.info("Attempting to set Fitness Goal..."); BluetoothGattCharacteristic characteristic = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_8_USER_SETTINGS); if (characteristic != null) { @@ -3161,7 +3161,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport { return this; } - private HuamiSupport setGoalNotification(TransactionBuilder builder) { + protected HuamiSupport setGoalNotification(TransactionBuilder builder) { boolean enable = HuamiCoordinator.getGoalNotification(gbDevice.getAddress()); LOG.info("Setting goal notification to " + enable); if (enable) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitneo/AmazfitNeoSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitneo/AmazfitNeoSupport.java index 6cc9623f4..d5dacabb0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitneo/AmazfitNeoSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitneo/AmazfitNeoSupport.java @@ -48,6 +48,32 @@ public class AmazfitNeoSupport extends MiBand5Support { return this; } + @Override + protected AmazfitNeoSupport setFitnessGoal(TransactionBuilder builder) { + LOG.info("Attempting to set Fitness Goal..."); + setNeoFitnessGoal(builder); + return this; + } + + @Override + protected AmazfitNeoSupport setGoalNotification(TransactionBuilder builder) { + LOG.info("Attempting to set goal notification..."); + setNeoFitnessGoal(builder); + return this; + } + + private void setNeoFitnessGoal(TransactionBuilder builder) { + int fitnessGoal = GBApplication.getPrefs().getInt(ActivityUser.PREF_USER_STEPS_GOAL, ActivityUser.defaultUserStepsGoal); + boolean fitnessGoalNotification = HuamiCoordinator.getGoalNotification(gbDevice.getAddress()); + LOG.info("Setting Amazfit Neo fitness goal to: " + fitnessGoal + ", notification: " + fitnessGoalNotification); + byte[] bytes = ArrayUtils.addAll( + new byte[] { 0x3a, 1, 0, 0, 0, (byte) (fitnessGoalNotification ? 1 : 0 ) }, + BLETypeConversions.fromUint16(fitnessGoal)); + bytes = ArrayUtils.addAll(bytes, + HuamiService.COMMAND_SET_FITNESS_GOAL_END); + writeToChunked(builder, 2, bytes); + } + @Override public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException { return new AmazfitNeoFWHelper(uri, context);