mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 07:21:40 +02:00
Minor cleanup
This commit is contained in:
@@ -51,11 +51,9 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
private void sendUserData(){
|
private void sendUserData(){
|
||||||
final ScaleUser selectedUser = OpenScale.getInstance().getSelectedScaleUser();
|
final ScaleUser selectedUser = OpenScale.getInstance().getSelectedScaleUser();
|
||||||
|
|
||||||
byte gender = selectedUser.getGender().isMale() ? (byte)0x01 : (byte)0xf1; // 00 - male; 01 - female
|
byte gender = selectedUser.getGender().isMale() ? (byte)0x01 : (byte)0xf1;
|
||||||
byte height = (byte)(((int)selectedUser.getBodyHeight()) & 0xff); // cm
|
byte height = (byte) selectedUser.getBodyHeight(); // cm
|
||||||
byte age = (byte)(selectedUser.getAge() & 0xff);
|
byte age = (byte) selectedUser.getAge();
|
||||||
|
|
||||||
int userId = selectedUser.getId();
|
|
||||||
|
|
||||||
Timber.d("Request Saved User Measurements ");
|
Timber.d("Request Saved User Measurements ");
|
||||||
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};
|
||||||
@@ -76,13 +74,13 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
setNotificationOn(WEIGHT_MEASUREMENT_SERVICE, WEIGHT_MEASUREMENT_CHARACTERISTIC,
|
setNotificationOn(WEIGHT_MEASUREMENT_SERVICE, WEIGHT_MEASUREMENT_CHARACTERISTIC,
|
||||||
BluetoothGattUuid.DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION);
|
BluetoothGattUuid.DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION);
|
||||||
sendUserData();
|
sendUserData();
|
||||||
gotData=0;
|
gotData = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//wait for answer
|
//wait for answer
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Finish init if everything is done
|
// Finish init if everything is done
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -107,7 +105,7 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean nextCleanUpCmd(int stateNr) {
|
protected boolean nextCleanUpCmd(int stateNr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,13 +118,13 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
parseBytes(data);
|
parseBytes(data);
|
||||||
if (measurement != null && measurement.getWeight() != 0.0 && gotData == 0) {
|
if (measurement != null && measurement.getWeight() != 0.0 && gotData == 0) {
|
||||||
Timber.d("meas: %s",measurement.toString());
|
Timber.d("meas: %s", measurement);
|
||||||
addScaleData(measurement);
|
addScaleData(measurement);
|
||||||
gotData = 1;
|
gotData = 1;
|
||||||
nextMachineStateStep();
|
nextMachineStateStep();
|
||||||
}
|
}
|
||||||
if (measurement != null && measurement.getWeight() != 0.0 && FatMus == 0x03 && gotData != 2) {
|
if (measurement != null && measurement.getWeight() != 0.0 && FatMus == 0x03 && gotData != 2) {
|
||||||
Timber.d("meas: %s",measurement.toString());
|
Timber.d("meas: %s", measurement);
|
||||||
addScaleData(measurement);
|
addScaleData(measurement);
|
||||||
gotData = 2;
|
gotData = 2;
|
||||||
}
|
}
|
||||||
@@ -137,8 +135,8 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
if (measurement == null) {
|
if (measurement == null) {
|
||||||
measurement = new ScaleMeasurement();
|
measurement = new ScaleMeasurement();
|
||||||
}
|
}
|
||||||
int type = (int)weightBytes[6] & 0xff;
|
int type = weightBytes[6] & 0xff;
|
||||||
Timber.d("type %02X",type);
|
Timber.d("type %02X", type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0xaa:
|
case 0xaa:
|
||||||
float weight = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // kg
|
float weight = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // kg
|
||||||
@@ -168,7 +166,6 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
case 0xe2:
|
case 0xe2:
|
||||||
//date
|
//date
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//measurement.setDateTime(lastWeighted);
|
//measurement.setDateTime(lastWeighted);
|
||||||
|
Reference in New Issue
Block a user