HPlus: Refactor Sex into Gender and convert value appropriatelly
This commit is contained in:
parent
649e20ad04
commit
fed5638782
|
@ -23,8 +23,8 @@ public final class HPlusConstants {
|
|||
public static final byte UNIT_METRIC = 0;
|
||||
public static final byte UNIT_IMPERIAL = 1;
|
||||
|
||||
public static final byte SEX_MALE = 0;
|
||||
public static final byte SEX_FEMALE = 1;
|
||||
public static final byte PREF_VALUE_GENDER_MALE = 0;
|
||||
public static final byte PREF_VALUE_GENDER_FEMALE = 1;
|
||||
|
||||
public static final byte HEARTRATE_MEASURE_ON = 11;
|
||||
public static final byte HEARTRATE_MEASURE_OFF = 22;
|
||||
|
|
|
@ -177,10 +177,13 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
|
|||
return (byte) (activityUser.getAge() & 0xFF);
|
||||
}
|
||||
|
||||
public static byte getUserSex(String address) {
|
||||
public static byte getUserGender(String address) {
|
||||
ActivityUser activityUser = new ActivityUser();
|
||||
|
||||
return (byte) (activityUser.getGender() & 0xFF);
|
||||
if (activityUser.getGender() == ActivityUser.GENDER_MALE)
|
||||
return HPlusConstants.PREF_VALUE_GENDER_MALE;
|
||||
|
||||
return HPlusConstants.PREF_VALUE_GENDER_FEMALE;
|
||||
}
|
||||
|
||||
public static int getGoal(String address) {
|
||||
|
|
|
@ -143,7 +143,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
|||
private HPlusSupport syncPreferences(TransactionBuilder transaction) {
|
||||
LOG.info("Attempting to sync preferences...");
|
||||
|
||||
byte sex = HPlusCoordinator.getUserSex(getDevice().getAddress());
|
||||
byte gender = HPlusCoordinator.getUserGender(getDevice().getAddress());
|
||||
byte age = HPlusCoordinator.getUserAge(getDevice().getAddress());
|
||||
byte bodyHeight = HPlusCoordinator.getUserHeight(getDevice().getAddress());
|
||||
byte bodyWeight = HPlusCoordinator.getUserWeight(getDevice().getAddress());
|
||||
|
@ -167,8 +167,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
|||
byte timemode = HPlusCoordinator.getTimeMode((getDevice().getAddress()));
|
||||
|
||||
transaction.write(ctrlCharacteristic, new byte[]{
|
||||
HPlusConstants.COMMAND_SET_PREF_COUNTRY,
|
||||
sex,
|
||||
HPlusConstants.COMMAND_SET_PREFS,
|
||||
gender,
|
||||
age,
|
||||
bodyHeight,
|
||||
bodyWeight,
|
||||
|
@ -345,7 +345,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
|||
private HPlusSupport setSex(TransactionBuilder transaction) {
|
||||
LOG.info("Attempting to set Sex...");
|
||||
|
||||
byte value = HPlusCoordinator.getUserSex(getDevice().getAddress());
|
||||
byte value = HPlusCoordinator.getUserGender(getDevice().getAddress());
|
||||
transaction.write(ctrlCharacteristic, new byte[]{
|
||||
HPlusConstants.COMMAND_SET_PREF_SEX,
|
||||
value
|
||||
|
|
Loading…
Reference in New Issue