File tree Expand file tree Collapse file tree
android_app/app/src/main/java/com/health/openscale/core/bluetooth/scales Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,16 +270,19 @@ class MiScaleHandler : ScaleDeviceHandler() {
270270 return
271271 }
272272
273- // Response to “ only last” : 0x01 <count> FF FF <uniqHi> <uniqLo >
273+ // Response to " only last" or "all" : 0x01 <count> 0x00 <marker/echo bytes... >
274274 if (d.size >= 6 && d[0 ] == 0x01 .toByte()) {
275275 val count = d[1 ].toInt() and 0xFF
276- // Accept FF FF and 00 00
277276 val marker = (d[2 ].toInt() and 0xFF ) shl 8 or (d[3 ].toInt() and 0xFF )
278277 if (marker == 0xFFFF || marker == 0x0000 ) {
279278 pendingHistoryCount = count
279+ histBufReset() // Discard any stale bytes (e.g. magic-echo) before history data arrives.
280280 logI(" History count announced (marker=${marker.toString(16 )} ): $pendingHistoryCount " )
281- return
281+ } else {
282+ // Control response (e.g. magic-echo) with unrecognized marker — discard, not history data.
283+ logD(" Ignoring control response (marker=${marker.toString(16 )} , len=${d.size} ): ${d.toHexPreview(16 )} " )
282284 }
285+ return
283286 }
284287
285288 // Live frames (13B) or combined (26B)
You can’t perform that action at this time.
0 commit comments