mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 14:31:23 +02:00
Whitespace fixes
This commit is contained in:
@@ -36,7 +36,7 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
private final UUID CMD_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff2); // write only
|
private final UUID CMD_MEASUREMENT_CHARACTERISTIC = BluetoothGattUuid.fromShortCode(0xfff2); // write only
|
||||||
|
|
||||||
private int gotData;
|
private int gotData;
|
||||||
private int FatMus=0;
|
private int FatMus = 0;
|
||||||
private ScaleMeasurement measurement;
|
private ScaleMeasurement measurement;
|
||||||
|
|
||||||
public BluetoothSenssun(Context context) {
|
public BluetoothSenssun(Context context) {
|
||||||
@@ -49,23 +49,23 @@ 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; // 00 - male; 01 - female
|
||||||
byte height = (byte)(((int)selectedUser.getBodyHeight()) & 0xff); // cm
|
byte height = (byte)(((int)selectedUser.getBodyHeight()) & 0xff); // cm
|
||||||
byte age = (byte)(selectedUser.getAge() & 0xff);
|
byte age = (byte)(selectedUser.getAge() & 0xff);
|
||||||
|
|
||||||
int userId = selectedUser.getId();
|
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};
|
||||||
|
|
||||||
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;
|
||||||
writeBytes(WEIGHT_MEASUREMENT_SERVICE, CMD_MEASUREMENT_CHARACTERISTIC, cmdByte);
|
writeBytes(WEIGHT_MEASUREMENT_SERVICE, CMD_MEASUREMENT_CHARACTERISTIC, cmdByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,21 +90,19 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean nextBluetoothCmd(int stateNr) {
|
protected boolean nextBluetoothCmd(int stateNr) {
|
||||||
switch (stateNr) {
|
switch (stateNr) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
sendUserData();
|
sendUserData();
|
||||||
|
break;
|
||||||
break;
|
default:
|
||||||
|
return false;
|
||||||
default:
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,65 +117,61 @@ 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 ) {
|
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.toString());
|
||||||
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.toString());
|
||||||
addScaleData(measurement);
|
addScaleData(measurement);
|
||||||
gotData=2;
|
gotData = 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseBytes(byte[] weightBytes) {
|
private void parseBytes(byte[] weightBytes) {
|
||||||
if (measurement==null){
|
if (measurement == null) {
|
||||||
measurement= new ScaleMeasurement();
|
measurement = new ScaleMeasurement();
|
||||||
}
|
}
|
||||||
int type=(int)weightBytes[6]&0xff;
|
int type = (int)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
|
||||||
measurement.setWeight(weight);
|
measurement.setWeight(weight);
|
||||||
break;
|
break;
|
||||||
case 0xb0:
|
case 0xb0:
|
||||||
float fat = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // %
|
float fat = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // %
|
||||||
float water = Converters.fromUnsignedInt16Be(weightBytes, 4) / 10.0f; // %
|
float water = Converters.fromUnsignedInt16Be(weightBytes, 4) / 10.0f; // %
|
||||||
measurement.setFat(fat);
|
measurement.setFat(fat);
|
||||||
measurement.setWater(water);
|
measurement.setWater(water);
|
||||||
FatMus|=0x2;
|
FatMus |= 0x2;
|
||||||
break;
|
break;
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
float bone = Converters.fromUnsignedInt16Le(weightBytes, 4) / 10.0f; // kg
|
float bone = Converters.fromUnsignedInt16Le(weightBytes, 4) / 10.0f; // kg
|
||||||
float muscle = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // %
|
float muscle = Converters.fromUnsignedInt16Be(weightBytes, 2) / 10.0f; // %
|
||||||
measurement.setMuscle(muscle);
|
measurement.setMuscle(muscle);
|
||||||
measurement.setBone(bone);
|
measurement.setBone(bone);
|
||||||
FatMus|=0x1;
|
FatMus |= 0x1;
|
||||||
break;
|
break;
|
||||||
case 0xd0:
|
case 0xd0:
|
||||||
float calorie = Converters.fromUnsignedInt16Be(weightBytes, 2);
|
float calorie = Converters.fromUnsignedInt16Be(weightBytes, 2);
|
||||||
break;
|
break;
|
||||||
case 0xe0:
|
case 0xe0:
|
||||||
break;
|
break;
|
||||||
case 0xe1:
|
case 0xe1:
|
||||||
break;
|
break;
|
||||||
case 0xe2:
|
case 0xe2:
|
||||||
//date
|
//date
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//measurement.setDateTime(lastWeighted);
|
//measurement.setDateTime(lastWeighted);
|
||||||
measurement.setDateTime(new Date());
|
measurement.setDateTime(new Date());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user