fix:调整配网loading卡主的问题
This commit is contained in:
parent
49ed169506
commit
cd41dd4ccf
@ -62,17 +62,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
peerId: peerId,
|
peerId: peerId,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
// 设置锁的peerID
|
||||||
|
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
||||||
|
wifiName: wifiName,
|
||||||
|
networkMac: networkMac,
|
||||||
|
secretKey: secretKey,
|
||||||
|
peerId: peerId,
|
||||||
|
);
|
||||||
|
|
||||||
showToast('配网成功'.tr, something: () async {
|
await _getUploadLockSet();
|
||||||
// 设置锁的peerID
|
|
||||||
StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
|
|
||||||
wifiName: wifiName,
|
|
||||||
networkMac: networkMac,
|
|
||||||
secretKey: secretKey,
|
|
||||||
peerId: peerId,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
_getUploadLockSet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +104,11 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
// WIFI配网结果
|
// WIFI配网结果
|
||||||
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
|
Future<void> _replySenderConfiguringWifiResult(Reply reply) async {
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
state.sureBtnState.value = 0;
|
// state.sureBtnState.value = 0;
|
||||||
state.isLoading.value = false;
|
|
||||||
|
// 取消loading超时定时器
|
||||||
|
state.loadingTimer?.cancel();
|
||||||
|
state.loadingTimer = null;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
@ -140,15 +141,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
secretKey: secretKey ?? '',
|
secretKey: secretKey ?? '',
|
||||||
deviceMac: deviceMac ?? '',
|
deviceMac: deviceMac ?? '',
|
||||||
networkMac: networkMac ?? '');
|
networkMac: networkMac ?? '');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//失败
|
//失败
|
||||||
dismissEasyLoading();
|
dismissEasyLoading(); // 关闭loading
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
if (state.loadingTimer != null) {
|
if (state.loadingTimer != null) {
|
||||||
state.loadingTimer!.cancel();
|
state.loadingTimer!.cancel();
|
||||||
state.loadingTimer = null;
|
state.loadingTimer = null;
|
||||||
}
|
}
|
||||||
cancelBlueConnetctToastTimer();
|
|
||||||
showToast('配网失败'.tr);
|
showToast('配网失败'.tr);
|
||||||
state.isLoading.value = false;
|
state.isLoading.value = false;
|
||||||
break;
|
break;
|
||||||
@ -164,7 +167,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
// 点击配置wifi
|
// 点击配置wifi
|
||||||
Future<void> senderConfiguringWifiAction() async {
|
Future<void> senderConfiguringWifiAction() async {
|
||||||
AppLog.log('开始配网${EasyLoading.isShow}');
|
AppLog.log('开始配网${EasyLoading.isShow}');
|
||||||
EasyLoading.show();
|
|
||||||
if (state.isLoading.isTrue) {
|
if (state.isLoading.isTrue) {
|
||||||
AppLog.log('正在配网中请勿重复点击');
|
AppLog.log('正在配网中请勿重复点击');
|
||||||
return;
|
return;
|
||||||
@ -178,10 +181,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
showToast('请输入WiFi密码'.tr);
|
showToast('请输入WiFi密码'.tr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state.sureBtnState.value == 1) {
|
// if (state.sureBtnState.value == 1) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
state.sureBtnState.value = 1;
|
// state.sureBtnState.value = 1;
|
||||||
|
|
||||||
final GetGatewayConfigurationEntity entity =
|
final GetGatewayConfigurationEntity entity =
|
||||||
await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
|
await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
|
||||||
@ -218,9 +221,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
// 如果为空,则直接赋值
|
// 如果为空,则直接赋值
|
||||||
state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
|
state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
|
||||||
}
|
}
|
||||||
|
showEasyLoading();
|
||||||
|
showBlueConnetctToastTimer(action: () {
|
||||||
|
dismissEasyLoading();
|
||||||
|
state.isLoading.value = false;
|
||||||
|
});
|
||||||
|
|
||||||
AppLog.log('获取到配网信息===开始发送蓝牙指令${EasyLoading.isShow}');
|
// 发送配网指令
|
||||||
|
|
||||||
BlueManage().blueSendData(
|
BlueManage().blueSendData(
|
||||||
BlueManage().connectDeviceName,
|
BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState connectionState) async {
|
(BluetoothConnectionState connectionState) async {
|
||||||
@ -233,35 +240,16 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
state.sureBtnState.value = 0;
|
state.isLoading.value = false;
|
||||||
|
// state.sureBtnState.value = 0;
|
||||||
if (state.ifCurrentScreen.value == true) {
|
if (state.ifCurrentScreen.value == true) {
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isAddEquipment: true,
|
isAddEquipment: false,
|
||||||
);
|
);
|
||||||
state.loadingTimer ??= Timer.periodic(Duration(milliseconds: 100), (timer) {
|
|
||||||
if (!EasyLoading.isShow) {
|
|
||||||
EasyLoading.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
state.isLoading.value = true;
|
state.isLoading.value = true;
|
||||||
// 添加15秒超时检查
|
|
||||||
Future.delayed(const Duration(seconds: 15), () {
|
|
||||||
if (state.isLoading.isTrue) {
|
|
||||||
EasyLoading.dismiss();
|
|
||||||
state.isLoading.value = false;
|
|
||||||
state.sureBtnState.value = 0;
|
|
||||||
if (state.loadingTimer != null) {
|
|
||||||
state.loadingTimer!.cancel();
|
|
||||||
state.loadingTimer = null;
|
|
||||||
}
|
|
||||||
showToast('配网失败'.tr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AppLog.log('发送方法执行完毕${EasyLoading.isShow}');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取设备状态
|
// 获取设备状态
|
||||||
@ -320,7 +308,7 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
|
|
||||||
getWifiLockServiceIpAndPort();
|
getWifiLockServiceIpAndPort();
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
getDevicesStatusAction();
|
// getDevicesStatusAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -336,13 +324,13 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
|
|
||||||
void _replyGatewayGetStatusReply(GatewayGetStatusReply reply) {
|
void _replyGatewayGetStatusReply(GatewayGetStatusReply reply) {
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
|
//成功
|
||||||
|
dismissEasyLoading();
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
// state.sureBtnState.value = 0;
|
// state.sureBtnState.value = 0;
|
||||||
cancelBlueConnetctToastTimer();
|
|
||||||
dismissEasyLoading();
|
|
||||||
|
|
||||||
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
|
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
|
||||||
// 网关MAC地址
|
// 网关MAC地址
|
||||||
@ -393,28 +381,17 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _replyStatusInfo(reply) {}
|
|
||||||
|
|
||||||
// 上传数据获取设置
|
// 上传数据获取设置
|
||||||
Future<void> _getUploadLockSet() async {
|
Future<void> _getUploadLockSet() async {
|
||||||
// showEasyLoading();
|
showEasyLoading();
|
||||||
// showBlueConnetctToastTimer(action: () {
|
showBlueConnetctToastTimer(action: () {
|
||||||
// dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
// });
|
|
||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
|
||||||
(BluetoothConnectionState connectionState) async {
|
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
|
||||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
|
||||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
|
||||||
|
|
||||||
_uploadLockSet(getTokenList);
|
|
||||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
|
||||||
cancelBlueConnetctToastTimer();
|
|
||||||
if (state.ifCurrentScreen.value == true) {
|
|
||||||
showBlueConnetctToast();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
|
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
|
await _uploadLockSet(getTokenList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公共的上传锁设置
|
// 公共的上传锁设置
|
||||||
@ -438,15 +415,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
// 上传数据获取锁设置解析
|
// 上传数据获取锁设置解析
|
||||||
Future<void> _replyUpdataLockSetReply(Reply reply) async {
|
Future<void> _replyUpdataLockSetReply(Reply reply) async {
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
|
dismissEasyLoading(); // 关闭loading
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
await _lockDataUpload(
|
||||||
dismissEasyLoading();
|
|
||||||
cancelBlueConnetctToastTimer();
|
|
||||||
_lockDataUpload(
|
|
||||||
uploadType: 1,
|
uploadType: 1,
|
||||||
recordType: 0,
|
recordType: 0,
|
||||||
records: reply.data.sublist(7, reply.data.length));
|
records: reply.data.sublist(7, reply.data.length));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
@ -475,33 +452,18 @@ class ConfiguringWifiLogic extends BaseGetXController {
|
|||||||
records: records,
|
records: records,
|
||||||
isUnShowLoading: true);
|
isUnShowLoading: true);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
await Future.delayed((Duration(seconds: 1)));
|
showToast('配网成功'.tr, something: () {
|
||||||
if (state.pageName.value == 'lockSet') {
|
state.isLoading.value = false;
|
||||||
Get.close(2);
|
if (state.pageName.value == 'lockSet') {
|
||||||
} else {
|
Get.close(2);
|
||||||
Get.offAllNamed(Routers.starLockMain);
|
} else {
|
||||||
}
|
Get.offAllNamed(Routers.starLockMain);
|
||||||
dismissEasyLoading();
|
}
|
||||||
eventBus
|
|
||||||
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
|
||||||
eventBus
|
|
||||||
.fire(SuccessfulDistributionNetwork());
|
|
||||||
if (state.loadingTimer != null) {
|
|
||||||
state.loadingTimer!.cancel();
|
|
||||||
state.loadingTimer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
eventBus
|
||||||
void dispose() {
|
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||||
dismissEasyLoading();
|
eventBus.fire(SuccessfulDistributionNetwork());
|
||||||
// TODO: implement dispose
|
});
|
||||||
super.dispose();
|
|
||||||
state.isLoading.value = false;
|
|
||||||
if (state.loadingTimer != null) {
|
|
||||||
state.loadingTimer!.cancel();
|
|
||||||
state.loadingTimer = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
showToast('固件升级完成'.tr);
|
showToast('固件升级完成'.tr);
|
||||||
closeOTADAta();
|
closeOTADAta();
|
||||||
}
|
}
|
||||||
dismissEasyLoading();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +159,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 获取星锁状态
|
// 获取星锁状态
|
||||||
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
Future<void> _replyGetStarLockStatusInfo(Reply reply) async {
|
||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
|
dismissEasyLoading();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
@ -743,8 +743,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
super.onClose();
|
|
||||||
_replySubscription?.cancel();
|
_replySubscription?.cancel();
|
||||||
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getNearByLimits() async {
|
Future<void> getNearByLimits() async {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user