mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
Mi Band 2/ Bip: Do not send user info if not set up
This commit is contained in:
parent
717eb6ba58
commit
e28085e6af
@ -373,15 +373,26 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
*/
|
||||
|
||||
private MiBand2Support setUserInfo(TransactionBuilder transaction) {
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_8_USER_SETTINGS);
|
||||
if (characteristic == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
LOG.info("Attempting to set user info...");
|
||||
Prefs prefs = GBApplication.getPrefs();
|
||||
String alias = prefs.getString(MiBandConst.PREF_USER_ALIAS, null);
|
||||
LOG.info("Attempting to set user info...");
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_8_USER_SETTINGS);
|
||||
if (characteristic != null && alias != null) {
|
||||
ActivityUser activityUser = new ActivityUser();
|
||||
int height = activityUser.getHeightCm();
|
||||
int weight = activityUser.getWeightKg();
|
||||
int birth_year = activityUser.getYearOfBirth();
|
||||
byte birth_month = 7; // not in user attributes
|
||||
byte birth_day = 1; // not in user attributes
|
||||
|
||||
if (alias == null || weight == 0 || height == 0 || birth_year == 0) {
|
||||
LOG.warn("Unable to set user info, make sure it is set up");
|
||||
return this;
|
||||
}
|
||||
|
||||
byte sex = 2; // other
|
||||
switch (activityUser.getGender()) {
|
||||
case ActivityUser.GENDER_MALE:
|
||||
@ -390,8 +401,6 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
case ActivityUser.GENDER_FEMALE:
|
||||
sex = 1;
|
||||
}
|
||||
int height = activityUser.getHeightCm();
|
||||
int weight = activityUser.getWeightKg();
|
||||
int userid = alias.hashCode(); // hash from alias like mi1
|
||||
|
||||
// FIXME: Do encoding like in PebbleProtocol, this is ugly
|
||||
@ -415,9 +424,6 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
};
|
||||
|
||||
transaction.write(characteristic, bytes);
|
||||
} else {
|
||||
LOG.warn("Unable to set user info");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user