fix: vendor_33 BLE emits compatible 'status' event for existing pages
- handleValueChange now calls parseVendorStatus and emits 'status' with legacy-compatible shape (mode_state, battery, remaining_ms, etc.) - 1-byte heartbeat mapped to mode_state, 33-byte state parsed for active IO detection - Fixes regression where treating, index, wear-check, auto-scan pages never received status updates in vendor_33 mode - Also emits 'vendor_raw' with full parsed data for future use
这个提交包含在:
@@ -83,14 +83,34 @@ function handleNotification(frame) {
|
|||||||
|
|
||||||
function handleValueChange(res) {
|
function handleValueChange(res) {
|
||||||
if (protocol.PROTOCOL_MODE === 'vendor_33') {
|
if (protocol.PROTOCOL_MODE === 'vendor_33') {
|
||||||
var bytes = protocol.bufferToBytes(res.value)
|
var parsed = protocol.parseVendorStatus(res.value)
|
||||||
var uuid = (res.characteristicId || '').toUpperCase()
|
emit('vendor_raw', parsed)
|
||||||
var isStatus = uuid.indexOf(CHAR.STATUS) !== -1
|
var status = {
|
||||||
if (isStatus) {
|
mode_state: parsed.is_heartbeat ? (parsed.heartbeat || 0) : protocol.MODE_STATE.IDLE,
|
||||||
emit('vendor_status', { raw: bytes, heartbeat: bytes[0] })
|
region_mask: protocol.REGION.FULL_FACE,
|
||||||
} else {
|
wavelength: 0,
|
||||||
emit('vendor_data', { raw: bytes, hex: protocol.bytesToHex(bytes) })
|
brightness: 0,
|
||||||
|
remaining_ms: 0,
|
||||||
|
error_code: 0,
|
||||||
|
battery: 0,
|
||||||
|
temperature: 0,
|
||||||
|
bind_status: 1,
|
||||||
|
subscription: 1
|
||||||
}
|
}
|
||||||
|
if (!parsed.is_heartbeat && parsed.ios) {
|
||||||
|
var anyActive = false
|
||||||
|
for (var i = 0; i < parsed.ios.length; i++) {
|
||||||
|
if (parsed.ios[i].red || parsed.ios[i].infrared || parsed.ios[i].uv || parsed.ios[i].warm_yellow) {
|
||||||
|
anyActive = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status.mode_state = anyActive ? protocol.MODE_STATE.ACTIVE : protocol.MODE_STATE.IDLE
|
||||||
|
if (parsed.hold_time > 0) {
|
||||||
|
status.remaining_ms = parsed.hold_time * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit('status', status)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var frame = protocol.parseFrame(res.value)
|
var frame = protocol.parseFrame(res.value)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户