fix: ADC notifications no longer emit 'status' (prevents timer jump)
- ADC (17-byte) now emits 'adc' + 'battery' events, not 'status' - Fixes CRITICAL timer jump: remaining_ms:0 was resetting countdown - Drop ADC packets with bad XOR checksum - treating.js + index.js subscribe to 'battery' for live battery updates - onStatus only updates remaining_ms when > 0
这个提交包含在:
@@ -55,7 +55,9 @@ Page({
|
||||
this._onReconnectFailed = this.onReconnectFailed.bind(this)
|
||||
this._sessionId = 'SESS_' + Date.now()
|
||||
|
||||
this._onBattery = this.onBattery.bind(this)
|
||||
ble.on('status', this._onStatus)
|
||||
ble.on('battery', this._onBattery)
|
||||
ble.on('treatment_complete', this._onComplete)
|
||||
ble.on('exception', this._onException)
|
||||
ble.on('disconnected', this._onDisconnect)
|
||||
@@ -68,6 +70,7 @@ Page({
|
||||
|
||||
onUnload: function () {
|
||||
if (this._onStatus) ble.off('status', this._onStatus)
|
||||
if (this._onBattery) ble.off('battery', this._onBattery)
|
||||
if (this._onComplete) ble.off('treatment_complete', this._onComplete)
|
||||
if (this._onException) ble.off('exception', this._onException)
|
||||
if (this._onDisconnect) ble.off('disconnected', this._onDisconnect)
|
||||
@@ -104,16 +107,21 @@ Page({
|
||||
},
|
||||
|
||||
onStatus: function (status) {
|
||||
var remaining = status.remaining_ms || 0
|
||||
this.updateProgress(remaining)
|
||||
if (status.remaining_ms > 0) {
|
||||
this.updateProgress(status.remaining_ms)
|
||||
}
|
||||
this.setData({
|
||||
battery: status.battery,
|
||||
temperature: status.temperature,
|
||||
battery: status.battery || this.data.battery,
|
||||
temperature: status.temperature || this.data.temperature,
|
||||
paused: status.mode_state === 0x03
|
||||
})
|
||||
this.syncCommands()
|
||||
},
|
||||
|
||||
onBattery: function (info) {
|
||||
this.setData({ battery: info.battery })
|
||||
},
|
||||
|
||||
syncCommands: function () {
|
||||
var app = getApp()
|
||||
var device = app.globalData.currentDevice || {}
|
||||
|
||||
在新工单中引用
屏蔽一个用户