mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-29 02:59:57 +02:00
catch illegal date MONTH, see #646
This commit is contained in:
@@ -202,29 +202,30 @@ public class BluetoothOneByone extends BluetoothCommunication {
|
|||||||
try {
|
try {
|
||||||
dateTime.setLenient(false);
|
dateTime.setLenient(false);
|
||||||
scaleBtData.setDateTime(dateTime.getTime());
|
scaleBtData.setDateTime(dateTime.getTime());
|
||||||
|
|
||||||
|
scaleBtData.setFat(oneByoneLib.getBodyFat(weight, impedanceCoeff));
|
||||||
|
scaleBtData.setWater(oneByoneLib.getWater(scaleBtData.getFat()));
|
||||||
|
scaleBtData.setBone(oneByoneLib.getBoneMass(weight, impedanceValue));
|
||||||
|
scaleBtData.setVisceralFat(oneByoneLib.getVisceralFat(weight));
|
||||||
|
scaleBtData.setMuscle(oneByoneLib.getMuscle(weight, scaleBtData.getFat(), scaleBtData.getBone()));
|
||||||
|
|
||||||
|
Timber.d("scale measurement [%s]", scaleBtData);
|
||||||
|
|
||||||
|
if (dateTime.getTimeInMillis() - lastDateTime.getTimeInMillis() < DATE_TIME_THRESHOLD) {
|
||||||
|
return; // don't save measurements too close to each other
|
||||||
|
}
|
||||||
|
lastDateTime = dateTime;
|
||||||
|
|
||||||
|
addScaleMeasurement(scaleBtData);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
if (historicMeasurement) {
|
if (historicMeasurement) {
|
||||||
Timber.d("invalid time-stamp: year %d, month %d, day %d, hour %d, minute %d, second %d",
|
Timber.d("invalid time-stamp: year %d, month %d, day %d, hour %d, minute %d, second %d",
|
||||||
Converters.fromUnsignedInt16Be(weightBytes, 11),
|
Converters.fromUnsignedInt16Be(weightBytes, 11),
|
||||||
weightBytes[13], weightBytes[14], weightBytes[15],
|
weightBytes[13], weightBytes[14], weightBytes[15],
|
||||||
weightBytes[16], weightBytes[17]);
|
weightBytes[16], weightBytes[17]);
|
||||||
return; // discard historic measurement with invalid time-stamp
|
return; // discard historic measurement with invalid time-stamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scaleBtData.setFat(oneByoneLib.getBodyFat(weight, impedanceCoeff));
|
|
||||||
scaleBtData.setWater(oneByoneLib.getWater(scaleBtData.getFat()));
|
|
||||||
scaleBtData.setBone(oneByoneLib.getBoneMass(weight, impedanceValue));
|
|
||||||
scaleBtData.setVisceralFat(oneByoneLib.getVisceralFat(weight));
|
|
||||||
scaleBtData.setMuscle(oneByoneLib.getMuscle(weight, scaleBtData.getFat(), scaleBtData.getBone()));
|
|
||||||
|
|
||||||
Timber.d("scale measurement [%s]", scaleBtData);
|
|
||||||
|
|
||||||
if (dateTime.getTimeInMillis() - lastDateTime.getTimeInMillis() < DATE_TIME_THRESHOLD) {
|
|
||||||
return; // don't save measurements too close to each other
|
|
||||||
}
|
|
||||||
lastDateTime = dateTime;
|
|
||||||
|
|
||||||
addScaleMeasurement(scaleBtData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user