diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java index 73515ee7f..892b8c722 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusConstants.java @@ -38,7 +38,8 @@ public final class HPlusConstants { public static final byte[] CMD_SET_PREF_START = new byte[]{0x4f, 0x5a}; public static final byte[] CMD_SET_PREF_START1 = new byte[]{0x4d}; - public static final byte CMD_SET_ALARM = 0x4c; + //public static final byte CMD_SET_ALARM = 0x4c; Unknown + public static final byte CMD_SET_ALARM = 0x0c; public static final byte CMD_SET_LANGUAGE = 0x22; public static final byte CMD_SET_TIMEMODE = 0x47; public static final byte CMD_SET_UNITS = 0x48; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java index 8495e6643..53f35e325 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/HPlusCoordinator.java @@ -138,19 +138,13 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { qb.where(HPlusHealthActivitySampleDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities(); } - public static int getFitnessGoal(String address) throws IllegalArgumentException { - ActivityUser activityUser = new ActivityUser(); - - return activityUser.getStepsGoal(); - } - public static byte getLanguage(String address) { return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_LANGUAGE + "_" + address, HPlusConstants.ARG_LANGUAGE_EN); } public static byte getTimeMode(String address) { - return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_TIMEMODE + "_" + address, 0); + return (byte) prefs.getInt(HPlusConstants.PREF_HPLUS_TIMEMODE + "_" + address, HPlusConstants.ARG_TIMEMODE_24H); } public static byte getUnit(String address) { @@ -212,14 +206,6 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator { return (byte) (prefs.getInt(HPlusConstants.PREF_HPLUS_WRIST + "_" + address, 10) & 0xFF); } - public static boolean getSWAlertTime(String address) { - return prefs.getBoolean(HPlusConstants.PREF_HPLUS_SWALERT + "_" + address, false); - } - - public static int getAlertTime(String address) { - return prefs.getInt(HPlusConstants.PREF_HPLUS_ALERT_TIME + "_" + address, 0); - } - public static int getSITStartTime(String address) { return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_START_TIME + "_" + address, 0); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/MakibesF68Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/MakibesF68Coordinator.java index 1b1abe568..63cd71915 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/MakibesF68Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/hplus/MakibesF68Coordinator.java @@ -30,4 +30,10 @@ public class MakibesF68Coordinator extends HPlusCoordinator { public DeviceType getDeviceType() { return DeviceType.MAKIBESF68; } + + @Override + public String getManufacturer() { + return "Makibes"; + } + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java index 4bf02c551..6daec55f3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/hplus/HPlusSupport.java @@ -26,6 +26,7 @@ import java.util.GregorianCalendar; import java.util.List; import java.util.UUID; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusConstants; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -109,11 +110,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { //Initialize device sendUserInfo(builder); //Sync preferences - setSIT(builder); //Sync SIT Interval - setCurrentDate(builder); // Sync Current Date - setDayOfWeek(builder); - setCurrentTime(builder); // Sync Current Time - setLanguage(builder); + requestDeviceInfo(builder); @@ -141,68 +138,18 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { private HPlusSupport syncPreferences(TransactionBuilder transaction) { if(deviceType == DeviceType.HPLUS) { - byte gender = HPlusCoordinator.getUserGender(getDevice().getAddress()); - byte age = HPlusCoordinator.getUserAge(getDevice().getAddress()); - byte bodyHeight = HPlusCoordinator.getUserHeight(getDevice().getAddress()); - byte bodyWeight = HPlusCoordinator.getUserWeight(getDevice().getAddress()); - int goal = HPlusCoordinator.getGoal(getDevice().getAddress()); - byte displayTime = HPlusCoordinator.getScreenTime(getDevice().getAddress()); - byte country = HPlusCoordinator.getLanguage(getDevice().getAddress()); - byte social = HPlusCoordinator.getSocial(getDevice().getAddress()); // ?? - byte allDayHeart = HPlusCoordinator.getAllDayHR(getDevice().getAddress()); - byte wrist = HPlusCoordinator.getUserWrist(getDevice().getAddress()); - byte alertTimeHour = 0; - byte alertTimeMinute = 0; - - if (HPlusCoordinator.getSWAlertTime(getDevice().getAddress())) { - int t = HPlusCoordinator.getAlertTime(getDevice().getAddress()); - - alertTimeHour = (byte) ((t / 256) & 0xff); - alertTimeMinute = (byte) (t % 256); - } - - byte unit = HPlusCoordinator.getUnit(getDevice().getAddress()); - byte timemode = HPlusCoordinator.getTimeMode((getDevice().getAddress())); - - transaction.write(ctrlCharacteristic, new byte[]{ - HPlusConstants.CMD_SET_PREFS, - gender, - age, - bodyHeight, - bodyWeight, - 0, - 0, - (byte) ((goal / 256) & 0xff), - (byte) (goal % 256), - displayTime, - country, - 0, - social, - allDayHeart, - wrist, - 0, - alertTimeHour, - alertTimeMinute, - unit, - timemode - }); - - }else if(deviceType == DeviceType.MAKIBESF68){ - //Makibes doesn't support setting everything at once. - - setGender(transaction); - setAge(transaction); - setWeight(transaction); - setHeight(transaction); - setGoal(transaction); - setLanguage(transaction); - setScreenTime(transaction); - //setAlarm(transaction, t); - setUnit(transaction); - setTimeMode(transaction); + setSIT(transaction); //Sync SIT Interval } - + setGender(transaction); + setAge(transaction); + setWeight(transaction); + setHeight(transaction); + setGoal(transaction); + setLanguage(transaction); + setScreenTime(transaction); + setUnit(transaction); + setTimeMode(transaction); setAllDayHeart(transaction); return this; @@ -404,12 +351,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { private HPlusSupport setAlarm(TransactionBuilder transaction, Calendar t) { transaction.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_ALARM, - (byte) (t.get(Calendar.YEAR) / 256), - (byte) (t.get(Calendar.YEAR) % 256), - (byte) (t.get(Calendar.MONTH) + 1), (byte) t.get(Calendar.HOUR_OF_DAY), - (byte) t.get(Calendar.MINUTE), - (byte) t.get(Calendar.SECOND)}); + (byte) t.get(Calendar.MINUTE)}); return this; } @@ -497,8 +440,11 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport { setAlarm(builder, t); builder.queue(getQueue()); + GB.toast(getContext(), getContext().getString(R.string.user_feedback_miband_set_alarms_ok), Toast.LENGTH_SHORT, GB.INFO); + return; //Only first alarm } + GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO); }