Merge branch 'master' of https://gitee.com/starlock-cn/app-starlock
This commit is contained in:
commit
84b3042579
@ -107,7 +107,7 @@ android {
|
||||
dimension "flavor-type"
|
||||
applicationId "com.xhjcn.lock"
|
||||
signingConfig signingConfigs.xhj
|
||||
resValue "string", "app_name", "星星锁"
|
||||
resValue "string", "app_name", "鑫锁"
|
||||
manifestPlaceholders.JPUSH_PKGNAME = "com.xhjcn.lock"
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ flavors:
|
||||
bundleId: "com.skychip.lock"
|
||||
xhj:
|
||||
app:
|
||||
name: "星星锁"
|
||||
name: "鑫锁"
|
||||
icon: "assets/icon/xhj.png"
|
||||
android:
|
||||
applicationId: "com.xhjcn.lock"
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
|
||||
FLUTTER_TARGET=lib/main_xhj_full.dart
|
||||
ASSET_PREFIX=xhj
|
||||
BUNDLE_NAME=星星锁
|
||||
BUNDLE_DISPLAY_NAME=星星锁
|
||||
BUNDLE_NAME=鑫锁
|
||||
BUNDLE_DISPLAY_NAME=鑫锁
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
|
||||
FLUTTER_TARGET=lib/main_xhj_full.dart
|
||||
ASSET_PREFIX=xhj
|
||||
BUNDLE_NAME=星星锁
|
||||
BUNDLE_DISPLAY_NAME=星星锁
|
||||
BUNDLE_NAME=鑫锁
|
||||
BUNDLE_DISPLAY_NAME=鑫锁
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
|
||||
FLUTTER_TARGET=lib/main_xhj_lite.dart
|
||||
ASSET_PREFIX=xhj
|
||||
BUNDLE_NAME=星星锁
|
||||
BUNDLE_DISPLAY_NAME=星星锁
|
||||
BUNDLE_NAME=鑫锁
|
||||
BUNDLE_DISPLAY_NAME=鑫锁
|
||||
|
||||
@ -55,53 +55,78 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
data.add(type1);
|
||||
data.add(type2);
|
||||
|
||||
print('---> 指令 : $type1 $type2' );
|
||||
|
||||
// 锁id 40
|
||||
int lockIDLength = utf8.encode(lockID!).length;
|
||||
data.addAll(utf8.encode(lockID!));
|
||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||
|
||||
print('---> 锁id :' + utf8.encode(lockID!).toString());
|
||||
|
||||
//userID 20
|
||||
int userIDLength = utf8.encode(userID!).length;
|
||||
data.addAll(utf8.encode(userID!));
|
||||
data = getFixedLengthList(data, 20 - userIDLength);
|
||||
|
||||
print('---> userID :' + utf8.encode(userID!).toString());
|
||||
|
||||
//platform 2
|
||||
int platform0 = (platform! & 0xFF00) >> 8;
|
||||
int platform1 = platform! & 0xFF;
|
||||
data.add(platform0);
|
||||
data.add(platform1);
|
||||
|
||||
print('---> platform : $platform0 $platform1');
|
||||
|
||||
//product 2
|
||||
int product0 = (product! & 0xFF00) >> 8;
|
||||
int product1 = product! & 0xFF;
|
||||
data.add(product0);
|
||||
data.add(product1);
|
||||
// int product0 = (product! & 0xFF00) >> 8;
|
||||
// int product1 = product! & 0xFF;
|
||||
// data.add(product0);
|
||||
// data.add(product1);
|
||||
data.addAll([0,1]);//先默认是 01
|
||||
|
||||
print('---> platform : ${[0,1]}');
|
||||
|
||||
//HwVersion 20
|
||||
int hwVersionLength = utf8.encode(hwVersion!).length;
|
||||
data.addAll(utf8.encode(hwVersion!));
|
||||
data = getFixedLengthList(data, 20 - hwVersionLength);
|
||||
|
||||
print('---> hwVersion : ${utf8.encode(hwVersion!)}');
|
||||
|
||||
//FwVersion 20
|
||||
int fwVersionLength = utf8.encode(fwVersion!).length;
|
||||
data.addAll(utf8.encode(fwVersion!));
|
||||
data = getFixedLengthList(data, 20 - fwVersionLength);
|
||||
|
||||
print('---> FwVersion : ${utf8.encode(fwVersion!)}');
|
||||
|
||||
//fwSize 4
|
||||
ByteData bytes = ByteData(4); // 创建一个长度为4的字节数据
|
||||
bytes.setInt32(0, fwSize!);
|
||||
List<int> byteList = bytes.buffer.asUint8List();
|
||||
data.addAll(byteList);
|
||||
|
||||
//fwMD5 16
|
||||
int fwMD5Length = utf8.encode(fwMD5!).length;
|
||||
data.addAll(utf8.encode(fwMD5!));
|
||||
data = getFixedLengthList(data, 16 - fwMD5Length);
|
||||
print('---> fwSize : ${byteList}');
|
||||
|
||||
// 创建一个16字节的字节数组
|
||||
Uint8List result = Uint8List(16);
|
||||
// 将每个十六进制字符转换为4位二进制数据,并将其存储到结果字节数组中
|
||||
for (int i = 0; i < fwMD5!.length; i += 2) {
|
||||
String hex = fwMD5!.substring(i, i + 2);
|
||||
int byteValue = int.parse(hex, radix: 16);
|
||||
result[i ~/ 2] = byteValue;
|
||||
}
|
||||
data.addAll(result);
|
||||
print('---> fwMD5 : ${result}');
|
||||
|
||||
// token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0
|
||||
data.addAll(token!);
|
||||
|
||||
print('--->1'+data.toString());
|
||||
print('---> token : ${token}');
|
||||
|
||||
print('--->1' + data.toString());
|
||||
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
@ -120,6 +145,8 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
print('---> ${utf8.encode(keyID!)} ${utf8.encode(userID!)} $token $signKey');
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
|
||||
@ -149,7 +176,7 @@ class OTAUpgradeReply extends Reply {
|
||||
data = dataDetail;
|
||||
token = data.sublist(2, 6);
|
||||
status = data[6];
|
||||
print('--->2'+data.toString());
|
||||
print('--->2' + data.toString());
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ enum CommandType {
|
||||
calibrationTime, // 校时 = 0x30f0
|
||||
readStarLockStatusInfo, //读星锁状态信息 0x3040
|
||||
startOATUpgrade, //OTA升级开始 0x30E0
|
||||
confirmationOTAUpgrade, //OTA升级开始 0x30E1
|
||||
processOTAUpgrade, //OTA升级过程 0x30E2
|
||||
confirmationOTAUpgrade, //OTA升级开始 0x30E2
|
||||
processOTAUpgrade, //OTA升级过程 0x30E1
|
||||
|
||||
generalExtendedCommond, // 通用扩展指令 = 0x3030
|
||||
gecChangeAdministratorPassword, // 通用扩展指令子命令-修改管理员密码 = 2
|
||||
|
||||
@ -74,7 +74,7 @@ class F {
|
||||
case Flavor.sky:
|
||||
return '锁通通';
|
||||
case Flavor.xhj:
|
||||
return '星星锁';
|
||||
return '鑫锁';
|
||||
default:
|
||||
throw Exception('flavor[$name] title not found');
|
||||
}
|
||||
@ -91,7 +91,7 @@ class F {
|
||||
case Flavor.sky:
|
||||
return '锁通通';
|
||||
case Flavor.xhj:
|
||||
return '星星锁';
|
||||
return '鑫锁';
|
||||
default:
|
||||
throw Exception('flavor[$name] title not found');
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
|
||||
import 'package:star_lock/blue/io_reply.dart';
|
||||
import 'package:star_lock/blue/io_tool/io_tool.dart';
|
||||
import 'package:star_lock/blue/io_tool/manager_event_bus.dart';
|
||||
import 'package:star_lock/blue/sender_manage.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_logic.dart';
|
||||
import 'package:star_lock/permission/permission_dialog.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
@ -64,7 +66,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
}
|
||||
String md5Str = md5.convert(otaBin!).toString();
|
||||
headJson!['fwMd5'] = md5Str;
|
||||
blueOTAUpgrade(headJson!, [0,0,0,0]);
|
||||
blueOTAUpgrade(headJson!, [0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
//蓝牙操作 ota 升级
|
||||
@ -74,20 +76,13 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
String lockID = CommonDataManage.shareManager()?.currentLockSetInfoData
|
||||
.lockId
|
||||
?.toString() ??
|
||||
'';
|
||||
String keyID =
|
||||
CommonDataManage.shareManager()?.currentKeyInfo.keyId?.toString() ??
|
||||
'';
|
||||
String uid = await Storage.getUid() ?? '';
|
||||
BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand(
|
||||
lockID: lockID,
|
||||
userID: await Storage.getUid(),
|
||||
keyID: keyID,
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: uid,
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
platform: int.tryParse(data['platform']) ?? 0,
|
||||
product: int.tryParse(data['product']) ?? 0,
|
||||
hwVersion: data['hwVersion'],
|
||||
@ -96,7 +91,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
fwMD5: data['fwMd5'],
|
||||
needAuthor: 1,
|
||||
token: token,
|
||||
signKey: signKeyDataList,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList)
|
||||
.packageData());
|
||||
} else if (deviceConnectionState ==
|
||||
@ -119,10 +114,11 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
}
|
||||
if (otaCount <= otaIndex) {
|
||||
int now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
String msg = '传输完成 时间:${now - startSecond}秒';
|
||||
String msg =
|
||||
'传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex ';
|
||||
closeOTADAta();
|
||||
print(msg);
|
||||
showToast(msg);
|
||||
// showToast(msg);
|
||||
return;
|
||||
}
|
||||
int star = otaIndex * 240;
|
||||
@ -130,10 +126,11 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
if (end > length) {
|
||||
end = length;
|
||||
}
|
||||
int size = end - star;
|
||||
List<int> data = otaBin!.sublist(star, end);
|
||||
state.otaProgress.value = otaIndex / otaCount;
|
||||
await BlueManage().writeCharacteristicWithResponse(
|
||||
ProcessOtaUpgradeCommand(index: otaIndex, size: length, data: data)
|
||||
ProcessOtaUpgradeCommand(index: otaIndex, size: size, data: data)
|
||||
.packageData());
|
||||
}
|
||||
|
||||
@ -173,7 +170,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
Uint8List metaLenList = data.sublist(12, 16);
|
||||
int metaLen = ByteData.sublistView(metaLenList).getUint32(0);
|
||||
if (metaLen < 2 || metaLen > 10240) {
|
||||
showToast('元数据长度错误');
|
||||
showToast('文件校验失败 0x01');
|
||||
return null;
|
||||
}
|
||||
// 读取和解析元数据
|
||||
@ -190,13 +187,14 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
// 获取固件数据部分
|
||||
Uint8List bin = data.sublist(binOffset.toInt(), data.length);
|
||||
//md5 校验有问题,暂时不解析
|
||||
// String md5Str = md5.convert(bin).toString();
|
||||
// if (md5Str != meta['fwMd5']) {
|
||||
// showToast('固件MD5校验失败');
|
||||
// return false;
|
||||
// }
|
||||
String md5Str = md5.convert(bin).toString().toUpperCase();
|
||||
print('---> $md5Str ${meta['fwMd5']}');
|
||||
if (md5Str != meta['fwMd5']) {
|
||||
showToast('文件校验失败 0x02');
|
||||
return null;
|
||||
}
|
||||
if (bin.length != meta['fwSize']) {
|
||||
showToast('固件校验失败');
|
||||
showToast('文件校验失败 0x03');
|
||||
return null;
|
||||
}
|
||||
return bin;
|
||||
@ -216,6 +214,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
if (reply is OTAUpgradeReply) {
|
||||
if (reply.status == 0x00) {
|
||||
//验证通过,开始发送数据包
|
||||
startOTAData();
|
||||
processOtaUpgrade();
|
||||
} else if (reply.status == 0x06) {
|
||||
blueOTAUpgrade(headJson!, reply.token);
|
||||
|
||||
@ -32,9 +32,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# 1.0.27+2024041101:打包提审
|
||||
# 1.0.27+2024041102:打包预发布环境给田总测试
|
||||
# 1.0.28+2024041702:打包给欧阳回归测试
|
||||
# 1.0.27+2024041702 打包星星锁提审华为
|
||||
# 1.0.27+2024041703 打包星星锁提审ios
|
||||
# 1.0.27+2024042204 打包星星锁提审ios与 android
|
||||
# 1.0.27+2024041702 打包鑫锁提审华为
|
||||
# 1.0.27+2024041703 打包鑫锁提审ios
|
||||
# 1.0.27+2024042204 打包鑫锁提审ios与 android
|
||||
|
||||
version: 1.0.27+2024042204
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user