diff --git a/android_app/app/src/main/java/com/health/openscale/core/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/BluetoothCommunication.java
index 9d54b515..a066444a 100644
--- a/android_app/app/src/main/java/com/health/openscale/core/BluetoothCommunication.java
+++ b/android_app/app/src/main/java/com/health/openscale/core/BluetoothCommunication.java
@@ -24,10 +24,11 @@ public abstract class BluetoothCommunication {
public static final int BT_OPEN_SCALE = 1;
public static final int BT_RETRIEVE_SCALE_DATA = 0;
- public static final int BT_CONNECTION_ESTABLISHED = 1;
- public static final int BT_CONNECTION_LOST = 2;
- public static final int BT_NO_DEVICE_FOUND = 3;
- public static final int BT_UNEXPECTED_ERROR = 4;
+ public static final int BT_INIT_PROCESS = 1;
+ public static final int BT_CONNECTION_ESTABLISHED = 2;
+ public static final int BT_CONNECTION_LOST = 3;
+ public static final int BT_NO_DEVICE_FOUND = 4;
+ public static final int BT_UNEXPECTED_ERROR = 5;
protected Handler callbackBtHandler;
protected BluetoothAdapter btAdapter;
diff --git a/android_app/app/src/main/java/com/health/openscale/core/BluetoothMiScale.java b/android_app/app/src/main/java/com/health/openscale/core/BluetoothMiScale.java
index c5312213..e344d3b8 100644
--- a/android_app/app/src/main/java/com/health/openscale/core/BluetoothMiScale.java
+++ b/android_app/app/src/main/java/com/health/openscale/core/BluetoothMiScale.java
@@ -14,11 +14,6 @@
* along with this program. If not, see
*/
-/*
- * Modified version of Mnkai original BTUtils.java source code
- * Copyright (C) Mnkai Apache 2.0 license
- */
-
package com.health.openscale.core;
import android.bluetooth.BluetoothAdapter;
@@ -77,7 +72,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
if (device.getAddress().replace(":", "").startsWith("880f10") ||
device.getAddress().replace(":", "").startsWith("880F10")) // Xiaomi
{
- if (device.getName().equals(btDeviceName)) { // It really is scale
+ if (device.getName().equals(btDeviceName)) {
Log.d("BluetoothMiScale", "Mi Scale found trying to connect...");
bluetoothGatt = device.connectGatt(context, false, gattCallback);
@@ -142,8 +137,6 @@ public class BluetoothMiScale extends BluetoothCommunication {
BluetoothGattCharacteristic characteristic;
BluetoothGattDescriptor descriptor;
- Log.d("BluetoothMiScale", "Cmd State " + nextCmdState);
-
switch (nextCmdState) {
case 0:
// read device time
@@ -202,10 +195,10 @@ public class BluetoothMiScale extends BluetoothCommunication {
initProcessOn = true;
- Log.d("BluetoothMiScale", "Init State " + nextInitState);
-
switch (nextInitState) {
case 0:
+ callbackBtHandler.obtainMessage(BluetoothCommunication.BT_INIT_PROCESS).sendToTarget();
+
// set current time
characteristic = gatt.getService(WEIGHT_MEASUREMENT_SERVICE)
.getCharacteristic(WEIGHT_MEASUREMENT_TIME_CHARACTERISTIC);
@@ -365,7 +358,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
callbackBtHandler.obtainMessage(BluetoothCommunication.BT_RETRIEVE_SCALE_DATA, scaleBtData).sendToTarget();
} else {
- Log.e("BluetoothMiScale", "Invalid weight year " + year);
+ Log.e("BluetoothMiScale", "Invalid Mi scale weight year " + year);
}
}
} catch (ParseException e) {
diff --git a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java
index 04d74bed..a9e8b7d8 100644
--- a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java
+++ b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java
@@ -220,7 +220,11 @@ public class MainActivity extends ActionBarActivity implements
}
OpenScale.getInstance(getApplicationContext()).addScaleData(scaleBtData);
- OpenScale.getInstance(getApplicationContext()).updateScaleData();
+ break;
+ case BluetoothCommunication.BT_INIT_PROCESS:
+ setBluetoothStatusIcon(R.drawable.bluetooth_connection_success);
+ Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_init), Toast.LENGTH_SHORT).show();
+ Log.d("OpenScale", "Bluetooth initializing");
break;
case BluetoothCommunication.BT_CONNECTION_LOST:
setBluetoothStatusIcon(R.drawable.bluetooth_connection_lost);
diff --git a/android_app/app/src/main/res/values-de/strings.xml b/android_app/app/src/main/res/values-de/strings.xml
index 916da6a3..63b18c70 100644
--- a/android_app/app/src/main/res/values-de/strings.xml
+++ b/android_app/app/src/main/res/values-de/strings.xml
@@ -103,4 +103,5 @@
Kein Bluetooth Gerät gefunden
Versuche Verbindung herzustellen zu
Gerätetyp
+ Initializiere Bluetooth Gerät
\ No newline at end of file
diff --git a/android_app/app/src/main/res/values-ja/strings.xml b/android_app/app/src/main/res/values-ja/strings.xml
index d0094f69..fd2188e5 100644
--- a/android_app/app/src/main/res/values-ja/strings.xml
+++ b/android_app/app/src/main/res/values-ja/strings.xml
@@ -103,4 +103,5 @@
Bluetooth接続を失いました
接続に成功しました
デバイスタイプ
+ Bluetooth接続を初期化する
\ No newline at end of file
diff --git a/android_app/app/src/main/res/values/strings.xml b/android_app/app/src/main/res/values/strings.xml
index fad47707..e7e86ec2 100644
--- a/android_app/app/src/main/res/values/strings.xml
+++ b/android_app/app/src/main/res/values/strings.xml
@@ -96,6 +96,7 @@
Lost Bluetooth connection.
No Bluetooth device found
Connection successful established
+ Initialize Bluetooth device
Bluetooth has an unexpected error
Enter your name