mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 08:13:43 +02:00
Let Timber do string formatting
This commit is contained in:
@@ -208,7 +208,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
byte[] nick = selectedUser.getUserName().toUpperCase().substring(0, maxIdx).getBytes();
|
byte[] nick = selectedUser.getUserName().toUpperCase().substring(0, maxIdx).getBytes();
|
||||||
|
|
||||||
byte activity = 2; // activity level: 1 - 5
|
byte activity = 2; // activity level: 1 - 5
|
||||||
Timber.d("Create User:" + selectedUser.getUserName());
|
Timber.d("Create User: %s", selectedUser.getUserName());
|
||||||
|
|
||||||
writeBytes(new byte[]{
|
writeBytes(new byte[]{
|
||||||
(byte) startByte, (byte) 0x31, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
(byte) startByte, (byte) 0x31, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
||||||
@@ -223,15 +223,15 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Get existing user information
|
// Get existing user information
|
||||||
Timber.d("Request getUserInfo " + currentScaleUserId);
|
Timber.d("Request getUserInfo %d", currentScaleUserId);
|
||||||
writeBytes(new byte[]{
|
writeBytes(new byte[]{
|
||||||
(byte) startByte, (byte) 0x36, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
(byte) startByte, (byte) 0x36, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
||||||
(byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId
|
(byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
Timber.d("scaleuserid:" + currentScaleUserId + " registered users: " + countRegisteredScaleUsers +
|
Timber.d("scaleuserid: %d, registered users: %d, extracted users: %d",
|
||||||
" extracted users: " + seenUsers.size());
|
currentScaleUserId, countRegisteredScaleUsers, seenUsers.size());
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
break;
|
break;
|
||||||
@@ -302,7 +302,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
|
|
||||||
int count = (byte) (data[4] & 0xFF);
|
int count = (byte) (data[4] & 0xFF);
|
||||||
int maxUsers = (byte) (data[5] & 0xFF);
|
int maxUsers = (byte) (data[5] & 0xFF);
|
||||||
Timber.d("Count:" + count + " maxUsers:" + maxUsers);
|
Timber.d("Count: %d, maxUsers: %d", count, maxUsers);
|
||||||
|
|
||||||
countRegisteredScaleUsers = count;
|
countRegisteredScaleUsers = count;
|
||||||
// Check if any scale user is registered
|
// Check if any scale user is registered
|
||||||
@@ -360,8 +360,8 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
boolean male = (data[11] & 0xF0) != 0;
|
boolean male = (data[11] & 0xF0) != 0;
|
||||||
byte activity = (byte) (data[11] & 0x0F);
|
byte activity = (byte) (data[11] & 0x0F);
|
||||||
|
|
||||||
Timber.d("Name " + name + " YY-MM-DD: " + year + " " + month + " " + day +
|
Timber.d("Name: %s, YY-MM-DD: %d-%d-%d, Height: %d, Sex: %s, activity: %d",
|
||||||
"Height: " + height + " Sex:" + (male ? "M" : "F") + "activity: " + activity);
|
name, year, month, day, height, male ? "male" : "female", activity);
|
||||||
|
|
||||||
// Get scale status for user
|
// Get scale status for user
|
||||||
writeBytes(new byte[]{
|
writeBytes(new byte[]{
|
||||||
@@ -385,10 +385,11 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
boolean userMeasurementExist = (data[10] == 0);
|
boolean userMeasurementExist = (data[10] == 0);
|
||||||
int scaleVersion = data[11];
|
int scaleVersion = data[11];
|
||||||
|
|
||||||
Timber.d("BatteryLevel:" + batteryLevel + " weightThreshold: " + weightThreshold +
|
Timber.d("BatteryLevel: %d, weightThreshold: %.2f, BodyFatThreshold: %.2f,"
|
||||||
" BodyFatThresh: " + bodyFatThreshold + " Unit: " + unit + " userExists: " + userExists +
|
+ " Unit: %d, userExists: %b, UserReference Weight Exists: %b,"
|
||||||
" UserReference Weight Exists: " + userReferWeightExists + " UserMeasurementExists: " + userMeasurementExist +
|
+ " UserMeasurementExists: %b, scaleVersion: %d",
|
||||||
" scaleVersion: " + scaleVersion);
|
batteryLevel, weightThreshold, bodyFatThreshold, unit, userExists,
|
||||||
|
userReferWeightExists, userMeasurementExist, scaleVersion);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +414,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
|
|
||||||
byte nr_measurements = data[3];
|
byte nr_measurements = data[3];
|
||||||
|
|
||||||
Timber.d("New measurements: " + nr_measurements / 2);
|
Timber.d("New measurements: %d", nr_measurements / 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +434,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
try {
|
try {
|
||||||
receivedScaleData.write(Arrays.copyOfRange(data, 4, data.length));
|
receivedScaleData.write(Arrays.copyOfRange(data, 4, data.length));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Timber.e(e, "Failed to copy user specific data");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send acknowledgement
|
// Send acknowledgement
|
||||||
@@ -447,8 +448,8 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
ScaleMeasurement parsedData = parseScaleData(receivedScaleData.toByteArray());
|
ScaleMeasurement parsedData = parseScaleData(receivedScaleData.toByteArray());
|
||||||
addScaleData(parsedData);
|
addScaleData(parsedData);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Timber.d(e, "Could not parse byte array: " + byteInHex(receivedScaleData.toByteArray()));
|
Timber.d(e, "Could not parse byte array: %s", byteInHex(receivedScaleData.toByteArray()));
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +469,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.i("Got weight: " + weight);
|
Timber.i("Got weight: %.2f", weight);
|
||||||
|
|
||||||
writeBytes(new byte[]{
|
writeBytes(new byte[]{
|
||||||
(byte) startByte, (byte) 0xf1, (byte) (data[1] & 0xFF),
|
(byte) startByte, (byte) 0xf1, (byte) (data[1] & 0xFF),
|
||||||
@@ -480,7 +481,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
|
|
||||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x59) {
|
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x59) {
|
||||||
// Get stable measurement results
|
// Get stable measurement results
|
||||||
Timber.d("Get measurement data " + ((int) data[3]));
|
Timber.d("Get measurement data %d", (int) data[3]);
|
||||||
|
|
||||||
int max_items = (data[2] & 0xFF);
|
int max_items = (data[2] & 0xFF);
|
||||||
int current_item = (data[3] & 0xFF);
|
int current_item = (data[3] & 0xFF);
|
||||||
@@ -492,7 +493,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
try {
|
try {
|
||||||
receivedScaleData.write(Arrays.copyOfRange(data, 4, data.length));
|
receivedScaleData.write(Arrays.copyOfRange(data, 4, data.length));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Timber.e(e, "Failed to copy stable measurement array");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +512,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
// Delete data
|
// Delete data
|
||||||
deleteScaleData();
|
deleteScaleData();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Timber.d(e, "Parse Exception " + byteInHex(receivedScaleData.toByteArray()));
|
Timber.d(e, "Parse Exception %s", byteInHex(receivedScaleData.toByteArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +524,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("DataChanged - not handled: " + byteInHex(data));
|
Timber.d("DataChanged - not handled: %s", byteInHex(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteScaleData() {
|
private void deleteScaleData() {
|
||||||
@@ -568,10 +569,8 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
receivedMeasurement.setMuscle(muscle);
|
receivedMeasurement.setMuscle(muscle);
|
||||||
receivedMeasurement.setBone(bone);
|
receivedMeasurement.setBone(bone);
|
||||||
|
|
||||||
Timber.i("Measurement: " + receivedMeasurement.getDateTime().toString() +
|
Timber.i("Measurement: %s, Impedance: %d, BMR: %d, AMR: %d, BMI: %.2f",
|
||||||
" Impedance: " + impedance + " Weight:" + weight +
|
receivedMeasurement, impedance, bmr, amr, bmi);
|
||||||
" Fat: " + fat + " Water: " + water + " Muscle: " + muscle +
|
|
||||||
" Bone: " + bone + " BMR: " + bmr + " AMR: " + amr + " BMI: " + bmi);
|
|
||||||
|
|
||||||
return receivedMeasurement;
|
return receivedMeasurement;
|
||||||
}
|
}
|
||||||
@@ -580,7 +579,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
// Update date/time of the scale
|
// Update date/time of the scale
|
||||||
long unixTime = System.currentTimeMillis() / 1000L;
|
long unixTime = System.currentTimeMillis() / 1000L;
|
||||||
byte[] unixTimeBytes = Converters.toUnsignedInt32Be(unixTime);
|
byte[] unixTimeBytes = Converters.toUnsignedInt32Be(unixTime);
|
||||||
Timber.d("Write new Date/Time:" + unixTime + " " + byteInHex(unixTimeBytes));
|
Timber.d("Write new Date/Time: %d (%s)", unixTime, byteInHex(unixTimeBytes));
|
||||||
|
|
||||||
writeBytes(new byte[]{(byte) getAlternativeStartByte(9),
|
writeBytes(new byte[]{(byte) getAlternativeStartByte(9),
|
||||||
unixTimeBytes[0], unixTimeBytes[1], unixTimeBytes[2], unixTimeBytes[3]});
|
unixTimeBytes[0], unixTimeBytes[1], unixTimeBytes[2], unixTimeBytes[3]});
|
||||||
@@ -601,7 +600,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
|||||||
command[2] = (byte) 0x04;
|
command[2] = (byte) 0x04;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Timber.d("Setting unit " + selectedUser.getScaleUnit().toString());
|
Timber.d("Setting unit %s", selectedUser.getScaleUnit());
|
||||||
writeBytes(command);
|
writeBytes(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -202,13 +202,13 @@ public class BluetoothCustomOpenScale extends BluetoothCommunication {
|
|||||||
|
|
||||||
switch (btString.charAt(1)) {
|
switch (btString.charAt(1)) {
|
||||||
case 'I':
|
case 'I':
|
||||||
Timber.i("MCU Information: " + btMsg);
|
Timber.i("MCU Information: %s", btMsg);
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
Timber.e("MCU Error: " + btMsg);
|
Timber.e("MCU Error: %s", btMsg);
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
Timber.i("MCU stored data size: " + btMsg);
|
Timber.i("MCU stored data size: %s", btMsg);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
String[] csvField = btMsg.split(",");
|
String[] csvField = btMsg.split(",");
|
||||||
|
@@ -141,7 +141,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
|||||||
|
|
||||||
|
|
||||||
private boolean sendBtData(String data) {
|
private boolean sendBtData(String data) {
|
||||||
Timber.w("ihealthHS3 - sendBtData"+data);
|
Timber.w("ihealthHS3 - sendBtData %s", data);
|
||||||
if (btSocket.isConnected()) {
|
if (btSocket.isConnected()) {
|
||||||
btConnectThread = new BluetoothConnectedThread();
|
btConnectThread = new BluetoothConnectedThread();
|
||||||
btConnectThread.write(data.getBytes());
|
btConnectThread.write(data.getBytes());
|
||||||
@@ -214,7 +214,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
|||||||
Timber.w("seen 0xa009a633 - time packet");
|
Timber.w("seen 0xa009a633 - time packet");
|
||||||
// deal with a time packet, if needed
|
// deal with a time packet, if needed
|
||||||
} else {
|
} else {
|
||||||
Timber.w("iHealthHS3 - seen byte after control leader "+String.format("%02X",btByte));
|
Timber.w("iHealthHS3 - seen byte after control leader %02X", btByte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -330,7 +330,7 @@ public class MainActivity extends BaseAppCompatActivity
|
|||||||
try {
|
try {
|
||||||
transaction.add(R.id.fragment_content, (Fragment) fragmentClass.newInstance(), tag);
|
transaction.add(R.id.fragment_content, (Fragment) fragmentClass.newInstance(), tag);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Timber.e(e, "Failed to add fragment %s", tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,7 +518,7 @@ public class MainActivity extends BaseAppCompatActivity
|
|||||||
case BT_UNEXPECTED_ERROR:
|
case BT_UNEXPECTED_ERROR:
|
||||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
|
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_connection_error) + ": " + msg.obj, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_connection_error) + ": " + msg.obj, Toast.LENGTH_SHORT).show();
|
||||||
Timber.e("Bluetooth unexpected error: " + msg.obj);
|
Timber.e("Bluetooth unexpected error: %s", msg.obj);
|
||||||
break;
|
break;
|
||||||
case BT_SCALE_MESSAGE:
|
case BT_SCALE_MESSAGE:
|
||||||
String toastMessage = String.format(getResources().getString(msg.arg1), msg.obj);
|
String toastMessage = String.format(getResources().getString(msg.arg1), msg.obj);
|
||||||
|
Reference in New Issue
Block a user