fix:调整配网逻辑

This commit is contained in:
liyi 2025-04-26 15:51:16 +08:00
parent 5f079fb3d4
commit 96367baaea

View File

@ -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; //
} }
} }