1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-19 06:51:57 +02:00

Fix comment and some whitespace

This commit is contained in:
Erik Johansson
2018-11-27 20:13:55 +01:00
parent 65bc1f02d9
commit 34baeb2296

View File

@@ -35,7 +35,6 @@ public class BluetoothSenssun extends BluetoothCommunication {
private final UUID WEIGHT_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff1); // read, notify private final UUID WEIGHT_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff1); // read, notify
private final UUID CMD_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff2); // write only private final UUID CMD_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff2); // write only
private boolean scaleGotUserData; private boolean scaleGotUserData;
long firstFixWeight = -1 ; long firstFixWeight = -1 ;
private byte WeightFatMus = 0; private byte WeightFatMus = 0;
@@ -52,12 +51,12 @@ public class BluetoothSenssun extends BluetoothCommunication {
@Override @Override
protected boolean doScanWhileConnecting() { protected boolean doScanWhileConnecting() {
// Medisana seems to have problem connecting if scan is running (see #278 and #353) // Senssun seems to have problem connecting if scan is running (see ##309)
return false; return false;
} }
private void sendUserData(){ private void sendUserData() {
if ( scaleGotUserData ){ if (scaleGotUserData) {
return; return;
} }
final ScaleUser selectedUser = OpenScale.getInstance().getSelectedScaleUser(); final ScaleUser selectedUser = OpenScale.getInstance().getSelectedScaleUser();
@@ -70,7 +69,7 @@ public class BluetoothSenssun extends BluetoothCommunication {
byte cmdByte[] = {(byte)0xa5, (byte)0x10, gender, age, height, (byte)0, (byte)0x0, (byte)0x0d2, (byte)0x00}; byte cmdByte[] = {(byte)0xa5, (byte)0x10, gender, age, height, (byte)0, (byte)0x0, (byte)0x0d2, (byte)0x00};
byte verify = 0; byte verify = 0;
for(int i = 1; i < cmdByte.length - 2; i++) { for (int i = 1; i < cmdByte.length - 2; i++) {
verify = (byte) (verify + cmdByte[i]); verify = (byte) (verify + cmdByte[i]);
} }
cmdByte[cmdByte.length - 2] = verify; cmdByte[cmdByte.length - 2] = verify;
@@ -113,15 +112,14 @@ public class BluetoothSenssun extends BluetoothCommunication {
// The first notification only includes weight and all other fields are // The first notification only includes weight and all other fields are
// either 0x00 (user info) or 0xff (fat, water, etc.) // either 0x00 (user info) or 0xff (fat, water, etc.)
if (data != null && !isBitSet(WeightFatMus,3) ) { //only if not saved if (data != null && !isBitSet(WeightFatMus, 3)) { //only if not saved
parseBytes(data); parseBytes(data);
Timber.d("WFM %02X %d ", WeightFatMus, ( System.currentTimeMillis() - firstFixWeight )); Timber.d("WFM %02X %d ", WeightFatMus, ( System.currentTimeMillis() - firstFixWeight ));
if ( isBitSet(WeightFatMus,2) && firstFixWeight > 0 ) { if (isBitSet(WeightFatMus, 2) && firstFixWeight > 0) {
if ( ( ( System.currentTimeMillis() - firstFixWeight ) > 2500 && WeightFatMus == (1<<2) )//wait 1.5 seconds for Data if (((System.currentTimeMillis() - firstFixWeight) > 2500 && WeightFatMus == (1 << 2)) //wait 1.5 seconds for Data
|| WeightFatMus == 0x07 ) { // got all Data to save || WeightFatMus == 0x07) { // got all Data to save
addScaleData(measurement); addScaleData(measurement);
WeightFatMus |= 1 <<3; WeightFatMus |= 1 << 3;
} }
} }
} }
@@ -135,7 +133,7 @@ public class BluetoothSenssun extends BluetoothCommunication {
Timber.d("type %02X", type); Timber.d("type %02X", type);
switch (type) { switch (type) {
case 0x00: case 0x00:
if ( weightBytes[2] == (byte)0x10 ){ if (weightBytes[2] == (byte)0x10) {
scaleGotUserData = true; scaleGotUserData = true;
} }
break; break;
@@ -146,7 +144,7 @@ public class BluetoothSenssun extends BluetoothCommunication {
float weight = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // kg float weight = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // kg
measurement.setWeight(weight); measurement.setWeight(weight);
if (!isBitSet(WeightFatMus,2)){ if (!isBitSet(WeightFatMus, 2)) {
WeightFatMus |= 1 << 2 ; WeightFatMus |= 1 << 2 ;
firstFixWeight = System.currentTimeMillis() ; firstFixWeight = System.currentTimeMillis() ;
} }