From 688edb8b10148a33a200c88bb42427a5e9cde25a Mon Sep 17 00:00:00 2001 From: Jochen Scheib Date: Sat, 1 Jul 2017 09:34:09 +0200 Subject: [PATCH 1/3] Add new HW address for Medisana BS444 --- .../health/openscale/core/bluetooth/BluetoothMedisanaBS444.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java index 9e71a766f..0a73cba32 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java @@ -60,6 +60,7 @@ public boolean isDeviceNameCheck() { public ArrayList hwAddresses() { ArrayList hwAddresses = new ArrayList(); hwAddresses.add("E454EB"); + hwAddresses.add("F13A88"); return hwAddresses; } From ff4aa2a14260a26f802fa36cb0cb58626892074f Mon Sep 17 00:00:00 2001 From: Jochen Scheib Date: Sat, 1 Jul 2017 15:02:02 +0200 Subject: [PATCH 2/3] Bugfix: Wrong time. Magic Bytes contain timestamp --- .../core/bluetooth/BluetoothMedisanaBS444.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java index 0a73cba32..fc75a7a2c 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java @@ -91,7 +91,16 @@ boolean nextBluetoothCmd(int stateNr){ break; case 3: // send magic number to receive weight data - byte[] magicBytes = new byte[]{(byte)0x02, (byte)0x7B, (byte)0x7B, (byte)0xF6, (byte)0x0D}; // 02:7b:7b:f6:0d + Date date = new Date(); + long unix_timestamp = date.getTime() - 1262304000; // -40 years because unix time starts in year 1970 + + byte[] magicBytes = new byte[5]; + magicBytes[0] = (byte)0x02; + for (int i = 4; i >= 1; i--) { + magicBytes[i] = (byte)(unix_timestamp & 0xFF); + unix_timestamp >>= 8; + } + //byte[] magicBytes = new byte[]{(byte)0x02, (byte)0x7B, (byte)0x7B, (byte)0xF6, (byte)0x0D}; // 02:7b:7b:f6:0d writeBytes(WEIGHT_MEASUREMENT_SERVICE, CMD_MEASUREMENT_CHARACTERISTIC, magicBytes); break; From d68c5a24dd6432a27aa1b02c24ef9b0bba624521 Mon Sep 17 00:00:00 2001 From: Jochen Scheib Date: Sat, 1 Jul 2017 19:13:17 +0200 Subject: [PATCH 3/3] Fix millisecs to secs --- .../core/bluetooth/BluetoothMedisanaBS444.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java index fc75a7a2c..3ab8ed5e5 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMedisanaBS444.java @@ -92,14 +92,15 @@ boolean nextBluetoothCmd(int stateNr){ case 3: // send magic number to receive weight data Date date = new Date(); - long unix_timestamp = date.getTime() - 1262304000; // -40 years because unix time starts in year 1970 - - byte[] magicBytes = new byte[5]; - magicBytes[0] = (byte)0x02; - for (int i = 4; i >= 1; i--) { - magicBytes[i] = (byte)(unix_timestamp & 0xFF); - unix_timestamp >>= 8; - } + int unix_timestamp = (int) ((date.getTime() / 1000) - 1262304000) ; // -40 years because unix time starts in year 1970 + + byte[] magicBytes = new byte[] { + (byte)0x02, + (byte)(unix_timestamp), + (byte)(unix_timestamp >>> 8), + (byte)(unix_timestamp >>> 16), + (byte)(unix_timestamp >>> 24) + }; //byte[] magicBytes = new byte[]{(byte)0x02, (byte)0x7B, (byte)0x7B, (byte)0xF6, (byte)0x0D}; // 02:7b:7b:f6:0d writeBytes(WEIGHT_MEASUREMENT_SERVICE, CMD_MEASUREMENT_CHARACTERISTIC, magicBytes);