[AI Generated]: feat(*): 新增蓝牙保活机制、设备初始化功能及用户双向同步逻辑
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
0a6578c2c9
commit
c41c7d9f63
@@ -48,6 +48,7 @@ Page({
|
||||
ppScale.device.connection = this.data.device;
|
||||
|
||||
wx.hideLoading();
|
||||
this._startKeepAlive();
|
||||
|
||||
// 配网步骤:重新获取 WiFi 列表
|
||||
if (currentStep === 2) {
|
||||
@@ -68,6 +69,7 @@ Page({
|
||||
console.log("===》codeSyncTime", codeSyncTime)
|
||||
|
||||
wx.hideLoading();
|
||||
this._startKeepAlive();
|
||||
ppScale.device.name = this.data.device.name;
|
||||
ppScale.device.connection = this.data.device;
|
||||
const nameArr = this.data.device.name.split("-");
|
||||
@@ -175,6 +177,25 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 启动保活定时器,每10秒发送一次保活指令
|
||||
_keepAliveTimer: null,
|
||||
_startKeepAlive() {
|
||||
this._stopKeepAlive();
|
||||
this._keepAliveTimer = setInterval(() => {
|
||||
if (ppScale.activeProtocol) {
|
||||
ppScale.activeProtocol.sendKeepAliveCode();
|
||||
}
|
||||
}, 15000);
|
||||
},
|
||||
|
||||
// 清除保活定时器
|
||||
_stopKeepAlive() {
|
||||
if (this._keepAliveTimer) {
|
||||
clearInterval(this._keepAliveTimer);
|
||||
this._keepAliveTimer = null;
|
||||
}
|
||||
},
|
||||
|
||||
checkBluetoothPermissionAndInit() {
|
||||
wx.getSetting({
|
||||
success: (res) => {
|
||||
@@ -233,6 +254,7 @@ Page({
|
||||
|
||||
onHide() {
|
||||
console.log("configureDevice onHide");
|
||||
this._stopKeepAlive();
|
||||
// 配网步骤:立即清空 WiFi 列表(stop 后数据已失效)
|
||||
if (this.data.progress.index === 2) {
|
||||
const comp = this.selectComponent('#configureDevice3');
|
||||
@@ -254,6 +276,7 @@ Page({
|
||||
|
||||
onUnload() {
|
||||
console.log("configureDevice onUnload");
|
||||
this._stopKeepAlive();
|
||||
app.resetReconnectCount();
|
||||
app.setGlobalData('ppScale.device.connectState', null);
|
||||
this._connectReady = false;
|
||||
|
||||
Reference in New Issue
Block a user