From a9a1899b49af114770e0fb2dbff76c4120178cb9 Mon Sep 17 00:00:00 2001 From: Guoguo Date: Tue, 28 Jul 2026 18:43:01 -0700 Subject: [PATCH] fix(ble): treat Byte17 != 0 as fitting-ok (matches firmware semantics) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firmware reports fitting via 'Byte17 != 0', not a dedicated bit — during scan Byte17 carries the wave marker (0x20/0x40/0x60/0x80), all non-zero, so it also signals fitting-ok. The old 'byte17 & 0x1F == 1' test never matched (low 5 bits are 0 when the wave marker occupies the high 3), so auto-scan waited forever on fitting==1 and then mis-fired '未贴合失败'. Verified against real-device frames: scan now collects and buckets all four wavelengths. --- miniprogram/services/ble/protocol.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/miniprogram/services/ble/protocol.js b/miniprogram/services/ble/protocol.js index 892c6a1..08b62ff 100644 --- a/miniprogram/services/ble/protocol.js +++ b/miniprogram/services/ble/protocol.js @@ -251,7 +251,9 @@ function parseVendorStatus(buffer) { for (var p = 0; p < 7; p++) { pds19.push(bytes[p * 2] | (bytes[p * 2 + 1] << 8)) } - // Byte17 复用:低位=贴合状态(0/1),高三位=扫描时光色指示(0 表示无标识/非扫描态或旧固件)。 + // Byte17 复用:固件约定「非 0 即贴合通过」;高三位另表扫描光色(001红/010红外/011紫外/100暖黄)。 + // 扫描态 Byte17 = 0x20/0x40/0x60/0x80(有光色→非0→贴合);检测启动但未贴合时 = 0。 + // 注意:贴合与光色共用一字节,固件当前无独立贴合位(已反馈,待其拆分)。 // Byte18 运行状态:0=IDLE 1=检测 2=治疗 0xFF=故障。 var scanWaveCode = (bytes[16] >> 5) & 0x07 return { @@ -259,7 +261,7 @@ function parseVendorStatus(buffer) { is_heartbeat: false, pd: pds19, vbat: bytes[14] | (bytes[15] << 8), - fitting: bytes[16] & 0x1F, + fitting: bytes[16] !== 0 ? 1 : 0, scan_wave: SCAN_WAVE_KEY[scanWaveCode] || null, run_state: bytes[17], is_fault: bytes[17] === 0xFF,