fix:调整配网逻辑
This commit is contained in:
parent
5f079fb3d4
commit
96367baaea
@ -55,7 +55,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
/// 更新网络信息到服务器
|
||||
void updateNetworkInfo({
|
||||
Future<LoginEntity> updateNetworkInfo({
|
||||
required String peerId,
|
||||
required String wifiName,
|
||||
required String secretKey,
|
||||
@ -71,27 +71,12 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
||||
wifiName: wifiName,
|
||||
networkMac: networkMac,
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
|
||||
await _getUploadLockSet();
|
||||
} else {
|
||||
dismissEasyLoading();
|
||||
showToast('网络配置失败,请重试'.tr);
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
return entity;
|
||||
} catch (e) {
|
||||
dismissEasyLoading();
|
||||
showToast('网络配置异常:${e.toString()}'.tr);
|
||||
state.sureBtnState.value = 0;
|
||||
AppLog.log('网络配置异常:$e');
|
||||
return LoginEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,19 +159,34 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
throw Exception('Missing required network information');
|
||||
}
|
||||
|
||||
/// 配网成功后,赋值锁的peerId
|
||||
StartChartManage().lockPeerId = peerId;
|
||||
|
||||
// 保存到缓存
|
||||
await Storage.saveLockNetWorkInfo(jsonMap);
|
||||
|
||||
// 上报服务器 - 注意: sureBtnState 状态将在 updateNetworkInfo 方法中或其回调中完成重置
|
||||
updateNetworkInfo(
|
||||
final info = await updateNetworkInfo(
|
||||
peerId: peerId,
|
||||
wifiName: wifiName ?? '',
|
||||
secretKey: secretKey,
|
||||
deviceMac: deviceMac ?? '',
|
||||
networkMac: networkMac ?? '');
|
||||
if (info.errorCode!.codeIsSuccessful) {
|
||||
// 设置锁的peerID
|
||||
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
||||
wifiName: wifiName,
|
||||
networkMac: networkMac,
|
||||
secretKey: secretKey,
|
||||
peerId: peerId,
|
||||
);
|
||||
|
||||
/// 配网成功后,赋值锁的peerId
|
||||
StartChartManage().lockPeerId = peerId;
|
||||
|
||||
// 保存到缓存
|
||||
await Storage.saveLockNetWorkInfo(jsonMap);
|
||||
|
||||
await _getUploadLockSet();
|
||||
} else {
|
||||
dismissEasyLoading();
|
||||
showToast('网络配置失败,请重试'.tr);
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
} catch (e) {
|
||||
if (EasyLoading.isShow) {
|
||||
dismissEasyLoading();
|
||||
@ -495,13 +495,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
throw Exception('Token is empty');
|
||||
}
|
||||
final List<int> getTokenList = changeStringListToIntList(token);
|
||||
// 蓝牙获取锁设置
|
||||
await _uploadLockSet(getTokenList);
|
||||
} catch (e) {
|
||||
if (EasyLoading.isShow) {
|
||||
dismissEasyLoading();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
showToast('获取设置失败:${e.toString()}'.tr);
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
@ -613,14 +613,14 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
||||
if (EasyLoading.isShow) {
|
||||
dismissEasyLoading();
|
||||
}
|
||||
showToast('数据上传失败:${entity.errorCode}'.tr);
|
||||
// showToast('数据上传失败:${entity.errorCode}'.tr);
|
||||
state.sureBtnState.value = 0; // 确保重置状态
|
||||
}
|
||||
} catch (e) {
|
||||
if (EasyLoading.isShow) {
|
||||
dismissEasyLoading();
|
||||
}
|
||||
showToast('数据上传异常:${e.toString()}'.tr);
|
||||
// showToast('数据上传异常:${e.toString()}'.tr);
|
||||
state.sureBtnState.value = 0; // 确保重置状态
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user