Merge branch 'master_hyx'
This commit is contained in:
commit
5795e7cb0d
@ -22,7 +22,7 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
int? fwSize;
|
||||
String? fwMD5;
|
||||
int? needAuthor;
|
||||
List<int>? publicKey;
|
||||
List<int>? signKey;
|
||||
List<int>? privateKey;
|
||||
List<int>? token;
|
||||
|
||||
@ -37,7 +37,7 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
this.fwSize,
|
||||
this.fwMD5,
|
||||
this.needAuthor,
|
||||
this.publicKey,
|
||||
this.signKey,
|
||||
this.privateKey,
|
||||
this.token})
|
||||
: super(CommandType.startOATUpgrade);
|
||||
@ -101,22 +101,24 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
// token 长度4 首次请求 Token 填 0,如果锁需要鉴权 操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 当token失效或者第一次发送的时候token为0
|
||||
data.addAll(token!);
|
||||
|
||||
print('--->1'+data.toString());
|
||||
|
||||
if (needAuthor == 0) {
|
||||
//AuthCodeLen 1
|
||||
data.add(0);
|
||||
} else {
|
||||
List<int> authCodeData = [];
|
||||
|
||||
//authUserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//KeyID
|
||||
authCodeData.addAll(utf8.encode(keyID!));
|
||||
|
||||
//UserID
|
||||
authCodeData.addAll(utf8.encode(userID!));
|
||||
|
||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||
authCodeData.addAll(token!);
|
||||
|
||||
authCodeData.addAll(publicKey!);
|
||||
authCodeData.addAll(signKey!);
|
||||
|
||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||
var authCode = crypto.md5.convert(authCodeData);
|
||||
@ -140,10 +142,14 @@ class OTAUpgradeCommand extends SenderProtocol {
|
||||
}
|
||||
|
||||
class OTAUpgradeReply extends Reply {
|
||||
List<int> token = [];
|
||||
|
||||
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[6];
|
||||
token = data.sublist(2, 6);
|
||||
status = data[6];
|
||||
print('--->2'+data.toString());
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class ProcessOtaUpgradeReply extends Reply {
|
||||
CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[2];
|
||||
status = data[2];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ class ConfirmationOTAUpgradeReply extends Reply {
|
||||
CommandType commandType, List<int> dataDetail)
|
||||
: super.parseData(commandType, dataDetail) {
|
||||
data = dataDetail;
|
||||
int status = data[2];
|
||||
status = data[2];
|
||||
errorWithStstus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -999,7 +999,7 @@ class IoSenderManage {
|
||||
required String? fwMD5,
|
||||
required int? needAuthor,
|
||||
required List<int>? token,
|
||||
required List<int>? publicKey,
|
||||
required List<int>? signKey,
|
||||
required List<int>? privateKey,
|
||||
CommandSendCallBack? callBack}) {
|
||||
CommandSenderManager().managerSendData(
|
||||
@ -1015,7 +1015,7 @@ class IoSenderManage {
|
||||
fwMD5: fwMD5,
|
||||
token: token,
|
||||
needAuthor: needAuthor,
|
||||
publicKey: publicKey,
|
||||
signKey: signKey,
|
||||
privateKey: privateKey,
|
||||
),
|
||||
callBack: callBack);
|
||||
|
||||
@ -27,7 +27,7 @@ class LockNetTokenEntity {
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? token;
|
||||
String? token;
|
||||
|
||||
Data({this.token});
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
int otaIndex = 0;
|
||||
Uint8List? otaBin;
|
||||
int startSecond = 0;
|
||||
Map? headJson = null;
|
||||
|
||||
// 锁升级
|
||||
Future<void> setLockSetGeneralSetting() async {
|
||||
@ -53,29 +54,28 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
}
|
||||
File file = File(result.files.single.path!);
|
||||
Uint8List data = await file.readAsBytes();
|
||||
Map? headJson = await getHeadFile(data);
|
||||
headJson = await getHeadFile(data);
|
||||
if (headJson is! Map) {
|
||||
return;
|
||||
}
|
||||
otaBin = await checkFile(data, headJson);
|
||||
otaBin = await checkFile(data, headJson!);
|
||||
if (otaBin == null) {
|
||||
return;
|
||||
}
|
||||
startOTAData();
|
||||
blueOTAUpgrade(headJson);
|
||||
String md5Str = md5.convert(otaBin!).toString();
|
||||
headJson!['fwMd5'] = md5Str;
|
||||
blueOTAUpgrade(headJson!, [0,0,0,0]);
|
||||
}
|
||||
|
||||
//蓝牙操作 ota 升级
|
||||
void blueOTAUpgrade(Map data) {
|
||||
void blueOTAUpgrade(Map data, List<int> token) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
String lockID = CommonDataManage.shareManager()
|
||||
?.currentLockSetInfoData
|
||||
.lockId
|
||||
@ -95,8 +95,8 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
fwSize: data['fwSize'],
|
||||
fwMD5: data['fwMd5'],
|
||||
needAuthor: 1,
|
||||
token: getTokenList,
|
||||
publicKey: getPublicKeyList,
|
||||
token: token,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList)
|
||||
.packageData());
|
||||
} else if (deviceConnectionState ==
|
||||
@ -115,6 +115,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
int difference = length % 240;
|
||||
otaCount = length ~/ 240 + (difference > 0 ? 1 : 0);
|
||||
startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
startOTAData();
|
||||
}
|
||||
if (otaCount <= otaIndex) {
|
||||
int now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
@ -212,9 +213,13 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
super.onInit();
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if (reply is OTAUpgradeReply && reply.status == 0x00) {
|
||||
//验证通过,开始发送数据包
|
||||
processOtaUpgrade();
|
||||
if (reply is OTAUpgradeReply) {
|
||||
if (reply.status == 0x00) {
|
||||
//验证通过,开始发送数据包
|
||||
processOtaUpgrade();
|
||||
} else if (reply.status == 0x06) {
|
||||
blueOTAUpgrade(headJson!, reply.token);
|
||||
}
|
||||
} else if (reply is ProcessOtaUpgradeReply && reply.status == 0x00) {
|
||||
otaIndex++;
|
||||
processOtaUpgrade();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user