feat:新增 ota 升级页面信息显示

This commit is contained in:
anfe 2024-05-13 14:08:21 +08:00
parent 9b6d8285e3
commit c4c95eaa59
10 changed files with 800 additions and 775 deletions

View File

@ -833,5 +833,11 @@
"姓名":"Name", "姓名":"Name",
"发送":"Send", "发送":"Send",
"请确认姓名全名和身份证号码是否正确":"Please confirm that the full name and ID number are correct", "请确认姓名全名和身份证号码是否正确":"Please confirm that the full name and ID number are correct",
"传输期间请勿离开当前页面":"Do not leave the current page during transfer" "传输期间请勿离开当前页面":"Do not leave the current page during transfer",
"机型": "models",
"硬件版本": "Hardware version",
"固件版本": "Firmware version",
"手动升级": "Manual upgrade",
"设备连接中...": "Device Connecting...",
"升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading"
} }

View File

@ -861,5 +861,11 @@
"姓名":"姓名", "姓名":"姓名",
"发送":"发送", "发送":"发送",
"请确认姓名全名和身份证号码是否正确":"请确认姓名全名和身份证号码是否正确", "请确认姓名全名和身份证号码是否正确":"请确认姓名全名和身份证号码是否正确",
"传输期间请勿离开当前页面":"传输期间请勿离开当前页面" "传输期间请勿离开当前页面":"传输期间请勿离开当前页面",
"机型": "机型",
"硬件版本": "硬件版本",
"固件版本": "固件版本",
"手动升级": "手动升级",
"设备连接中...": "设备连接中...",
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级"
} }

File diff suppressed because it is too large Load Diff

View File

@ -280,6 +280,17 @@ class BlueManage {
} }
} }
} }
// String listStr = scanDevices
// // .where((element) =>
// // element.advertisementData.advName == 'TMH_dc8f928369ed')
// .map((e) => 'advName:${e.advertisementData.advName} '
// 'serviceUuids:${e.advertisementData.serviceUuids} '
// '是否被重置:${e.advertisementData.serviceUuids[0].toString()[31]}')
// .join(',')
// .toString();
// AppLog.log('--->扫描到的设备 ${listStr} ');
scanDevicesCallBack(scanDevices); scanDevicesCallBack(scanDevices);
// EventBusManager().eventBusFir(scanDevices); // EventBusManager().eventBusFir(scanDevices);
// FlutterBluePlus.stopScan(); // FlutterBluePlus.stopScan();
@ -364,7 +375,7 @@ class BlueManage {
(d.device.platformName == deviceName) || (d.device.platformName == deviceName) ||
(d.advertisementData.advName == deviceName)); (d.advertisementData.advName == deviceName));
ScanResult? scanResult;//使 ScanResult? scanResult; //使
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
// //
connectDeviceMacAddress = connectDeviceMacAddress =
@ -381,7 +392,7 @@ class BlueManage {
} }
// AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); // AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
// stopScan(); // stopScan();
if (scanResult == null ||connectDeviceMacAddress.isEmpty) { if (scanResult == null || connectDeviceMacAddress.isEmpty) {
// connectStateCallBack(BluetoothConnectionState.disconnected!); // connectStateCallBack(BluetoothConnectionState.disconnected!);
return; return;
} }

View File

@ -90,7 +90,7 @@ abstract class Reply{
case 0x0e: case 0x0e:
// //
showErrorMessage("钥匙已存在"); showErrorMessage("钥匙已存在");
AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙无效"); AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在");
break; break;
case 0x0f: case 0x0f:
// //
@ -124,7 +124,7 @@ abstract class Reply{
break; break;
case 0xff: case 0xff:
// //
AppLog.log("$logTag ${commandType!.typeName} 0xff"); AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误");
showErrorMessage("异常,未知错误"); showErrorMessage("异常,未知错误");
break; break;
default: default:

View File

@ -123,10 +123,6 @@ class LockDetailLogic extends BaseGetXController {
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
break;
case 0x07:
//
break; break;
case 0x16: case 0x16:
// ... // ...
@ -138,6 +134,7 @@ class LockDetailLogic extends BaseGetXController {
break; break;
default: default:
// //
cancelBlueConnetctToastTimer();
break; break;
} }
} }

View File

@ -6,6 +6,7 @@ import 'dart:typed_data';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/blue/blue_manage.dart'; import 'package:star_lock/blue/blue_manage.dart';
@ -18,6 +19,7 @@ import 'package:star_lock/blue/sender_manage.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_logic.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_logic.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/showTipView.dart';
import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/widget/permission/permission_dialog.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart';
@ -67,7 +69,15 @@ class LockEscalationLogic extends BaseGetXController {
} }
String md5Str = md5.convert(otaBin!).toString(); String md5Str = md5.convert(otaBin!).toString();
headJson!['fwMd5'] = md5Str; headJson!['fwMd5'] = md5Str;
blueOTAUpgrade(headJson!, [0, 0, 0, 0]); ShowTipView().showIosTipWithContentDialog("升级过程中无法开锁,请先开锁后再升级".tr,
() async {
blueOTAUpgrade(headJson!, [0, 0, 0, 0]);
EasyLoading.show(
status: '设备连接中...'.tr, maskType: EasyLoadingMaskType.black);
Future.delayed(const Duration(seconds: 4), () {
EasyLoading.dismiss();
});
});
} }
// ota // ota
@ -217,7 +227,7 @@ class LockEscalationLogic extends BaseGetXController {
Uint8List bin = data.sublist(binOffset.toInt(), data.length); Uint8List bin = data.sublist(binOffset.toInt(), data.length);
//md5 //md5
String md5Str = md5.convert(bin).toString().toUpperCase(); String md5Str = md5.convert(bin).toString().toUpperCase();
AppLog.log('---> $md5Str ${meta['fwMd5']}'); AppLog.log('固件 md5 检验md5$md5Str 固件信息 md5${meta['fwMd5']}');
if (md5Str != meta['fwMd5']) { if (md5Str != meta['fwMd5']) {
showToast('文件校验失败 0x02'.tr); showToast('文件校验失败 0x02'.tr);
return null; return null;

View File

@ -31,136 +31,161 @@ class _LockEscalationPageState extends State<LockEscalationPage> {
), ),
body: Container( body: Container(
padding: EdgeInsets.all(30.w), padding: EdgeInsets.all(30.w),
child: Column( child: Obx(() {
children: [ return updateView(logic);
Obx(() { }),
return logic.state.otaUpdateIng.value
? PopScope(
canPop: false,
onPopInvoked: (didPop) async {
if (logic.state.otaUpdateIng.value) {
logic.closeOTADAta();
}
},
child: const SizedBox(),
)
: const SizedBox();
}),
SizedBox(
height: 60.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'images/main/icon_main_lockSet_lockEscalation.png',
width: 36.w,
height: 36.w,
),
SizedBox(
width: 10.w,
),
Text(
// TranslationLoader.lanKeys!.haveNewVersion!.tr,
"未发现新版本",
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w600),
)
],
),
SizedBox(
height: 30.h,
),
Text(
"${TranslationLoader.lanKeys!.currentVersion!.tr}1.0.0",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(
height: 40.h,
),
Obx(() {
return !logic.state.otaUpdateIng.value
? SubmitBtn(
btnName: TranslationLoader.lanKeys!.upgrade!.tr,
onClick: () {})
: SizedBox();
}),
SizedBox(
height: 10.h,
),
Obx(() {
return !logic.state.otaUpdateIng.value
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
// Container(
// margin: EdgeInsets.only(top: 8, bottom: 8),
// width: Get.width,
// child: Center(
// child: Text(
// // "${TranslationLoader.lanKeys!.newVersion!.tr}1.0.1",
// "未发现新版本",
// style: TextStyle(
// color: AppColors.mainColor,
// fontSize: 18.sp),
// ),
// ),
// ),
GestureDetector(
onTap: () {
logic.otaUpdate();
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'手动升级',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 18.sp,
fontWeight: FontWeight.w400),
),
),
)
],
)
: Padding(
padding: EdgeInsets.symmetric(
horizontal: 50.w, vertical: 15.h),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'固件传输中',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 18.sp,
fontWeight: FontWeight.w400),
),
SizedBox(
width: 10.w,
),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(10.r)),
child: LinearProgressIndicator(
value: logic
.state.otaProgress.value, // 50%
backgroundColor: Colors.grey[200],
valueColor:
AlwaysStoppedAnimation<Color>(
AppColors.mainColor),
),
),
),
],
),
);
}),
],
),
)); ));
}); });
} }
Widget updateView(LockEscalationLogic logic) {
if (logic.state.otaUpdateIng.value) {
return otaUpdate(logic);
}
return defaultUpdate(logic);
}
//
Widget defaultUpdate(LockEscalationLogic logic) {
return Column(
children: [
SizedBox(
height: 60.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'images/main/icon_main_lockSet_lockEscalation.png',
width: 36.w,
height: 36.w,
),
SizedBox(
width: 10.w,
),
Text(
// TranslationLoader.lanKeys!.haveNewVersion!.tr,
"未发现新版本",
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
)
],
),
SizedBox(
height: 30.h,
),
Text(
"${TranslationLoader.lanKeys!.currentVersion!.tr}1.0.0",
style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(
height: 40.h,
),
Obx(() {
return !logic.state.otaUpdateIng.value
? SubmitBtn(
btnName: TranslationLoader.lanKeys!.upgrade!.tr,
onClick: () {})
: SizedBox();
}),
SizedBox(
height: 10.h,
),
Align(
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () {
logic.otaUpdate();
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'手动升级'.tr,
style: TextStyle(
color: AppColors.mainColor,
fontSize: 18.sp,
fontWeight: FontWeight.w400),
),
),
),
),
],
);
}
//ota升级
Widget otaUpdate(LockEscalationLogic logic) {
return Column(
children: [
SizedBox(
height: 20.h,
),
Text(
'${'机型'.tr}${logic.headJson?['platform']}-${logic.headJson?['product']}',
style: TextStyle(
color: AppColors.blackColor,
fontSize: 22.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.h,
),
Text(
'${'硬件版本'.tr}${logic.headJson?['hwVersion']}',
style: TextStyle(
color: AppColors.blackColor,
fontSize: 22.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 10.h,
),
Text(
'${'固件版本'.tr}${logic.headJson?['fwVersion']}',
style: TextStyle(
color: AppColors.blackColor,
fontSize: 22.sp,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 20.h,
),
Text(
'传输期间请勿离开当前页面'.tr,
style: TextStyle(
color: AppColors.blackColor,
fontSize: 20.sp,
fontWeight: FontWeight.w400),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 50.w, vertical: 15.h),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'固件传输中',
style: TextStyle(
color: AppColors.mainColor,
fontSize: 18.sp,
fontWeight: FontWeight.w400),
),
SizedBox(
width: 10.w,
),
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10.r)),
child: LinearProgressIndicator(
value: logic.state.otaProgress.value, // 50%
backgroundColor: Colors.grey[200],
valueColor:
AlwaysStoppedAnimation<Color>(AppColors.mainColor),
),
),
),
],
),
),
],
);
}
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -27,12 +26,17 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(barTitle: TranslationLoader.lanKeys!.addLock!.tr, haveBack:true, backgroundColor: AppColors.mainColor), appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.addLock!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column( body: Column(
// mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox(height: 80.h,), SizedBox(
height: 80.h,
),
Container( Container(
margin: EdgeInsets.only(left: 50.w, right: 50.w), margin: EdgeInsets.only(left: 50.w, right: 50.w),
width: 1.sw, width: 1.sw,
@ -40,22 +44,29 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Flexible( Flexible(
child: Text(TranslationLoader.lanKeys!.addSuccessfullyPleaseRename!.tr, style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w500)) child: Text(
), TranslationLoader
.lanKeys!.addSuccessfullyPleaseRename!.tr,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w500))),
], ],
), ),
), ),
SizedBox(height: 80.h,), SizedBox(
height: 80.h,
),
Container( Container(
height: 80.h, height: 80.h,
// color: Colors.red, // color: Colors.red,
padding: EdgeInsets.only(left: 50.w, right: 50.w), padding: EdgeInsets.only(left: 50.w, right: 50.w),
child: TextField( child: TextField(
controller: state.aliNameController, focusNode: state.focusNode,
onChanged: (v){ autofocus: true,
controller: state.aliNameController,
onChanged: (v) {
state.aliName.value = v; state.aliName.value = v;
}, },
textAlign:TextAlign.center, textAlign: TextAlign.center,
inputFormatters: [ inputFormatters: [
LengthLimitingTextInputFormatter(32), LengthLimitingTextInputFormatter(32),
], ],
@ -63,58 +74,44 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
decoration: InputDecoration( decoration: InputDecoration(
hintText: '请填写信息'.tr, hintText: '请填写信息'.tr,
hintStyle: TextStyle( hintStyle: TextStyle(
// height: 1.1, // height: 1.1,
fontSize: 24.sp, fontSize: 24.sp,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: const Color(0xFF999999) color: const Color(0xFF999999)),
),
border: OutlineInputBorder( border: OutlineInputBorder(
///
borderRadius: BorderRadius.all(Radius.circular(50.h)), borderRadius: BorderRadius.all(Radius.circular(50.h)),
///
borderSide: BorderSide( borderSide: BorderSide(
///
color: AppColors.mainColor, color: AppColors.mainColor,
///
width: 1, width: 1,
), ),
), ),
///
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
///
borderRadius: BorderRadius.all(Radius.circular(50.h)), borderRadius: BorderRadius.all(Radius.circular(50.h)),
///
borderSide: BorderSide( borderSide: BorderSide(
///
color: AppColors.mainColor, color: AppColors.mainColor,
///
width: 1, width: 1,
), ),
), ),
) )),
), ),
SizedBox(
height: 120.h,
), ),
SizedBox(height: 120.h,),
SubmitBtn( SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr, btnName: TranslationLoader.lanKeys!.sure!.tr,
borderRadius: 20.w, borderRadius: 20.w,
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: 50.w, left: 50.w,
right: 50.w, right: 50.w,
// top: 30.w, // top: 30.w,
// bottom: 30.w // bottom: 30.w
), ),
padding: EdgeInsets.only( padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
top: 25.w, onClick: () {
bottom: 25.w
),
onClick: (){
logic.addUserConnectBlue(); logic.addUserConnectBlue();
} }),
),
], ],
) ));
);
} }
@override @override
@ -130,6 +127,7 @@ class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
void dispose() { void dispose() {
// TODO: implement dispose // TODO: implement dispose
/// ///
state.focusNode.unfocus();
AppRouteObserver().routeObserver.unsubscribe(this); AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose(); super.dispose();
BlueManage().stopScan(); BlueManage().stopScan();

View File

@ -1,16 +1,15 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
class SaveLockState { class SaveLockState {
var aliName = ''.obs; var aliName = ''.obs;
var pwdTimestamp= 0.obs; var pwdTimestamp = 0.obs;
var addressInfo = {}.obs; var addressInfo = {}.obs;
TextEditingController aliNameController = TextEditingController(); TextEditingController aliNameController = TextEditingController();
FocusNode focusNode = FocusNode();
var lockUserNo = 0; var lockUserNo = 0;
var lockInfo = {}; var lockInfo = {};
@ -20,15 +19,16 @@ class SaveLockState {
var isFromMap = 0; // 0: 1: var isFromMap = 0; // 0: 1:
var ifCurrentScreen = true.obs; // , var ifCurrentScreen = true.obs; // ,
var sureBtnState = 0.obs;// 0 1 var sureBtnState = 0.obs; // 0 1
// //
var adminPasswordTF = TextEditingController(); var adminPasswordTF = TextEditingController();
var adminPassword = ''; var adminPassword = '';
var lockId = 0; var lockId = 0;
SaveLockState() { SaveLockState() {
aliName.value = BlueManage().connectDeviceName; aliName.value = BlueManage().connectDeviceName;
aliNameController.text = aliName.value; aliNameController.text = aliName.value;
Map map = Get.arguments; Map map = Get.arguments;