Skip to content

Commit b59f6b4

Browse files
authored
Fix Mi Scale v1 measurments (#1294)
Handle the 10‑byte frames sent through CHAR_WEIGHT_MEAS and parse them with parseHistory10(). Live weight on Mi Scale v1 stopped working after 3.0.0. This restores it. Tested on a real Mi Scale v1. No changes made for v2.
1 parent f65627d commit b59f6b4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • android_app/app/src/main/java/com/health/openscale/core/bluetooth/scales

android_app/app/src/main/java/com/health/openscale/core/bluetooth/scales/MiScaleHandler.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ class MiScaleHandler : ScaleDeviceHandler() {
245245
return
246246
}
247247

248+
if (characteristic == CHAR_WEIGHT_MEAS) {
249+
handleWeightMeasNotify(data, user)
250+
return
251+
}
252+
248253
// Some firmwares may leak data elsewhere; log a small preview.
249254
logD("Notify $characteristic len=${data.size} ${data.toHexPreview(24)}")
250255
}
@@ -295,6 +300,17 @@ class MiScaleHandler : ScaleDeviceHandler() {
295300
appendHistoryChunk(d)
296301
}
297302

303+
private fun handleWeightMeasNotify(d: ByteArray, user: ScaleUser) {
304+
// 10‑byte frame (same layout as history10)
305+
if (variant == Variant.V1 && d.size == 10) {
306+
parseHistory10(d, user)
307+
return
308+
}
309+
310+
// Other lengths: debug only
311+
logD("WeightMeas notify len=${d.size} ${d.toHexPreview(24)}")
312+
}
313+
298314
/** v2 live frame (13 bytes). With/without impedance. Publishes stabilized frames only. */
299315
private fun parseLive13(d: ByteArray, user: ScaleUser): Boolean {
300316
if (d.size != 13) return false

0 commit comments

Comments
 (0)