diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c287c9f7..2131843f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,19 +16,19 @@ variables:
- macos
- flutter
rules:
- - if: $CI_COMMIT_BRANCH == "develop"
- - if: $CI_COMMIT_BRANCH == "release"
+ - if: $CI_COMMIT_BRANCH == "develop_sky"
+ - if: $CI_COMMIT_BRANCH == "release_sky"
- if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/
- - if: $CI_COMMIT_BRANCH == "canary_release"
- - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/
+ - if: $CI_COMMIT_BRANCH == "canary_release_sky"
+ - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?(_sky)?$/
.notify_rule:
tags:
- macos
- flutter
rules:
- - if: $CI_COMMIT_BRANCH == "develop"
- - if: $CI_COMMIT_BRANCH == "release"
+ - if: $CI_COMMIT_BRANCH == "develop_sky"
+ - if: $CI_COMMIT_BRANCH == "release_sky"
- if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/
.generate_tag_rule:
@@ -36,16 +36,16 @@ variables:
- macos
- flutter
rules:
- - if: $CI_COMMIT_BRANCH == "master"
+ - if: $CI_COMMIT_BRANCH == "master_sky"
.generate_next_version_rule:
tags:
- macos
- flutter
rules:
- - if: $CI_COMMIT_BRANCH == "develop"
- - if: $CI_COMMIT_BRANCH == "release"
- - if: $CI_COMMIT_BRANCH == "canary_release"
+ - if: $CI_COMMIT_BRANCH == "develop_sky"
+ - if: $CI_COMMIT_BRANCH == "release_sky"
+ - if: $CI_COMMIT_BRANCH == "canary_release_sky"
- if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/
.print_env:
diff --git a/README.md b/README.md
index 45dfc905..d6ee8c02 100755
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# 星锁APP
-
+测试ci
星云项目组旗下的智能锁应用,其中锁相关数据接入星云平台,业务数据接入星锁自有后台。
基于Flutter技术架构,支持Android和iOS平台。
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 341d6fae..76a4b29b 100755
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -31,7 +31,6 @@
-
diff --git a/android/build.sh b/android/build.sh
index 4b598959..40a15413 100755
--- a/android/build.sh
+++ b/android/build.sh
@@ -8,8 +8,9 @@ export ENV_BUILD_WORKSPACE=${CI_PROJECT_DIR}
echo "GITLAB_WORKSPACE: ${CI_PROJECT_DIR}"
cd ${CI_PROJECT_DIR}/android
echo "ENV_BUILD_TAG:${ENV_BUILD_TAG},ENV_BUILD_BRANCH:${ENV_BUILD_BRANCH}"
-regex='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$'
-if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then
+# 只支持 v1.2.3_sky 这种tag格式
+regex='^v[0-9]+\.[0-9]+\.[0-9]+_sky$'
+if [[ "${ENV_BUILD_BRANCH}" == "canary_release_sky" ]]; then
echo "===build canary_release: ${NEXT_VERSION}"
export ENV_BUILD_TAG=${NEXT_VERSION}
bundle exec fastlane release_apk flavor:xhj --verbose
@@ -20,11 +21,11 @@ elif [[ $ENV_BUILD_TAG =~ $regex ]]; then
bundle exec fastlane release_apk flavor:sky --verbose
bundle exec fastlane release_bundle flavor:xhj_bundle --verbose
bundle exec fastlane release_bundle flavor:sky --verbose
-elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then
+elif [[ "${ENV_BUILD_BRANCH}" == "develop_sky" ]]; then
echo "===build dev===${NEXT_VERSION}"
bundle exec fastlane beta flavor:xhj env:dev --verbose
bundle exec fastlane beta flavor:sky env:dev --verbose
-elif [[ "${ENV_BUILD_BRANCH}" == "release" ]] || [[ "${ENV_BUILD_BRANCH}" == "feat_devops" ]] ; then
+elif [[ "${ENV_BUILD_BRANCH}" == "release_sky" || "${ENV_BUILD_BRANCH}" == "feat_devops_sky" ]] ; then
echo "===build pre===${NEXT_VERSION}"
bundle exec fastlane beta flavor:xhj env:pre --verbose
bundle exec fastlane beta flavor:sky env:pre --verbose
diff --git a/assets/html/h264.html b/assets/html/h264.html
index 0995b612..60ec7039 100644
--- a/assets/html/h264.html
+++ b/assets/html/h264.html
@@ -29,8 +29,8 @@
#player {
object-fit: cover;
- height: 56vh;
- transform: rotate(-90deg);
+ width: 100vw;
+ height: 100vh;
}
diff --git a/ios/build.sh b/ios/build.sh
index a8a977bf..2c46b1f1 100755
--- a/ios/build.sh
+++ b/ios/build.sh
@@ -9,8 +9,9 @@ echo "GITLAB_WORKSPACE: ${CI_PROJECT_DIR}"
cd ${CI_PROJECT_DIR}/ios
#bundle exec pod install
echo "ENV_BUILD_TAG:${ENV_BUILD_TAG},ENV_BUILD_BRANCH:${ENV_BUILD_BRANCH}"
-regex='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$'
-if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then
+# 只支持 v1.2.3_sky 这种tag格式
+regex='^v[0-9]+\.[0-9]+\.[0-9]+_sky$'
+if [[ "${ENV_BUILD_BRANCH}" == "canary_release_sky" ]]; then
echo "===build canary_release: ${NEXT_VERSION}"
export ENV_BUILD_TAG=${NEXT_VERSION}
bundle exec fastlane release_ipa flavor:xhj --verbose
@@ -19,11 +20,11 @@ elif [[ $ENV_BUILD_TAG =~ $regex ]]; then
echo "===build release===$ENV_BUILD_TAG"
bundle exec fastlane release_ipa flavor:xhj --verbose
bundle exec fastlane release_ipa flavor:sky --verbose
-elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then
+elif [[ "${ENV_BUILD_BRANCH}" == "develop_sky" ]]; then
echo "===build dev===${NEXT_VERSION}"
bundle exec fastlane beta flavor:xhj env:Dev --verbose
bundle exec fastlane beta flavor:sky env:Dev --verbose
-elif [[ "${ENV_BUILD_BRANCH}" == "release" ]] || [[ "${ENV_BUILD_BRANCH}" == "feat_devops" ]] ; then
+elif [[ "${ENV_BUILD_BRANCH}" == "release_sky" || "${ENV_BUILD_BRANCH}" == "feat_devops_sky" ]] ; then
echo "===build pre===${NEXT_VERSION}"
bundle exec fastlane beta flavor:xhj env:Pre --verbose
bundle exec fastlane beta flavor:sky env:Pre --verbose
diff --git a/lib/appRouters.dart b/lib/appRouters.dart
index ab6c17a9..0a06445a 100755
--- a/lib/appRouters.dart
+++ b/lib/appRouters.dart
@@ -60,6 +60,7 @@ import 'package:star_lock/mine/mineSet/transferSmartLock/transferSmartLockList/t
import 'package:star_lock/mine/valueAddedServices/advancedFeaturesWeb/advancedFeaturesWeb_page.dart';
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_page.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_page.dart';
+import 'package:star_lock/talk/starChart/views/native/talk_view_native_decode_page.dart';
import 'package:star_lock/talk/starChart/views/talkView/talk_view_page.dart';
import 'package:star_lock/talk/starChart/webView/h264_web_view.dart';
@@ -202,6 +203,7 @@ import 'mine/valueAddedServices/valueAddedServicesRealName/value_added_services_
import 'mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesAddSMSTemplate/newSMSTemplate_page.dart';
import 'mine/valueAddedServices/valueAddedServicesSMSTemplate/valueAddedServicesListSMSTemplate/customSMSTemplateList_page.dart';
import 'starLockApplication/starLockApplication.dart';
+import 'talk/starChart/views/imageTransmission/image_transmission_page.dart';
import 'tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart';
abstract class Routers {
@@ -514,6 +516,8 @@ abstract class Routers {
static const String starChartPage = '/starChartPage'; //星图
static const String starChartTalkView = '/starChartTalkView'; //星图对讲页面
static const String h264WebView = '/h264WebView'; //星图对讲页面
+ static const String imageTransmissionView =
+ '/imageTransmissionView'; //星图对讲页面(图传)
}
abstract class AppRouters {
@@ -1184,6 +1188,13 @@ abstract class AppRouters {
page: () => const DoubleLockLinkPage()),
GetPage(
name: Routers.starChartTalkView, page: () => const TalkViewPage()),
- GetPage(name: Routers.h264WebView, page: () => H264WebView()),
+ GetPage(
+ name: Routers.h264WebView, page: () => TalkViewNativeDecodePage()),
+ // 插件播放页面
+ GetPage(
+ name: Routers.imageTransmissionView,
+ page: () => ImageTransmissionPage()),
+ // 插件播放页面
+ // GetPage(name: Routers.h264WebView, page: () => H264WebView()), // webview播放页面
];
}
diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart
index f90753b4..d3d4d587 100755
--- a/lib/blue/blue_manage.dart
+++ b/lib/blue/blue_manage.dart
@@ -5,6 +5,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
+import 'package:star_lock/flavors.dart';
import 'package:star_lock/tools/bugly/bugly_tool.dart';
import 'package:star_lock/tools/commonDataManage.dart';
@@ -190,10 +191,12 @@ class BlueManage {
continue;
}
- final isMatch = _isMatch(scanResult
- .advertisementData.serviceUuids
- .map((e) => e.uuid)
- .toList());
+ final isMatch = _isMatch(
+ scanResult.advertisementData.serviceUuids
+ .map((e) => e.uuid)
+ .toList(),
+ isSingle: true,
+ );
if (isMatch && (scanResult.rssi >= -100)) {
// 查询id相同的元素
@@ -276,6 +279,7 @@ class BlueManage {
.map((e) => e.uuid)
.toList(),
deviceType: deviceType,
+ isSingle: false,
);
// 判断名字为空的直接剔除
if (isMatch && (scanResult.rssi >= -100)) {
@@ -320,26 +324,47 @@ class BlueManage {
/// 判断是否包含指定的uuid
bool _isMatch(List serviceUuids,
- {DeviceType deviceType = DeviceType.blue}) {
+ {DeviceType deviceType = DeviceType.blue, required bool isSingle}) {
final List prefixes =
getDeviceType(deviceType).map((e) => e.toLowerCase()).toList();
for (String uuid in serviceUuids) {
- final String cleanUuid = uuid.replaceAll('-', '').toLowerCase();
+ final String cleanUuid = uuid.toLowerCase();
if (cleanUuid.length == 8) {
- // 8位,判断前两位
+ // 8位,判断第4、5位
+ String pairStatus = cleanUuid.substring(4, 6); // 第4、5位(索引3和4)
for (final prefix in prefixes) {
if (cleanUuid.startsWith(prefix)) {
- return true;
+ if (isSingle) {
+ return true; // isSingle为true,前缀匹配即返回true
+ } else {
+ // 00=未配对,01=已配对
+ if (pairStatus == '00') {
+ return true; // 未配对才返回true
+ }
+ // 已配对(01)不返回true,继续判断下一个uuid
+ }
}
}
- } else if (cleanUuid.length == 32) {
+ } else {
// 128位,判断前8位的第3、第4位
- final String first8 = cleanUuid.substring(0, 8);
- if (first8.length >= 4) {
- final String thirdAndFourth = first8.substring(2, 4); // 索引2和3
+ if (cleanUuid.length >= 32) {
+ final String thirdAndFourth = cleanUuid.substring(2, 4); // 索引2和3
for (final prefix in prefixes) {
if (thirdAndFourth == prefix) {
- return true;
+ if (isSingle) {
+ return true; // isSingle为true,前缀匹配即返回true
+ } else {
+ // 判断配对状态(带横杠UUID的第31、32位,从1开始计数)
+ if (cleanUuid.length >= 32) {
+ String pairStatus =
+ cleanUuid.substring(30, 32); // 第31、32位(从1开始计数)
+ // 00=未配对,01=已配对
+ if (pairStatus == '00') {
+ return true; // 未配对才返回true
+ }
+ // 已配对(01)不返回true,继续判断下一个uuid
+ }
+ }
}
}
}
@@ -567,7 +592,10 @@ class BlueManage {
});
} else {
connectStateCallBack(BluetoothConnectionState.disconnected);
- EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
+ if (!F.isSKY) {
+ EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
+ }
+
scanDevices.clear();
BuglyTool.uploadException(
@@ -598,7 +626,9 @@ class BlueManage {
});
} else {
connectStateCallBack(BluetoothConnectionState.disconnected);
- EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
+ if (!F.isSKY) {
+ EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
+ }
scanDevices.clear();
BuglyTool.uploadException(
@@ -791,7 +821,7 @@ class BlueManage {
}
}
- // 写入
+ /// 写入蓝牙特征值,并等待响应
Future writeCharacteristicWithResponse(List value) async {
final List services =
await bluetoothConnectDevice!.discoverServices();
@@ -801,30 +831,70 @@ class BlueManage {
in service.characteristics) {
if (characteristic.characteristicUuid == _characteristicIdWrite) {
try {
+ // 添加重试机制
+ int retryCount = 0;
+ const int maxRetries = 3;
+ const int retryDelayMs = 500;
+
final List valueList = value;
final List subData = splitList(valueList, _mtuSize!);
- // AppLog.log('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData');
+
for (int i = 0; i < subData.length; i++) {
- if (characteristic.properties.writeWithoutResponse) {
- // 使用WRITE_NO_RESPONSE属性写入值
- await characteristic.write(subData[i], withoutResponse: true);
- } else if (characteristic.properties.write) {
- // 使用WRITE属性写入值
- await characteristic.write(subData[i]);
- } else {
- // 特性不支持写入
+ // 对每个数据包都应用重试逻辑
+ bool packetSent = false;
+ retryCount = 0;
+
+ while (!packetSent && retryCount < maxRetries) {
+ try {
+ if (characteristic.properties.writeWithoutResponse) {
+ await characteristic.write(subData[i],
+ withoutResponse: true);
+ } else if (characteristic.properties.write) {
+ await characteristic.write(subData[i]);
+ } else {
+ // 特性不支持写入
+ throw Exception(
+ 'This characteristic does not support writing.');
+ }
+
+ // 如果到这里没有异常,则包发送成功
+ packetSent = true;
+ } catch (e) {
+ if (e.toString().contains('UNKNOWN_GATT_ERROR (133)') &&
+ retryCount < maxRetries - 1) {
+ // GATT错误133,尝试重试
+ retryCount++;
+ AppLog.log(
+ '蓝牙写入失败(GATT 133),数据包 ${i + 1}/${subData.length} 正在重试 $retryCount/$maxRetries...');
+ await Future.delayed(
+ Duration(milliseconds: retryDelayMs));
+ continue;
+ } else {
+ // 其他错误或已达到最大重试次数,抛出异常
+ AppLog.log('APP写入失败: $e');
+ throw e;
+ }
+ }
+ }
+
+ if (!packetSent) {
throw Exception(
- 'This characteristic does not support writing.');
+ '蓝牙写入失败,数据包 ${i + 1}/${subData.length} 已达到最大重试次数');
}
}
+
+ return; // 所有数据包都发送成功
} on Exception catch (e, s) {
- AppLog.log('APP写入失败: $e $s');
+ AppLog.log('APP写入失败: $e $s');
rethrow;
}
}
}
}
}
+
+ // 如果找不到合适的特性用于写入
+ throw Exception('未找到适合写入的蓝牙特性');
}
// 停止扫描蓝牙设备
diff --git a/lib/blue/reciver_data.dart b/lib/blue/reciver_data.dart
index 2fc7fe54..0b0f4c61 100755
--- a/lib/blue/reciver_data.dart
+++ b/lib/blue/reciver_data.dart
@@ -61,16 +61,16 @@ class CommandReciverManager {
final int dataSize = data.length;
// 验证CRC校验
- if (dataSize >= 2) {
- final int calculatedCrc =
- _calculateCRC16(data.sublist(0, dataSize - 2), dataSize - 2);
- final int receivedCrc = (data[dataSize - 2] << 8) | data[dataSize - 1];
-
- if (calculatedCrc != receivedCrc) {
- AppLog.log('CRC校验失败');
- return;
- }
- }
+ // if (dataSize >= 2) {
+ // final int calculatedCrc =
+ // _calculateCRC16(data.sublist(0, dataSize - 2), dataSize - 2);
+ // final int receivedCrc = (data[dataSize - 2] << 8) | data[dataSize - 1];
+ //
+ // if (calculatedCrc != receivedCrc) {
+ // throw Exception('CRC校验失败');
+ // return;
+ // }
+ // }
// 当小于包头加起来13个字节
if (dataSize < 13) {
return;
diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart
index bc2fd663..8d8140e6 100755
--- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart
+++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart
@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
+import 'package:star_lock/flavors.dart';
import 'package:star_lock/main/lockDetail/card/cardDetail/cardDetail_state.dart';
import '../../../../appRouters.dart';
@@ -179,13 +180,22 @@ class _CardDetailPageState extends State with RouteAware {
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
- Obx(() => CommonItem(
- leftTitel: '是否为管理员'.tr,
- rightTitle: '',
- isTipsImg: false,
- isHaveRightWidget: true,
- rightWidget:
- SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))),
+ Visibility(
+ visible: !F.isSKY,
+ child: Obx(
+ () => CommonItem(
+ leftTitel: '是否为管理员'.tr,
+ rightTitle: '',
+ isTipsImg: false,
+ isHaveRightWidget: true,
+ rightWidget: SizedBox(
+ width: 60.w,
+ height: 50.h,
+ child: _isAdmin(),
+ ),
+ ),
+ ),
+ ),
Container(height: 10.h),
CommonItem(
leftTitel: '操作记录'.tr,
diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart
index 2fc2e376..c007eca1 100755
--- a/lib/main/lockDetail/card/cardList/cardList_logic.dart
+++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart
@@ -249,8 +249,9 @@ class CardListLogic extends BaseGetXController {
_initReplySubscription();
// _initRefreshAction();
+ await getICCardListData(isRefresh: true);
}
- await getICCardListData(isRefresh: true);
+
}
@override
diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart
index 766e81ab..e4af7a36 100755
--- a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart
+++ b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart
@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
+import 'package:star_lock/flavors.dart';
import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_logic.dart';
import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart';
@@ -174,13 +175,22 @@ class _FaceDetailPageState extends State with RouteAware {
// isHaveRightWidget: true,
// isHaveLine: true,
// rightWidget: SizedBox(width: 60.w, height: 50.h, child: _isStressFace()))),
- Obx(() => CommonItem(
- leftTitel: '是否为管理员'.tr,
- rightTitle: '',
- isTipsImg: false,
- isHaveRightWidget: true,
- rightWidget:
- SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))),
+ Visibility(
+ visible: !F.isSKY,
+ child: Obx(
+ () => CommonItem(
+ leftTitel: '是否为管理员'.tr,
+ rightTitle: '',
+ isTipsImg: false,
+ isHaveRightWidget: true,
+ rightWidget: SizedBox(
+ width: 60.w,
+ height: 50.h,
+ child: _isAdmin(),
+ ),
+ ),
+ ),
+ ),
Container(height: 10.h),
CommonItem(
leftTitel: '操作记录'.tr,
diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart
index a1499556..2f6e8a18 100755
--- a/lib/main/lockDetail/face/faceList/faceList_logic.dart
+++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart
@@ -443,8 +443,9 @@ class FaceListLogic extends BaseGetXController {
// senderCheckingCardStatus();
// senderCheckingUserInfoCount();
+ await getFaceListData(isRefresh: true);
}
- getFaceListData(isRefresh: true);
+
}
@override
diff --git a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart
index c5ff8d1c..ebf94158 100755
--- a/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart
+++ b/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/apm/apm_helper.dart';
+import 'package:star_lock/flavors.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockDetail/fingerprint/addFingerprint/addFingerprint_entity.dart';
import 'package:star_lock/tools/dateTool.dart';
@@ -141,7 +142,7 @@ class AddFingerprintLogic extends BaseGetXController {
break;
case 0xFE:
case 12:
- // 管理员已满
+ // 管理员已满
state.ifAddState.value = false;
showToast('管理员已满'.tr, something: () {
Get.back();
@@ -250,6 +251,12 @@ class AddFingerprintLogic extends BaseGetXController {
final List? token = await Storage.getStringList(saveBlueToken);
final List getTokenList = changeStringListToIntList(token!);
+ String startTime = DateTool().dateToHNString(state.effectiveDateTime.value);
+ String endTime = DateTool().dateToHNString(state.failureDateTime.value);
+ if (F.isSKY) {
+ startTime = '255:00';
+ endTime = '255:00';
+ }
final String command = SenderAddFingerprintWithTimeCycleCoercionCommand(
keyID: '1',
@@ -267,8 +274,8 @@ class AddFingerprintLogic extends BaseGetXController {
// 周循环
startDate: int.parse(state.startDate.value) ~/ 1000,
endDate: int.parse(state.endDate.value) ~/ 1000,
- startTime: DateTool().dateToHNString(state.effectiveDateTime.value),
- endTime: DateTool().dateToHNString(state.failureDateTime.value),
+ startTime: startTime,
+ endTime: endTime,
needAuthor: 1,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
@@ -324,8 +331,8 @@ class AddFingerprintLogic extends BaseGetXController {
// 周循环
startDate: int.parse(state.startDate.value) ~/ 1000,
endDate: int.parse(state.endDate.value) ~/ 1000,
- startTime: DateTool().dateToHNString(state.effectiveDateTime.value),
- endTime: DateTool().dateToHNString(state.failureDateTime.value),
+ startTime: startTime,
+ endTime: endTime,
needAuthor: 1,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart
index b3f66632..fc018b40 100755
--- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart
+++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
+import 'package:star_lock/flavors.dart';
import 'package:star_lock/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart';
import '../../../../appRouters.dart';
@@ -178,13 +179,22 @@ class _FingerprintDetailPageState extends State
isHaveLine: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _isStressFingerprint()))),
- Obx(() => CommonItem(
- leftTitel: '是否为管理员'.tr,
- rightTitle: '',
- isTipsImg: false,
- isHaveRightWidget: true,
- rightWidget:
- SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))),
+ Visibility(
+ visible: !F.isSKY,
+ child: Obx(
+ () => CommonItem(
+ leftTitel: '是否为管理员'.tr,
+ rightTitle: '',
+ isTipsImg: false,
+ isHaveRightWidget: true,
+ rightWidget: SizedBox(
+ width: 60.w,
+ height: 50.h,
+ child: _isAdmin(),
+ ),
+ ),
+ ),
+ ),
Container(height: 10.h),
CommonItem(
leftTitel: '操作记录'.tr,
diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart
index 3cf6e155..44e9259d 100755
--- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart
+++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart
@@ -15,6 +15,8 @@ import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
+import 'package:star_lock/talk/starChart/handle/other/packet_loss_statistics.dart';
+import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
import 'package:star_lock/tools/bugly/bugly_tool.dart';
import 'package:star_lock/tools/throttler.dart';
@@ -572,7 +574,7 @@ class LockDetailLogic extends BaseGetXController {
// 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口
Future getLockNetToken() async {
final LockNetTokenEntity entity = await ApiRepository.to
- .getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
+ .getLockNetToken(lockId: state.keyInfos.value.lockId!);
if (entity.errorCode!.codeIsSuccessful) {
state.lockNetToken = entity.data!.token!.toString();
// AppLog.log('从服务器获取联网token:${state.lockNetToken}');
@@ -752,42 +754,40 @@ class LockDetailLogic extends BaseGetXController {
eventBus.fire(RefreshLockDetailInfoDataEvent());
}
- /// 请求设备网络信息并设置
- void requestDeviceNetworkInfo() async {
- final DeviceNetwork deviceNetworkInfo =
- await ApiRepository.to.getDeviceNetwork(
- deviceType: 2,
- deviceMac: state.keyInfos.value.mac!,
- );
- if (deviceNetworkInfo.data?.wifiName == null ||
- deviceNetworkInfo.data?.wifiName == '') {
- return;
- } else {
- final peerId = deviceNetworkInfo?.data?.peerId;
- if (peerId == null || peerId.isEmpty || peerId == '') {
- throw Exception('设备peerId为空');
- }
- // 设置锁的peerID
- StartChartManage().lockNetworkInfo =
- deviceNetworkInfo.data ?? DeviceNetworkInfo();
- StartChartManage().lockPeerId = peerId;
- }
- }
+ // /// 请求设备网络信息并设置
+ // void requestDeviceNetworkInfo() async {
+ // final DeviceNetwork deviceNetworkInfo =
+ // await ApiRepository.to.getDeviceNetwork(
+ // deviceType: 2,
+ // deviceMac: state.keyInfos.value.mac!,
+ // );
+ // if (deviceNetworkInfo.data?.peerId == null ||
+ // deviceNetworkInfo.data?.peerId == '') {
+ // return;
+ // }
+ // final peerId = deviceNetworkInfo!.data!.peerId;
+ // // 设置锁的peerID
+ // StartChartManage().lockNetworkInfo =
+ // deviceNetworkInfo.data ?? DeviceNetworkInfo();
+ // StartChartManage().lockPeerId = peerId!;
+ // }
/// 发送监控消息
void sendMonitorMessage() {
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
+ final network = state.keyInfos.value.network;
if (catEyeConfig.isNotEmpty &&
catEyeConfig.length > 0 &&
catEyeConfig[0].catEyeMode != 0) {
- if (StartChartManage().lockNetworkInfo.wifiName == null ||
- StartChartManage().lockNetworkInfo.wifiName == '') {
+ if (network == null || network?.peerId == null || network?.peerId == '') {
showToast('设备未配网'.tr);
return;
}
+ // 重置丢包率监控
+ // PacketLossStatistics().reset();
// 发送监控id
- StartChartManage().startCallRequestMessageTimer(
- ToPeerId: StartChartManage().lockPeerId ?? '');
+ StartChartManage()
+ .startCallRequestMessageTimer(ToPeerId: network!.peerId ?? '');
} else {
showToast('猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式'.tr);
}
@@ -799,12 +799,13 @@ class LockDetailLogic extends BaseGetXController {
getServerDatetime();
await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth();
- requestDeviceNetworkInfo();
+ // requestDeviceNetworkInfo();
}
@override
void onInit() {
super.onInit();
+
state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = eventBus
.on()
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
@@ -851,11 +852,11 @@ class LockDetailLogic extends BaseGetXController {
}
});
- state.SuccessfulDistributionNetworkEvent = eventBus
- .on()
- .listen((SuccessfulDistributionNetwork event) {
- // 配网成功获取一下配网信息
- requestDeviceNetworkInfo();
- });
+ // state.SuccessfulDistributionNetworkEvent = eventBus
+ // .on()
+ // .listen((SuccessfulDistributionNetwork event) {
+ // // 配网成功获取一下配网信息
+ // requestDeviceNetworkInfo();
+ // });
}
}
diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart
index 1040b5ba..f7605c48 100755
--- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart
+++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart
@@ -1,5 +1,6 @@
import 'dart:async';
+import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -88,7 +89,6 @@ class _LockDetailPageState extends State
/// 路由订阅
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
state.isOpenLockNeedOnline.refresh();
-
}
StreamSubscription? _lockRefreshLockDetailInfoDataEvent;
@@ -1103,13 +1103,15 @@ class _LockDetailPageState extends State
}));
// 密码
- showWidgetArr.add(bottomItem('images/main/icon_main_password.png', '密码'.tr,
- state.bottomBtnisEable.value, () {
- Get.toNamed(Routers.passwordKeyListPage,
- arguments: {
- 'keyInfo': state.keyInfos.value
- });
- }));
+ if (state.keyInfos.value.lockFeature!.password == 1) {
+ showWidgetArr.add(bottomItem('images/main/icon_main_password.png',
+ '密码'.tr, state.bottomBtnisEable.value, () {
+ Get.toNamed(Routers.passwordKeyListPage,
+ arguments: {
+ 'keyInfo': state.keyInfos.value
+ });
+ }));
+ }
// ic卡
if (state.keyInfos.value.lockFeature!.icCard == 1) {
@@ -1179,7 +1181,7 @@ class _LockDetailPageState extends State
}
//可视对讲门锁新增->监控
- if (state.keyInfos.value.lockFeature!.videoIntercom == 1) {
+ if (state.keyInfos.value.lockFeature!.isSupportCatEye == 1) {
showWidgetArr.add(
bottomItem('images/main/icon_catEyes.png', '监控'.tr,
state.bottomBtnisEable.value, () async {
@@ -1467,7 +1469,7 @@ class _LockDetailPageState extends State
state.iSOpenLock.value = true;
state.openLockBtnState.value = 1;
state.animationController!.forward();
- // AppLog.log('点击开锁');
+ AppLog.log('点击开锁');
if (isOpenLockNeedOnline) {
// 不需要联网
state.openDoorModel = 0;
diff --git a/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/lib/main/lockDetail/lockDetail/lockDetail_state.dart
index 01178f52..44efb77d 100755
--- a/lib/main/lockDetail/lockDetail/lockDetail_state.dart
+++ b/lib/main/lockDetail/lockDetail/lockDetail_state.dart
@@ -7,18 +7,18 @@ import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dar
import '../../../blue/io_reply.dart';
import '../../lockMian/entity/lockListInfo_entity.dart';
-
class LockDetailState {
Rx keyInfos = LockListInfoItemEntity().obs;
final Rx lockSetInfoData = LockSetInfoData().obs;
late StreamSubscription replySubscription;
- StreamSubscription? lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
+ StreamSubscription?
+ lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
StreamSubscription? LockSetChangeSetRefreshLockDetailWithTypeSubscription;
StreamSubscription? DetailLockInfo;
StreamSubscription? SuccessfulDistributionNetworkEvent;
String lockNetToken = '0';
- int differentialTime = 0;// 服务器时间与本地时间差值
+ int differentialTime = 0; // 服务器时间与本地时间差值
bool isHaveNetwork = true;
int lockUserNo = 0;
int senderUserId = 0;
@@ -41,7 +41,7 @@ class LockDetailState {
RxBool bottomBtnisEable = true.obs; // 是否不可用 用于限制底部按钮是否可用
RxBool openDoorBtnisUneable = true.obs; // 当钥匙状态不能使用的情况下开锁按钮禁止使用,默认可用
- int openDoorModel = 0;// 离线开门0, 在线开门2 离线关门32 在线关门34
+ int openDoorModel = 0; // 离线开门0, 在线开门2 离线关门32 在线关门34
//过渡动画控制器
AnimationController? animationController;
diff --git a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart
index 58c5a9bb..20c36487 100755
--- a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart
+++ b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart
@@ -158,23 +158,23 @@ class _BasicInformationPageState extends State {
allHeight: 70.h,
isHaveLine: true),
)),
- Obx(() => CommonItem(
- leftTitel: '位置信息'.tr,
- // rightTitle: state.lockBasicInfo.value.address ?? "-",
- allHeight: 80.h,
- isHaveLine: false,
- isHaveRightWidget: true,
- rightWidget: SizedBox(
- width: 300.w,
- child: Text(state.lockBasicInfo.value.address ?? '无'.tr,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.end,
- style: TextStyle(
- fontSize: 22.sp,
- color: AppColors.darkGrayTextColor)),
- ),
- )),
+ // Obx(() => CommonItem(
+ // leftTitel: '位置信息'.tr,
+ // // rightTitle: state.lockBasicInfo.value.address ?? "-",
+ // allHeight: 80.h,
+ // isHaveLine: false,
+ // isHaveRightWidget: true,
+ // rightWidget: SizedBox(
+ // width: 300.w,
+ // child: Text(state.lockBasicInfo.value.address ?? '无'.tr,
+ // maxLines: 2,
+ // overflow: TextOverflow.ellipsis,
+ // textAlign: TextAlign.end,
+ // style: TextStyle(
+ // fontSize: 22.sp,
+ // color: AppColors.darkGrayTextColor)),
+ // ),
+ // )),
/* 2024-01-12 会议确定去掉“微信二维码” by DaisyWu
CommonItem(
leftTitel:
diff --git a/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart b/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart
index 74e2c236..95830a3b 100755
--- a/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart
+++ b/lib/main/lockDetail/lockSet/burglarAlarm/burglarAlarm_logic.dart
@@ -1,4 +1,3 @@
-
import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
@@ -17,31 +16,36 @@ import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart';
import 'burglarAlarm_state.dart';
-class BurglarAlarmLogic extends BaseGetXController{
+class BurglarAlarmLogic extends BaseGetXController {
BurglarAlarmState state = BurglarAlarmState();
// 配置锁的常开模式设置 -> 防撬报警
- Future _setLockSetGeneralSetting() async{
+ Future _setLockSetGeneralSetting() async {
final LoginEntity entity = await ApiRepository.to.setBurglarAlarmData(
lockId: state.lockSetInfoData.value.lockId!,
- antiPrySwitch:state.burglarAlarmEnable.value == 1 ? 0 : 1, // 1-开启、2-关闭;
+ antiPrySwitch: state.burglarAlarmEnable.value == 1 ? 0 : 1, // 1-开启、2-关闭;
);
- if(entity.errorCode!.codeIsSuccessful){
- // eventBus.fire(RefreshLockListInfoDataEvent());
+ if (entity.errorCode!.codeIsSuccessful) {
+ eventBus.fire(RefreshLockListInfoDataEvent());
- state.burglarAlarmEnable.value = state.burglarAlarmEnable.value == 1 ? 0 : 1;
- state.lockSetInfoData.value.lockSettingInfo!.antiPrySwitch = state.burglarAlarmEnable.value;
- showToast('操作成功'.tr, something: (){
- eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
+ state.burglarAlarmEnable.value =
+ state.burglarAlarmEnable.value == 1 ? 0 : 1;
+ state.lockSetInfoData.value.lockSettingInfo!.antiPrySwitch =
+ state.burglarAlarmEnable.value;
+ showToast('操作成功'.tr, something: () {
+ eventBus
+ .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
});
}
}
// 获取解析后的数据
late StreamSubscription _replySubscription;
+
void _initReplySubscription() {
- _replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) {
- if(reply is SetSupportFunctionsNoParametersReply) {
+ _replySubscription =
+ EventBusManager().eventBus!.on().listen((Reply reply) {
+ if (reply is SetSupportFunctionsNoParametersReply) {
_replySetSupportFunctionsWithParameters(reply);
}
@@ -71,7 +75,7 @@ class BurglarAlarmLogic extends BaseGetXController{
// 设置自动落锁数据解析
Future _replySetSupportFunctionsWithParameters(Reply reply) async {
final int status = reply.data[2];
- switch(status){
+ switch (status) {
case 0x00:
//成功
state.sureBtnState.value = 0;
@@ -91,41 +95,47 @@ class BurglarAlarmLogic extends BaseGetXController{
// 设置支持功能(带参数)
Future sendBurglarAlarm() async {
- if(state.sureBtnState.value == 1){
+ if (state.sureBtnState.value == 1) {
return;
}
state.sureBtnState.value = 1;
EasyLoading.show();
- showBlueConnetctToastTimer(action: (){
+ showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName,
+ (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
- final List? privateKey = await Storage.getStringList(saveBluePrivateKey);
- final List getPrivateKeyList = changeStringListToIntList(privateKey!);
+ final List? privateKey =
+ await Storage.getStringList(saveBluePrivateKey);
+ final List getPrivateKeyList =
+ changeStringListToIntList(privateKey!);
final List? token = await Storage.getStringList(saveBlueToken);
final List getTokenList = changeStringListToIntList(token!);
- final List? publicKey = await Storage.getStringList(saveBluePublicKey);
- final List getPublicKeyList = changeStringListToIntList(publicKey!);
+ final List? publicKey =
+ await Storage.getStringList(saveBluePublicKey);
+ final List getPublicKeyList =
+ changeStringListToIntList(publicKey!);
IoSenderManage.setSupportFunctionsNoParametersCommand(
- keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
- userID: await Storage.getUid(),
- featureBit: 30,
- featureEnable: state.burglarAlarmEnable.value == 1 ? 0 : 1,
- token: getTokenList,
- needAuthor: 1,
- publicKey: getPublicKeyList,
- privateKey: getPrivateKeyList);
+ keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
+ userID: await Storage.getUid(),
+ featureBit: 30,
+ featureEnable: state.burglarAlarmEnable.value == 1 ? 0 : 1,
+ token: getTokenList,
+ needAuthor: 1,
+ publicKey: getPublicKeyList,
+ privateKey: getPrivateKeyList,
+ );
} else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
state.sureBtnState.value = 0;
- if(state.ifCurrentScreen.value == true){
+ if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
}
@@ -152,5 +162,4 @@ class BurglarAlarmLogic extends BaseGetXController{
_replySubscription.cancel();
}
-
}
diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart
index 25c8e43d..6f0a4570 100755
--- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart
+++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_logic.dart
@@ -37,40 +37,46 @@ import 'configuringWifi_state.dart';
class ConfiguringWifiLogic extends BaseGetXController {
final ConfiguringWifiState state = ConfiguringWifiState();
+ final int _configurationTimeout = 60; // 配网超时时间(秒)
+ /// 获取WiFi锁服务IP和端口
Future getWifiLockServiceIpAndPort() async {
- final ConfiguringWifiEntity entity =
- await ApiRepository.to.getWifiLockServiceIpAndPort();
- if (entity.errorCode! == 0) {
- state.configuringWifiEntity.value = entity;
+ try {
+ final ConfiguringWifiEntity entity =
+ await ApiRepository.to.getWifiLockServiceIpAndPort();
+ if (entity.errorCode! == 0) {
+ state.configuringWifiEntity.value = entity;
+ } else {
+ AppLog.log('获取WiFi锁服务IP和端口失败:${entity.errorCode}');
+ }
+ } catch (e) {
+ AppLog.log('获取WiFi锁服务IP和端口异常:$e');
}
}
- void updateNetworkInfo({
+ /// 更新网络信息到服务器
+ Future updateNetworkInfo({
required String peerId,
required String wifiName,
required String secretKey,
required String deviceMac,
required String networkMac,
}) async {
- final LoginEntity entity = await ApiRepository.to.settingDeviceNetwork(
- deviceType: 2,
- deviceMac: deviceMac,
- wifiName: wifiName,
- networkMac: networkMac,
- secretKey: secretKey,
- peerId: peerId,
- );
- if (entity.errorCode!.codeIsSuccessful) {
- // 设置锁的peerID
- StartChartManage().lockNetworkInfo = DeviceNetworkInfo(
+ try {
+ final LoginEntity entity = await ApiRepository.to.settingDeviceNetwork(
+ deviceType: 2,
+ deviceMac: deviceMac,
wifiName: wifiName,
networkMac: networkMac,
secretKey: secretKey,
peerId: peerId,
);
-
- await _getUploadLockSet();
+ return entity;
+ } catch (e) {
+ dismissEasyLoading();
+ state.sureBtnState.value = 0;
+ AppLog.log('网络配置异常:$e');
+ return LoginEntity();
}
}
@@ -84,81 +90,165 @@ class ConfiguringWifiLogic extends BaseGetXController {
if (reply is GatewayConfiguringWifiResultReply) {
_replySenderConfiguringWifiResult(reply);
}
+ // wifi配网命令应答结果
if (reply is GatewayConfiguringWifiReply) {
- _replySenderConfiguringWifiResult(reply);
+ _replySenderConfiguringWifi(reply);
}
if (reply is GatewayGetStatusReply) {
_replyGatewayGetStatusReply(reply);
}
- // if (reply is GatewayGetStatusReply) {
- // _replyStatusInfo(reply);
- // }
// 上传数据获取锁设置
if (reply is UpdataLockSetReply) {
_replyUpdataLockSetReply(reply);
}
- AppLog.log('蓝牙回调处理完毕${EasyLoading.isShow}');
});
}
- // WIFI配网结果
- Future _replySenderConfiguringWifiResult(Reply reply) async {
+ // WIFI配网操作结果处理
+ Future _replySenderConfiguringWifi(Reply reply) async {
final int status = reply.data[2];
- // state.sureBtnState.value = 0;
-
- // 取消loading超时定时器
- state.loadingTimer?.cancel();
- state.loadingTimer = null;
switch (status) {
case 0x00:
- await Storage.removeLockNetWorkInfoCache();
- final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3];
-
- final List secretKeyList =
- reply.data.sublist(5, 5 + secretKeyJsonLength);
- String result = utf8String(secretKeyList);
- // 解析 JSON 字符串为 Map
- Map jsonMap = json.decode(result);
-
- // 提取 peerId
- String? peerId = jsonMap['peerId'];
- String? wifiName = jsonMap['wifiName'];
- String? secretKey = jsonMap['secretKey'];
- String? deviceMac = jsonMap['deviceMac'];
- String? networkMac = jsonMap['networkMac'];
-
- /// 配网成功后,赋值锁的peerId
- StartChartManage().lockPeerId = peerId ?? '';
-
- state.isLoading.value = false;
- // 保存到缓存
- await Storage.saveLockNetWorkInfo(jsonMap);
- // 上报服务器
- updateNetworkInfo(
- peerId: peerId ?? '',
- wifiName: wifiName ?? '',
- secretKey: secretKey ?? '',
- deviceMac: deviceMac ?? '',
- networkMac: networkMac ?? '');
-
+ AppLog.log('wifi配网命令回复结果:成功');
break;
default:
//失败
dismissEasyLoading(); // 关闭loading
- cancelBlueConnetctToastTimer();
- if (state.loadingTimer != null) {
- state.loadingTimer!.cancel();
- state.loadingTimer = null;
- }
-
showToast('配网失败'.tr);
state.isLoading.value = false;
break;
}
}
-// 辅助函数:美化 JSON 输出
+ // WIFI配网结果处理
+ Future _replySenderConfiguringWifiResult(Reply reply) async {
+ final int status = reply.data[2];
+
+ // 收到响应后,取消蓝牙超时计时器
+ cancelBlueConnetctToastTimer();
+
+ switch (status) {
+ case 0x00:
+ // 配网成功 - 不关闭loading,保持状态直到全部完成
+ await Storage.removeLockNetWorkInfoCache();
+
+ try {
+ final int secretKeyJsonLength = (reply.data[4] << 8) + reply.data[3];
+ final List secretKeyList =
+ reply.data.sublist(5, 5 + secretKeyJsonLength);
+ String result = utf8String(secretKeyList);
+
+ AppLog.log('解析配网信息: $result');
+
+ // 解析 JSON 字符串为 Map
+ Map jsonMap = json.decode(result);
+
+ // 提取网络信息
+ String? peerId = jsonMap['peerId'];
+ String? wifiName = jsonMap['wifiName'];
+ String? secretKey = jsonMap['secretKey'];
+ String? deviceMac = jsonMap['deviceMac'];
+ String? networkMac = jsonMap['networkMac'];
+
+ // 验证关键字段
+ if (peerId == null ||
+ peerId.isEmpty ||
+ secretKey == null ||
+ secretKey.isEmpty) {
+ throw Exception('Missing required network information');
+ }
+
+ // 上报服务器 - 注意: sureBtnState 状态将在 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);
+
+ showToast('配网成功'.tr, something: () {
+ state.sureBtnState.value = 0; // 确保重置状态
+ if (state.pageName.value == 'lockSet') {
+ Get.close(2);
+ } else {
+ Get.offAllNamed(Routers.starLockMain);
+ }
+ eventBus.fire(SuccessfulDistributionNetwork());
+ eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true,isUnShowLoading: true));
+ });
+
+ // 获取锁设置
+ _getUploadLockSet();
+ } else {
+ dismissEasyLoading();
+ // showToast('网络配置失败,请重试'.tr);
+ state.sureBtnState.value = 0;
+ }
+ } catch (e) {
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ // showToast('解析配网信息失败,请重试'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ AppLog.log('解析配网信息失败: $e');
+ return; // 添加return阻止后续流程
+ }
+ break;
+
+ case 0x01:
+ // WiFi密码错误
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ // showToast('WiFi密码错误,请重新输入'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ break;
+
+ case 0x02:
+ // 找不到WiFi
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ // showToast('找不到该WiFi网络,请确认WiFi名称正确'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ break;
+
+ case 0x03:
+ // 网络连接超时
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ // showToast('连接WiFi超时,请确保网络信号良好'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ break;
+
+ default:
+ // 其他错误
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ // showToast('配网失败 (错误码: $status),请重试'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ break;
+ }
+ }
+
+ // 辅助函数:美化 JSON 输出
String prettyPrintJson(String jsonString) {
var jsonObject = json.decode(jsonString);
return JsonEncoder.withIndent(' ').convert(jsonObject);
@@ -168,80 +258,111 @@ class ConfiguringWifiLogic extends BaseGetXController {
Future senderConfiguringWifiAction() async {
AppLog.log('开始配网${EasyLoading.isShow}');
- if (state.isLoading.isTrue) {
+ if (state.sureBtnState.value == 1) {
AppLog.log('正在配网中请勿重复点击');
return;
}
- if (state.wifiNameController.text.isEmpty) {
- showToast('请输入wifi名称'.tr);
+
+ // 获取网关配置信息
+ try {
+ final GetGatewayConfigurationEntity entity = await ApiRepository.to
+ .getGatewayConfigurationNotLoading(timeout: _configurationTimeout);
+ if (entity.errorCode!.codeIsSuccessful) {
+ state.getGatewayConfigurationStr = entity.data ?? '';
+ } else {
+ // showToast('获取网关配置失败,请重试'.tr);
+ AppLog.log('获取网关配置失败,请重试');
+ return;
+ }
+
+ // 判断是否登录账户
+ final loginData = await Storage.getLoginData();
+ if (loginData == null) {
+ AppLog.log('未检测到登录信息,请重新登录'.tr);
+ return;
+ }
+
+ // 获取app用户的peerId
+ String appPeerId = loginData.starchart?.starchartId ?? '';
+ if (appPeerId.isEmpty) {
+ AppLog.log('用户ID获取失败,请重新登录'.tr);
+ return;
+ }
+
+ // 处理配置字符串
+ if (state.getGatewayConfigurationStr.isNotEmpty) {
+ // 解析 JSON 字符串为 Map
+ Map jsonMap =
+ json.decode(state.getGatewayConfigurationStr);
+
+ // 移除指定的键
+ jsonMap.remove("starCloudUrl");
+ jsonMap.remove("starLockPeerId");
+
+ // 追加新的键值对
+ jsonMap['userPeerld'] = appPeerId;
+
+ // 将 Map 转换回 JSON 字符串
+ state.getGatewayConfigurationStr =
+ json.encode(jsonMap).replaceAll(',', ',\n');
+
+ // 确保格式化输出
+ state.getGatewayConfigurationStr =
+ prettyPrintJson(state.getGatewayConfigurationStr);
+ } else {
+ // 如果为空,则直接赋值
+ state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
+ }
+ } catch (e) {
+ AppLog.log('网关配置准备失败:${e.toString()}'.tr);
return;
}
- if (state.wifiPWDController.text.isEmpty) {
- showToast('请输入WiFi密码'.tr);
- return;
- }
- // if (state.sureBtnState.value == 1) {
- // return;
- // }
- // state.sureBtnState.value = 1;
+ // 先设置sureBtnState状态,以禁用按钮
+ state.sureBtnState.value = 1;
- final GetGatewayConfigurationEntity entity =
- await ApiRepository.to.getGatewayConfigurationNotLoading(timeout: 60);
- if (entity.errorCode!.codeIsSuccessful) {
- state.getGatewayConfigurationStr = entity.data ?? '';
+ // 显示loading,如果已经显示则不再重复显示
+ if (!EasyLoading.isShow) {
+ showEasyLoading();
}
- // 判断是否登录账户
- final loginData = await Storage.getLoginData();
-
- // 获取app用户的peerId
- String appPeerId = loginData?.starchart?.starchartId ?? '';
- // 如果已有值,则追加
- if (state.getGatewayConfigurationStr.isNotEmpty) {
- // 解析 JSON 字符串为 Map
- Map jsonMap =
- json.decode(state.getGatewayConfigurationStr);
-
- // 移除指定的键
- jsonMap.remove("starCloudUrl");
- jsonMap.remove("starLockPeerId");
-
- // 追加新的键值对
- jsonMap['userPeerld'] = appPeerId;
-
- // 将 Map 转换回 JSON 字符串
- state.getGatewayConfigurationStr =
- json.encode(jsonMap).replaceAll(',', ',\n');
-
- // 确保格式化输出
- state.getGatewayConfigurationStr =
- prettyPrintJson(state.getGatewayConfigurationStr);
- } else {
- // 如果为空,则直接赋值
- state.getGatewayConfigurationStr = "{\"userPeerld\": \"$appPeerId\"}";
- }
- showEasyLoading();
- showBlueConnetctToastTimer(action: () {
- dismissEasyLoading();
- state.isLoading.value = false;
- });
+ // 设置蓝牙操作超时处理
+ showBlueConnetctToastTimer(
+ action: () {
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ state.sureBtnState.value = 0; // 连接超时时重置状态
+ },
+ outTimer: 30,
+ );
// 发送配网指令
BlueManage().blueSendData(
BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
- IoSenderManage.gatewayConfiguringWifiCommand(
- ssid: state.wifiNameController.text,
- password: state.wifiPWDController.text,
- gatewayConfigurationStr: state.getGatewayConfigurationStr,
- );
+ try {
+ IoSenderManage.gatewayConfiguringWifiCommand(
+ ssid: state.wifiNameController.text,
+ password: state.wifiPWDController.text,
+ gatewayConfigurationStr: state.getGatewayConfigurationStr,
+ );
+ // 注意:此处不要重置sureBtnState状态,等待配网结果回调
+ } catch (e) {
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
+ cancelBlueConnetctToastTimer();
+ state.sureBtnState.value = 0; // 发送命令失败时重置状态
+ // showToast('发送配网指令失败:${e.toString()}'.tr);
+ }
} else if (connectionState == BluetoothConnectionState.disconnected) {
- dismissEasyLoading();
+ if (EasyLoading.isShow) {
+ dismissEasyLoading();
+ }
cancelBlueConnetctToastTimer();
- state.isLoading.value = false;
- // state.sureBtnState.value = 0;
+ state.sureBtnState.value = 0; // 蓝牙断开时重置状态
if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast();
}
@@ -249,7 +370,6 @@ class ConfiguringWifiLogic extends BaseGetXController {
},
isAddEquipment: false,
);
- state.isLoading.value = true;
}
// 获取设备状态
@@ -278,11 +398,15 @@ class ConfiguringWifiLogic extends BaseGetXController {
final NetworkInfo _networkInfo = NetworkInfo();
Future getWifiName() async {
- String ssid = '';
- ssid = (await _networkInfo.getWifiName())!;
- ssid = ssid ?? '';
- ssid = ssid.replaceAll(r'"', '');
- return ssid ?? '';
+ try {
+ String? ssid = await _networkInfo.getWifiName();
+ ssid = ssid ?? '';
+ ssid = ssid.replaceAll(r'"', '');
+ return ssid;
+ } catch (e) {
+ AppLog.log('获取WiFi名称失败: $e');
+ return '';
+ }
}
///定位权限
@@ -308,17 +432,12 @@ class ConfiguringWifiLogic extends BaseGetXController {
getWifiLockServiceIpAndPort();
_initReplySubscription();
- // getDevicesStatusAction();
- }
-
- @override
- void onInit() {
- super.onInit();
}
@override
void onClose() {
_replySubscription.cancel();
+ cancelBlueConnetctToastTimer(); // 确保取消蓝牙超时计时器
super.onClose();
}
@@ -330,8 +449,6 @@ class ConfiguringWifiLogic extends BaseGetXController {
switch (status) {
case 0x00:
//成功
- // state.sureBtnState.value = 0;
-
final GetGatewayInfoModel gatewayModel = GetGatewayInfoModel();
// 网关MAC地址
int index = 3;
@@ -372,25 +489,16 @@ class ConfiguringWifiLogic extends BaseGetXController {
default:
//失败
dismissEasyLoading();
- showToast('配网失败'.tr);
- if (state.loadingTimer != null) {
- state.loadingTimer!.cancel();
- state.loadingTimer = null;
- }
+ // showToast('获取设备状态失败'.tr);
break;
}
}
// 上传数据获取设置
Future _getUploadLockSet() async {
- showEasyLoading();
- showBlueConnetctToastTimer(action: () {
- dismissEasyLoading();
- });
-
final List? token = await Storage.getStringList(saveBlueToken);
final List getTokenList = changeStringListToIntList(token!);
-
+ // 蓝牙获取锁设置
await _uploadLockSet(getTokenList);
}
@@ -398,44 +506,74 @@ class ConfiguringWifiLogic extends BaseGetXController {
Future _uploadLockSet(List token) async {
final List? privateKey =
await Storage.getStringList(saveBluePrivateKey);
- final List getPrivateKeyList = changeStringListToIntList(privateKey!);
+ if (privateKey == null || privateKey.isEmpty) {
+ throw Exception('Private key is empty');
+ }
+ final List getPrivateKeyList = changeStringListToIntList(privateKey);
final List? signKey = await Storage.getStringList(saveBlueSignKey);
- final List signKeyDataList = changeStringListToIntList(signKey!);
+ if (signKey == null || signKey.isEmpty) {
+ throw Exception('Sign key is empty');
+ }
+ final List signKeyDataList = changeStringListToIntList(signKey);
- IoSenderManage.updataLockSetCommand(
- lockID: BlueManage().connectDeviceName,
- userID: await Storage.getUid(),
- token: token,
- needAuthor: 1,
- signKey: signKeyDataList,
- privateKey: getPrivateKeyList);
+ BlueManage().blueSendData(BlueManage().connectDeviceName,
+ (BluetoothConnectionState connectionState) async {
+ if (connectionState == BluetoothConnectionState.connected) {
+ IoSenderManage.updataLockSetCommand(
+ lockID: BlueManage().connectDeviceName,
+ userID: await Storage.getUid(),
+ token: token,
+ needAuthor: 1,
+ signKey: signKeyDataList,
+ privateKey: getPrivateKeyList,
+ );
+ } else if (connectionState == BluetoothConnectionState.disconnected) {
+ dismissEasyLoading();
+ cancelBlueConnetctToastTimer();
+ if (state.ifCurrentScreen.value == true) {
+ showBlueConnetctToast();
+ }
+ }
+ }, isAddEquipment: true);
}
// 上传数据获取锁设置解析
Future _replyUpdataLockSetReply(Reply reply) async {
final int status = reply.data[2];
- dismissEasyLoading(); // 关闭loading
+ // 保持loading状态直到整个过程完成
cancelBlueConnetctToastTimer();
+
switch (status) {
case 0x00:
await _lockDataUpload(
uploadType: 1,
recordType: 0,
records: reply.data.sublist(7, reply.data.length));
-
break;
+
case 0x06:
- //无权限
- final List token = reply.data.sublist(3, 7);
- final List saveStrList = changeIntListToStringList(token);
- Storage.setStringList(saveBlueToken, saveStrList);
-
- _uploadLockSet(token);
+ //无权限,尝试重新获取token
+ try {
+ final List token = reply.data.sublist(3, 7);
+ final List saveStrList = changeIntListToStringList(token);
+ await Storage.setStringList(saveBlueToken, saveStrList);
+ _uploadLockSet(token);
+ } catch (e) {
+ if (EasyLoading.isShow) {
+ dismissEasyLoading(); // 错误时关闭loading
+ }
+ // showToast('获取设置权限失败:${e.toString()}'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
+ }
break;
+
default:
- dismissEasyLoading();
- cancelBlueConnetctToastTimer();
+ if (EasyLoading.isShow) {
+ dismissEasyLoading(); // 错误时关闭loading
+ }
+ // showToast('获取锁设置失败 (错误码: $status)'.tr);
+ state.sureBtnState.value = 0; // 确保重置状态
break;
}
}
@@ -451,19 +589,10 @@ class ConfiguringWifiLogic extends BaseGetXController {
recordType: recordType,
records: records,
isUnShowLoading: true);
- if (entity.errorCode!.codeIsSuccessful) {
- showToast('配网成功'.tr, something: () {
- state.isLoading.value = false;
- if (state.pageName.value == 'lockSet') {
- Get.close(2);
- } else {
- Get.offAllNamed(Routers.starLockMain);
- }
- eventBus
- .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
- eventBus.fire(SuccessfulDistributionNetwork());
- });
+ if (entity.errorCode!.codeIsSuccessful) {
+ eventBus
+ .fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
}
}
}
diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart
index ed653308..33a38066 100755
--- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart
+++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_page.dart
@@ -25,6 +25,9 @@ class _ConfiguringWifiPageState extends State
final ConfiguringWifiLogic logic = Get.put(ConfiguringWifiLogic());
final ConfiguringWifiState state = Get.find().state;
+ // 添加密码可见性控制
+ final RxBool _obscureText = true.obs;
+
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -39,19 +42,36 @@ class _ConfiguringWifiPageState extends State
'WiFi名称'.tr, '请输入WiFi名字'.tr, state.wifiNameController),
Container(
width: 1.sw, height: 1.h, color: AppColors.mainBackgroundColor),
- configuringWifiTFWidget(
+ configuringWifiPasswordTFWidget(
'WiFi密码'.tr, '请输入WiFi密码'.tr, state.wifiPWDController),
SizedBox(
height: 50.h,
),
Obx(
() => SubmitBtn(
- btnName: '确定'.tr,
- isDisabled: state.isLoading.isFalse,
- onClick: state.isLoading.isTrue
+ btnName: state.sureBtnState.value == 1 ? '配置中...'.tr : '确定'.tr,
+ // 当sureBtnState为1时按钮不可用
+ isDisabled: state.sureBtnState.value == 0,
+ onClick: state.sureBtnState.value == 1
? null
: () {
FocusScope.of(context).requestFocus(FocusNode());
+ // 验证输入
+ if (state.wifiNameController.text.isEmpty) {
+ logic.showToast('请输入WiFi名称'.tr);
+ return;
+ }
+ if (state.wifiPWDController.text.isEmpty) {
+ logic.showToast('请输入WiFi密码'.tr);
+ return;
+ }
+ // 检查WiFi名称是否包含5G关键字
+ if (state.wifiNameController.text
+ .toLowerCase()
+ .contains('5g')) {
+ logic.showToast('请确保使用2.4GHz WiFi网络'.tr);
+ return;
+ }
logic.senderConfiguringWifiAction();
},
),
@@ -86,7 +106,22 @@ class _ConfiguringWifiPageState extends State
);
}
- // 接受者信息输入框
+ Widget configuringWifiPasswordTFWidget(
+ String titleStr, String rightTitle, TextEditingController controller) {
+ return Column(
+ children: [
+ Container(height: 10.h),
+ CommonItem(
+ leftTitel: titleStr,
+ rightTitle: '',
+ isHaveRightWidget: true,
+ rightWidget: getPasswordTFWidget(rightTitle, controller)),
+ Container(height: 10.h),
+ ],
+ );
+ }
+
+ // 普通输入框
Widget getTFWidget(String tfStr, TextEditingController controller) {
return Container(
height: 65.h,
@@ -95,18 +130,14 @@ class _ConfiguringWifiPageState extends State
children: [
Expanded(
child: TextField(
- //输入框一行
maxLines: 1,
inputFormatters: [
FilteringTextInputFormatter.deny('\n'),
- // LengthLimitingTextInputFormatter(30),
],
controller: controller,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
- //输入里面输入文字内边距设置
- // contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr,
hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(
@@ -135,6 +166,61 @@ class _ConfiguringWifiPageState extends State
);
}
+ // 密码输入框
+ Widget getPasswordTFWidget(String tfStr, TextEditingController controller) {
+ return Container(
+ height: 65.h,
+ width: 300.w,
+ child: Row(
+ children: [
+ Expanded(
+ child: Obx(
+ () => TextField(
+ maxLines: 1,
+ obscureText: _obscureText.value,
+ inputFormatters: [
+ FilteringTextInputFormatter.deny('\n'),
+ ],
+ controller: controller,
+ autofocus: false,
+ textAlign: TextAlign.end,
+ decoration: InputDecoration(
+ hintText: tfStr,
+ hintStyle: TextStyle(fontSize: 22.sp),
+ focusedBorder: const OutlineInputBorder(
+ borderSide:
+ BorderSide(width: 0, color: Colors.transparent)),
+ disabledBorder: const OutlineInputBorder(
+ borderSide:
+ BorderSide(width: 0, color: Colors.transparent)),
+ enabledBorder: const OutlineInputBorder(
+ borderSide:
+ BorderSide(width: 0, color: Colors.transparent)),
+ border: const OutlineInputBorder(
+ borderSide:
+ BorderSide(width: 0, color: Colors.transparent)),
+ contentPadding: const EdgeInsets.symmetric(vertical: 0),
+ ),
+ style: TextStyle(
+ fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
+ ),
+ ),
+ ),
+ IconButton(
+ icon: Icon(
+ _obscureText.value ? Icons.visibility_off : Icons.visibility,
+ color: Colors.grey,
+ size: 24.sp,
+ ),
+ onPressed: () {
+ _obscureText.value = !_obscureText.value;
+ },
+ ),
+ ],
+ ),
+ );
+ }
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
diff --git a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart
index 513fede2..350a2863 100755
--- a/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart
+++ b/lib/main/lockDetail/lockSet/configuringWifi/configuringWifi/configuringWifi_state.dart
@@ -1,5 +1,3 @@
-import 'dart:async';
-
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:network_info_plus/network_info_plus.dart';
@@ -33,5 +31,4 @@ class ConfiguringWifiState {
String getGatewayConfigurationStr = '';
RxBool isLoading = false.obs;
- Timer? loadingTimer;
}
diff --git a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart
index 8f95204e..93532323 100755
--- a/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart
+++ b/lib/main/lockDetail/lockSet/configuringWifi/wifiList/wifiList_logic.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
+import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/blue/io_gateway/io_gateway_getWifiList.dart';
import 'package:star_lock/blue/io_protocol/io_getWifiList.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
@@ -20,7 +21,9 @@ class WifiListLogic extends BaseGetXController {
// 获取解析后的数据
late StreamSubscription _replySubscription;
+ Timer? _connectionTimer;
+ /// 初始化订阅,监听设备响应
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on().listen((Reply reply) {
@@ -31,78 +34,130 @@ class WifiListLogic extends BaseGetXController {
if (reply is GatewayGetWifiListReply) {
_replyGetWifiListParameters(reply);
}
+ }, onError: (error) {
+ // 处理CRC校验失败等错误
+ AppLog.log('WiFi列表获取过程中发生错误: $error');
+
+ // 取消loading状态,显示错误提示
+ dismissEasyLoading();
+ cancelBlueConnetctToastTimer();
+
+ // 重置按钮状态,允许重新扫描
+ state.sureBtnState.value = 0;
+
+ // 如果是CRC校验失败,显示特定提示
+ if (error.toString().contains('CRC')) {
+ showToast('数据校验失败,请重新扫描'.tr);
+ } else {
+ showToast('扫描WiFi失败,请重试'.tr);
+ }
});
}
- // 发送获取wifi列表数据解析
+ /// 发送获取wifi列表数据解析
Future _replySendGetWifiParameters(Reply reply) async {
final int status = reply.data[2];
switch (status) {
case 0x00:
- //成功
- showEasyLoading();
+ //成功 - 不显示loading框,UI中已经有进度指示器
cancelBlueConnetctToastTimer();
- Future.delayed(5.seconds, dismissEasyLoading);
break;
case 0x06:
// 需要鉴权
+ dismissEasyLoading();
+ AppLog.log('需要设备鉴权,请重试'.tr);
+ state.sureBtnState.value = 0;
break;
default:
+ // 处理其他错误状态
+ dismissEasyLoading();
+ AppLog.log('获取WiFi列表失败,错误码:$status'.tr);
+ state.sureBtnState.value = 0;
break;
}
}
- // 获取WiFi数据解析
+ /// 获取WiFi数据解析
Future _replyGetWifiListParameters(Reply reply) async {
final int status = reply.data[2];
switch (status) {
case 0x00:
//成功
- // showEasyLoading();
dismissEasyLoading();
state.sureBtnState.value = 0;
if (reply.data[3] > 0) {
reply.data.removeRange(0, 4);
- // 把得到的数据按33位分割成数组 然后塞进一个新的数组里面
+ // 把得到的数据按33位分割成数组然后处理
final List> getList = splitList(reply.data, 33);
final List