mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 07:21:40 +02:00
fix bluetooth mi scale bug if no device is in range
This commit is contained in:
@@ -8,7 +8,7 @@ android {
|
|||||||
applicationId "com.health.openscale"
|
applicationId "com.health.openscale"
|
||||||
minSdkVersion 18
|
minSdkVersion 18
|
||||||
targetSdkVersion 22 // don't set target sdk > 22 otherwise bluetooth le discovery need permission to ACCESS_COARSE_LOCATION
|
targetSdkVersion 22 // don't set target sdk > 22 otherwise bluetooth le discovery need permission to ACCESS_COARSE_LOCATION
|
||||||
versionCode 11
|
versionCode 12
|
||||||
versionName "1.4.3"
|
versionName "1.4.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,16 +67,16 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
|||||||
scanCallback = new BluetoothAdapter.LeScanCallback()
|
scanCallback = new BluetoothAdapter.LeScanCallback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord)
|
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
|
||||||
|
if (device.getAddress().replace(":", "").toUpperCase().startsWith("880F10") ||
|
||||||
|
device.getAddress().replace(":", "").toUpperCase().startsWith("C80F10") ) // Xiaomi
|
||||||
{
|
{
|
||||||
if (device.getName().equals(btDeviceName)) {
|
if (device.getName().equals(btDeviceName)) {
|
||||||
Log.d("BluetoothMiScale", "Mi Scale found trying to connect...");
|
Log.d("BluetoothMiScale", "Mi Scale found trying to connect...");
|
||||||
|
|
||||||
if (scanRecord.length > 30) {
|
|
||||||
final byte[] weightData = Arrays.copyOfRange(scanRecord, 21, 31);
|
final byte[] weightData = Arrays.copyOfRange(scanRecord, 21, 31);
|
||||||
weightData[0] = 0x62; // Set weight remove to false to come through parse bytes
|
weightData[0] = 0x62; // Set weight remove to false to come through parse bytes
|
||||||
parseBytes(weightData);
|
parseBytes(weightData);
|
||||||
}
|
|
||||||
|
|
||||||
bluetoothGatt = device.connectGatt(context, false, gattCallback);
|
bluetoothGatt = device.connectGatt(context, false, gattCallback);
|
||||||
|
|
||||||
@@ -84,6 +84,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
|||||||
btAdapter.stopLeScan(scanCallback);
|
btAdapter.stopLeScan(scanCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,7 +88,8 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="90"
|
android:layout_weight="90"
|
||||||
android:stretchColumns="1">
|
android:stretchColumns="1"
|
||||||
|
android:id="@+id/tableLayoutMeasurements">
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@@ -79,7 +79,8 @@
|
|||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:stretchColumns="1">
|
android:stretchColumns="1"
|
||||||
|
android:id="@+id/tableLayoutMeasurements">
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||||
<string-array name="bt_device_entries">
|
<string-array name="bt_device_entries">
|
||||||
<item>Xiaomi Mi Scale</item>
|
<item>Xiaomi Mi Scale v1</item>
|
||||||
<item>openScale Custom Scale</item>
|
<item>openScale Custom Scale</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user