1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-18 22:41:44 +02:00

Add Medisana BS430 to list of supported scales

This commit is contained in:
Ivan Vershinin
2018-12-14 10:51:05 +02:00
parent 99e3f88a4c
commit ca3c210000
3 changed files with 19 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ Install [openScale-dev-build.apk](https://github.com/oliexdev/openScale/releases
- Import or export your data from/into a CSV file
- Estimates body metrics (body fat, body water and lean body mass) based on scientic publications
- Support for multiple users
- Partial or full support for custom made Bluetooth scale, Xiaomi Mi scale v1/v2, Sanitas SBF70, Medisana BS444/BS440, Digoo DG-S038H, Yunmai Mini, Excelvan CF369BLE/CF366BLE, Yunmai SE, MGB, Exingtech Y1, Beurer BF700/BF710/BF800, Silvercrest SBF75, Runtastic Libra, Hesley (Yunchen), iHealth HS3, Easy Home 64050, Accuway, Trisa Body Analyze 4.0, Inlife (see [openScale wiki](https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale) for details)
- Partial or full support for custom made Bluetooth scale, Xiaomi Mi scale v1/v2, Sanitas SBF70, Medisana BS430/BS444/BS440, Digoo DG-S038H, Yunmai Mini, Excelvan CF369BLE/CF366BLE, Yunmai SE, MGB, Exingtech Y1, Beurer BF700/BF710/BF800, Silvercrest SBF75, Runtastic Libra, Hesley (Yunchen), iHealth HS3, Easy Home 64050, Accuway, Trisa Body Analyze 4.0, Inlife (see [openScale wiki](https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale) for details)
- Partially or full translated into Brazilian Portuguese, Catalan, Chinese (traditional), Croatian, Czech, Danish, Dutch, English, French, Galician, German, Greek, Hebrew, Italian, Japanese, Norwegian Bokmål, Polish, Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Turkish, Vietnamese
- No advertising and for free
- All data belongs to you (no cloud service)

View File

@@ -59,8 +59,14 @@ public class BluetoothFactory {
}
// BS444 || BS440
if (deviceName.startsWith("013197") || deviceName.startsWith("0202B6")) {
return new BluetoothMedisanaBS44x(context);
return new BluetoothMedisanaBS44x(context, true);
}
//BS430
if (deviceName.startsWith("0203B")) {
return new BluetoothMedisanaBS44x(context, false);
}
if (deviceName.startsWith("SWAN") || name.equals("icomon".toLowerCase(Locale.US))) {
return new BluetoothMGB(context);
}

View File

@@ -34,12 +34,16 @@ public class BluetoothMedisanaBS44x extends BluetoothCommunication {
private ScaleMeasurement btScaleMeasurement;
private boolean applyOffset;
// Scale time is in seconds since 2010-01-01
private static final long SCALE_UNIX_TIMESTAMP_OFFSET = 1262304000;
public BluetoothMedisanaBS44x(Context context) {
public BluetoothMedisanaBS44x(Context context, boolean applyOffset) {
super(context);
btScaleMeasurement = new ScaleMeasurement();
this.applyOffset = applyOffset;
}
@Override
@@ -79,7 +83,9 @@ public class BluetoothMedisanaBS44x extends BluetoothCommunication {
case 3:
// send magic number to receive weight data
long timestamp = new Date().getTime() / 1000;
timestamp -= SCALE_UNIX_TIMESTAMP_OFFSET;
if(applyOffset){
timestamp -= SCALE_UNIX_TIMESTAMP_OFFSET;
}
byte[] date = Converters.toInt32Le(timestamp);
byte[] magicBytes = new byte[] {(byte)0x02, date[0], date[1], date[2], date[3]};
@@ -117,7 +123,9 @@ public class BluetoothMedisanaBS44x extends BluetoothCommunication {
private void parseWeightData(byte[] weightData) {
float weight = Converters.fromUnsignedInt16Le(weightData, 1) / 100.0f;
long timestamp = Converters.fromUnsignedInt32Le(weightData, 5);
timestamp += SCALE_UNIX_TIMESTAMP_OFFSET;
if (applyOffset) {
timestamp += SCALE_UNIX_TIMESTAMP_OFFSET;
}
btScaleMeasurement.setDateTime(new Date(timestamp * 1000));
btScaleMeasurement.setWeight(weight);