mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 07:21:40 +02:00
refactored Sennsun scale
This commit is contained in:
@@ -46,21 +46,6 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
return "Senssun";
|
return "Senssun";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disconnect() {
|
|
||||||
Timber.i("disconnect(and save Data)");
|
|
||||||
saveUserData();
|
|
||||||
super.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveUserData(){
|
|
||||||
if ( isBitSet(WeightFatMus,2) ) {
|
|
||||||
addScaleData(measurement);
|
|
||||||
WeightFatMus=0;
|
|
||||||
setBtStatus(BT_STATUS_CODE.BT_CONNECTION_LOST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUserData(){
|
private void sendUserData(){
|
||||||
if ( scaleGotUserData ){
|
if ( scaleGotUserData ){
|
||||||
return;
|
return;
|
||||||
@@ -84,10 +69,11 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean nextInitCmd(int stateNr) {
|
protected boolean nextInitCmd(int stateNr) {
|
||||||
Timber.d("Cmd Clean %d",stateNr);
|
|
||||||
switch (stateNr) {
|
switch (stateNr) {
|
||||||
case 0:
|
case 0:
|
||||||
setNotificationOn(WEIGHT_MEASUREMENT_CHARACTERISTIC);
|
setNotificationOn(WEIGHT_MEASUREMENT_CHARACTERISTIC);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
sendUserData();
|
sendUserData();
|
||||||
WeightFatMus = 0;
|
WeightFatMus = 0;
|
||||||
scaleGotUserData = false;
|
scaleGotUserData = false;
|
||||||
@@ -118,9 +104,10 @@ public class BluetoothSenssun extends BluetoothCommunication {
|
|||||||
|
|
||||||
if (data != null && !isBitSet(WeightFatMus, 3)) { //only if not saved
|
if (data != null && !isBitSet(WeightFatMus, 3)) { //only if not saved
|
||||||
parseBytes(data);
|
parseBytes(data);
|
||||||
if (WeightFatMus == 0x07) {
|
}
|
||||||
disconnect();
|
|
||||||
}
|
if (isBitSet(WeightFatMus,2) ) {
|
||||||
|
addScaleData(measurement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user