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