Merge branch 'release' of gitee.com:starlock-cn/app-starlock into release
This commit is contained in:
commit
f9738cdcf7
@ -65,67 +65,62 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<int> messageDetail() {
|
List<int> messageDetail() {
|
||||||
List<int> data = [];
|
List<int> data = <int>[];
|
||||||
List<int> ebcData = [];
|
List<int> ebcData = <int>[];
|
||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
int type = commandType!.typeValue;
|
final int type = commandType!.typeValue;
|
||||||
double typeDouble = type / 256;
|
final double typeDouble = type / 256;
|
||||||
int type1 = typeDouble.toInt();
|
final int type1 = typeDouble.toInt();
|
||||||
int type2 = type % 256;
|
final int type2 = type % 256;
|
||||||
data.add(type1);
|
data.add(type1);
|
||||||
data.add(type2);
|
data.add(type2);
|
||||||
|
|
||||||
|
|
||||||
// 锁id 40
|
// 锁id 40
|
||||||
int lockIDLength = utf8.encode(lockID!).length;
|
final int lockIDLength = utf8.encode(lockID!).length;
|
||||||
data.addAll(utf8.encode(lockID!));
|
data.addAll(utf8.encode(lockID!));
|
||||||
data = getFixedLengthList(data, 40 - lockIDLength);
|
data = getFixedLengthList(data, 40 - lockIDLength);
|
||||||
|
|
||||||
|
|
||||||
//userID 20
|
//userID 20
|
||||||
int userIDLength = utf8.encode(userID!).length;
|
final int userIDLength = utf8.encode(userID!).length;
|
||||||
data.addAll(utf8.encode(userID!));
|
data.addAll(utf8.encode(userID!));
|
||||||
data = getFixedLengthList(data, 20 - userIDLength);
|
data = getFixedLengthList(data, 20 - userIDLength);
|
||||||
|
|
||||||
|
|
||||||
//platform 2
|
//platform 2
|
||||||
int platform0 = (platform! & 0xFF00) >> 8;
|
final int platform0 = (platform! & 0xFF00) >> 8;
|
||||||
int platform1 = platform! & 0xFF;
|
final int platform1 = platform! & 0xFF;
|
||||||
data.add(platform0);
|
data.add(platform0);
|
||||||
data.add(platform1);
|
data.add(platform1);
|
||||||
|
|
||||||
|
|
||||||
//product 2
|
//product 2
|
||||||
// int product0 = (product! & 0xFF00) >> 8;
|
// int product0 = (product! & 0xFF00) >> 8;
|
||||||
// int product1 = product! & 0xFF;
|
// int product1 = product! & 0xFF;
|
||||||
// data.add(product0);
|
// data.add(product0);
|
||||||
// data.add(product1);
|
// data.add(product1);
|
||||||
data.addAll([0, 1]); //先默认是 01
|
data.addAll(<int>[0, 1]); //先默认是 01
|
||||||
|
|
||||||
|
|
||||||
//HwVersion 20
|
//HwVersion 20
|
||||||
int hwVersionLength = utf8.encode(hwVersion!).length;
|
final int hwVersionLength = utf8.encode(hwVersion!).length;
|
||||||
data.addAll(utf8.encode(hwVersion!));
|
data.addAll(utf8.encode(hwVersion!));
|
||||||
data = getFixedLengthList(data, 20 - hwVersionLength);
|
data = getFixedLengthList(data, 20 - hwVersionLength);
|
||||||
|
|
||||||
//FwVersion 20
|
//FwVersion 20
|
||||||
int fwVersionLength = utf8.encode(fwVersion!).length;
|
final int fwVersionLength = utf8.encode(fwVersion!).length;
|
||||||
data.addAll(utf8.encode(fwVersion!));
|
data.addAll(utf8.encode(fwVersion!));
|
||||||
data = getFixedLengthList(data, 20 - fwVersionLength);
|
data = getFixedLengthList(data, 20 - fwVersionLength);
|
||||||
|
|
||||||
//fwSize 4
|
//fwSize 4
|
||||||
ByteData bytes = ByteData(4); // 创建一个长度为4的字节数据
|
final ByteData bytes = ByteData(4); // 创建一个长度为4的字节数据
|
||||||
bytes.setInt32(0, fwSize!);
|
bytes.setInt32(0, fwSize!);
|
||||||
List<int> byteList = bytes.buffer.asUint8List();
|
final List<int> byteList = bytes.buffer.asUint8List();
|
||||||
data.addAll(byteList);
|
data.addAll(byteList);
|
||||||
|
|
||||||
// 创建一个16字节的字节数组
|
// 创建一个16字节的字节数组
|
||||||
Uint8List result = Uint8List(16);
|
final Uint8List result = Uint8List(16);
|
||||||
// 将每个十六进制字符转换为4位二进制数据,并将其存储到结果字节数组中
|
// 将每个十六进制字符转换为4位二进制数据,并将其存储到结果字节数组中
|
||||||
for (int i = 0; i < fwMD5!.length; i += 2) {
|
for (int i = 0; i < fwMD5!.length; i += 2) {
|
||||||
String hex = fwMD5!.substring(i, i + 2);
|
final String hex = fwMD5!.substring(i, i + 2);
|
||||||
int byteValue = int.parse(hex, radix: 16);
|
final int byteValue = int.parse(hex, radix: 16);
|
||||||
result[i ~/ 2] = byteValue;
|
result[i ~/ 2] = byteValue;
|
||||||
}
|
}
|
||||||
data.addAll(result);
|
data.addAll(result);
|
||||||
@ -135,7 +130,7 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
//AuthCodeLen 1
|
//AuthCodeLen 1
|
||||||
data.add(0);
|
data.add(0);
|
||||||
} else {
|
} else {
|
||||||
List<int> authCodeData = [];
|
final List<int> authCodeData = <int>[];
|
||||||
|
|
||||||
//KeyID
|
//KeyID
|
||||||
authCodeData.addAll(utf8.encode(keyID!));
|
authCodeData.addAll(utf8.encode(keyID!));
|
||||||
@ -144,19 +139,19 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
authCodeData.addAll(utf8.encode(userID!));
|
authCodeData.addAll(utf8.encode(userID!));
|
||||||
|
|
||||||
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
//token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。
|
||||||
authCodeData.addAll(token??[]);
|
authCodeData.addAll(token ?? <int>[]);
|
||||||
|
|
||||||
authCodeData.addAll(signKey??[]);
|
authCodeData.addAll(signKey ?? <int>[]);
|
||||||
|
|
||||||
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
// 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode
|
||||||
var authCode = crypto.md5.convert(authCodeData);
|
final crypto.Digest authCode = crypto.md5.convert(authCodeData);
|
||||||
|
|
||||||
data.add(authCode.bytes.length);
|
data.add(authCode.bytes.length);
|
||||||
data.addAll(authCode.bytes);
|
data.addAll(authCode.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.length % 16) != 0) {
|
if ((data.length % 16) != 0) {
|
||||||
int add = (16 - data.length % 16);
|
final int add = 16 - data.length % 16;
|
||||||
for (int i = 0; i < add; i++) {
|
for (int i = 0; i < add; i++) {
|
||||||
data.add(0);
|
data.add(0);
|
||||||
}
|
}
|
||||||
@ -164,7 +159,6 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
printLog(data);
|
printLog(data);
|
||||||
|
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
|
|
||||||
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
// 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
|
||||||
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
|
||||||
return ebcData;
|
return ebcData;
|
||||||
@ -176,7 +170,7 @@ class OTAUpgradeCommand extends SenderProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OTAUpgradeReply extends Reply {
|
class OTAUpgradeReply extends Reply {
|
||||||
List<int> token = [];
|
List<int> token = <int>[];
|
||||||
|
|
||||||
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
|
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
|
||||||
: super.parseData(commandType, dataDetail) {
|
: super.parseData(commandType, dataDetail) {
|
||||||
|
|||||||
@ -1345,7 +1345,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
|
|
||||||
final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸
|
final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸
|
||||||
if (textSizeWidth > 358.w * 2 - 20) {
|
if (textSizeWidth > 358.w * 2 - 20) {
|
||||||
lockAlias = '${lockAlias.substring(0, 25)}...';
|
lockAlias =
|
||||||
|
'${lockAlias.substring(0, lockAlias.length > 25 ? 25 : lockAlias.length)}...';
|
||||||
}
|
}
|
||||||
return Center(
|
return Center(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
@ -1430,7 +1431,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startOpenLock() async{
|
Future<void> startOpenLock() async {
|
||||||
if (state.openLockBtnState.value == 1) {
|
if (state.openLockBtnState.value == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,8 +92,8 @@ class LockEscalationLogic extends BaseGetXController {
|
|||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: uid,
|
userID: uid,
|
||||||
keyID: BlueManage().connectDeviceName,
|
keyID: BlueManage().connectDeviceName,
|
||||||
platform: int.tryParse(data['platform'] ?? '0'),
|
platform: int.tryParse(data['platform'] ?? '0') ?? 0,
|
||||||
product: int.tryParse(data['product'] ?? '0'),
|
product: int.tryParse(data['product'] ?? '0') ?? 0,
|
||||||
hwVersion: data['hwVersion'],
|
hwVersion: data['hwVersion'],
|
||||||
fwVersion: data['fwVersion'],
|
fwVersion: data['fwVersion'],
|
||||||
fwSize: data['fwSize'],
|
fwSize: data['fwSize'],
|
||||||
|
|||||||
@ -182,17 +182,7 @@ class _LockEscalationPageState extends State<LockEscalationPage> {
|
|||||||
height: 20.h,
|
height: 20.h,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${'机型'.tr}:${logic.headJson?['platform']}-${logic.headJson?['product']}',
|
'${'机型'.tr}:${logic.headJson?['platform']}',
|
||||||
style: TextStyle(
|
|
||||||
color: AppColors.blackColor,
|
|
||||||
fontSize: 22.sp,
|
|
||||||
fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 10.h,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${'硬件版本'.tr}:${logic.headJson?['hwVersion']}',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.blackColor,
|
color: AppColors.blackColor,
|
||||||
fontSize: 22.sp,
|
fontSize: 22.sp,
|
||||||
|
|||||||
@ -7,22 +7,19 @@ import 'package:star_lock/mine/addLock/addLock/addLock_state.dart';
|
|||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import 'package:star_lock/widget/permission/permission_dialog.dart';
|
import 'package:star_lock/widget/permission/permission_dialog.dart';
|
||||||
|
|
||||||
|
|
||||||
class AddLockLogic extends BaseGetXController {
|
class AddLockLogic extends BaseGetXController {
|
||||||
final AddLockState state = AddLockState();
|
final AddLockState state = AddLockState();
|
||||||
|
|
||||||
|
|
||||||
//跳转到附近的锁页面先判断权限
|
//跳转到附近的锁页面先判断权限
|
||||||
Future<void> getNearByLimits() async {
|
Future<void> getNearByLimits() async {
|
||||||
if (!Platform.isIOS) {
|
if (!Platform.isIOS) {
|
||||||
bool bluetoothRequest = await PermissionDialog.requestBluetooth();
|
final bool locationRequest = await PermissionDialog.request(Permission.location);
|
||||||
bool locationRequest = await PermissionDialog.request(Permission.location);
|
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
|
||||||
if (!bluetoothRequest || !locationRequest) {
|
if (!bluetoothRequest || !locationRequest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Get.toNamed(Routers.nearbyLockPage);
|
Get.toNamed(Routers.nearbyLockPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@ -9,6 +8,7 @@ import 'package:date_format/date_format.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:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
import 'package:star_lock/blue/io_protocol/io_getPrivateKey.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
import 'package:star_lock/blue/io_protocol/io_getPublicKey.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
|
||||||
@ -45,15 +45,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 点击连接设备
|
// 点击连接设备
|
||||||
void connect(String deviceName) {
|
void connect(String deviceName) {
|
||||||
showTitleEasyLoading('获取锁信息 1/3');
|
showTitleEasyLoading('获取锁信息 1/3');
|
||||||
// if(state.sureBtnState.value == 1){
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// state.sureBtnState.value = 1;
|
|
||||||
|
|
||||||
// showEasyLoading();
|
|
||||||
showBlueConnetctToastTimer(action: () {
|
showBlueConnetctToastTimer(action: () {
|
||||||
dismissEasyLoading();
|
dismissEasyLoading();
|
||||||
// state.sureBtnState.value = 0;
|
|
||||||
});
|
});
|
||||||
BlueManage().blueSendData(deviceName,
|
BlueManage().blueSendData(deviceName,
|
||||||
(BluetoothConnectionState state) async {
|
(BluetoothConnectionState state) async {
|
||||||
@ -71,7 +64,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
_replySubscription =
|
_replySubscription =
|
||||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||||
if (reply is GetPublicKeyReply) {
|
if (reply is GetPublicKeyReply) {
|
||||||
_replyGetPublicKey(reply);
|
_replyGetPublicKey(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply is GetPrivateKeyReply) {
|
if (reply is GetPrivateKeyReply) {
|
||||||
@ -103,8 +96,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _replyGetPublicKey(Reply reply) async {
|
Future<void> _replyGetPublicKey(Reply reply) async {
|
||||||
// dismissEasyLoading();
|
|
||||||
|
|
||||||
// 获取公钥
|
// 获取公钥
|
||||||
switch (reply.status) {
|
switch (reply.status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
@ -127,7 +118,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
needAuthor: 1);
|
needAuthor: 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// state.sureBtnState.value = 0;
|
|
||||||
AppLog.log('获取公钥失败');
|
AppLog.log('获取公钥失败');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -142,7 +132,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 私钥
|
// 私钥
|
||||||
final List<int> privateKey = reply.data.sublist(0, 16);
|
final List<int> privateKey = reply.data.sublist(0, 16);
|
||||||
final List<String> savePrivateKeyList = changeIntListToStringList(privateKey);
|
final List<String> savePrivateKeyList =
|
||||||
|
changeIntListToStringList(privateKey);
|
||||||
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
||||||
|
|
||||||
// signKey
|
// signKey
|
||||||
@ -160,7 +151,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
_getStarLockStatus();
|
_getStarLockStatus();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// state.sureBtnState.value = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +160,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
final int status = reply.data[2];
|
final int status = reply.data[2];
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
AppLog.log('获取锁状态成功');
|
AppLog.log('获取锁状态成功');
|
||||||
// 厂商名称
|
// 厂商名称
|
||||||
int index = 3;
|
int index = 3;
|
||||||
@ -196,14 +186,14 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
AppLog.log('产品名称 mmodelStr:$modelStr');
|
AppLog.log('产品名称 mmodelStr:$modelStr');
|
||||||
|
|
||||||
// 软件版本
|
// 软件版本
|
||||||
final List<int> fwVersion = reply.data.sublist(index, index+20);
|
final List<int> fwVersion = reply.data.sublist(index, index + 20);
|
||||||
final String fwVersionStr = utf8String(fwVersion);
|
final String fwVersionStr = utf8String(fwVersion);
|
||||||
state.lockInfo['fwVersion'] = fwVersionStr;
|
state.lockInfo['fwVersion'] = fwVersionStr;
|
||||||
index = index + 20;
|
index = index + 20;
|
||||||
AppLog.log('软件版本 fwVersionStr:$fwVersionStr');
|
AppLog.log('软件版本 fwVersionStr:$fwVersionStr');
|
||||||
|
|
||||||
// 硬件版本
|
// 硬件版本
|
||||||
final List<int> hwVersion = reply.data.sublist(index, index+20);
|
final List<int> hwVersion = reply.data.sublist(index, index + 20);
|
||||||
final String hwVersionStr = utf8String(hwVersion);
|
final String hwVersionStr = utf8String(hwVersion);
|
||||||
state.lockInfo['hwVersion'] = hwVersionStr;
|
state.lockInfo['hwVersion'] = hwVersionStr;
|
||||||
index = index + 20;
|
index = index + 20;
|
||||||
@ -245,16 +235,18 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 重置次数
|
// 重置次数
|
||||||
final List<int> restoreCounter = reply.data.sublist(index, index + 2);
|
final List<int> restoreCounter = reply.data.sublist(index, index + 2);
|
||||||
state.lockInfo['restoreCount'] = restoreCounter[0] * 256 + restoreCounter[1];
|
state.lockInfo['restoreCount'] =
|
||||||
|
restoreCounter[0] * 256 + restoreCounter[1];
|
||||||
index = index + 2;
|
index = index + 2;
|
||||||
AppLog.log('重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}');
|
AppLog.log(
|
||||||
|
'重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}');
|
||||||
|
|
||||||
// 重置时间
|
// 重置时间
|
||||||
final List<int> restoreDate = reply.data.sublist(index, index + 4);
|
final List<int> restoreDate = reply.data.sublist(index, index + 4);
|
||||||
final int restoreDateValue = (0xff & restoreDate[0]) << 24 |
|
final int restoreDateValue = (0xff & restoreDate[0]) << 24 |
|
||||||
(0xff & restoreDate[1]) << 16 |
|
(0xff & restoreDate[1]) << 16 |
|
||||||
(0xff & restoreDate[2]) << 8 |
|
(0xff & restoreDate[2]) << 8 |
|
||||||
(0xFF & restoreDate[3]);
|
(0xFF & restoreDate[3]);
|
||||||
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
|
||||||
state.lockInfo['restoreDate'] = restoreDateValue * 1000;
|
state.lockInfo['restoreDate'] = restoreDateValue * 1000;
|
||||||
index = index + 4;
|
index = index + 4;
|
||||||
@ -270,9 +262,9 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// 有效时间
|
// 有效时间
|
||||||
final List<int> indate = reply.data.sublist(index, index + 4);
|
final List<int> indate = reply.data.sublist(index, index + 4);
|
||||||
final int indateValue = (0xff & indate[0]) << 24 |
|
final int indateValue = (0xff & indate[0]) << 24 |
|
||||||
(0xff & indate[1]) << 16 |
|
(0xff & indate[1]) << 16 |
|
||||||
(0xff & indate[2]) << 8 |
|
(0xff & indate[2]) << 8 |
|
||||||
(0xFF & indate[3]);
|
(0xFF & indate[3]);
|
||||||
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
// String indateStr = DateTool().dateToYMDHNSString("$indateValue");
|
||||||
state.lockInfo['indate'] = indateValue * 1000;
|
state.lockInfo['indate'] = indateValue * 1000;
|
||||||
index = index + 4;
|
index = index + 4;
|
||||||
@ -286,7 +278,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
AppLog.log('mac地址 macAddressStr:$macAddressStr');
|
AppLog.log('mac地址 macAddressStr:$macAddressStr');
|
||||||
|
|
||||||
//时区偏移
|
//时区偏移
|
||||||
state.lockInfo['timezoneOffset'] = DateTime.now().timeZoneOffset.inSeconds;
|
state.lockInfo['timezoneOffset'] =
|
||||||
|
DateTime.now().timeZoneOffset.inSeconds;
|
||||||
|
|
||||||
// 锁特征值字符串长度
|
// 锁特征值字符串长度
|
||||||
final int featureValueLength = reply.data[index];
|
final int featureValueLength = reply.data[index];
|
||||||
@ -300,7 +293,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
showToast('锁数据异常,请重试');
|
showToast('锁数据异常,请重试');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<int> featureValue = reply.data.sublist(index, index + featureValueLength);
|
final List<int> featureValue =
|
||||||
|
reply.data.sublist(index, index + featureValueLength);
|
||||||
final String featureValueStr = asciiString(featureValue);
|
final String featureValueStr = asciiString(featureValue);
|
||||||
state.featureValue = featureValueStr;
|
state.featureValue = featureValueStr;
|
||||||
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
// List allFeatureValueTwoList = charListChangeIntList(featureValue);
|
||||||
@ -319,7 +313,8 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
showToast('锁数据异常,请重试');
|
showToast('锁数据异常,请重试');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<int> featureEnVal = reply.data.sublist(index, index + featureEnValLength);
|
final List<int> featureEnVal =
|
||||||
|
reply.data.sublist(index, index + featureEnValLength);
|
||||||
final String featureEnValStr = asciiString(featureEnVal);
|
final String featureEnValStr = asciiString(featureEnVal);
|
||||||
state.featureSettingValue = featureEnValStr;
|
state.featureSettingValue = featureEnValStr;
|
||||||
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
|
||||||
@ -344,14 +339,11 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey =
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
// IoSenderManage.senderGetLockStatu(
|
final List<int> getPrivateKeyList =
|
||||||
// lockID:BlueManage().connectDeviceName,
|
changeStringListToIntList(privateKey!);
|
||||||
// userID:await Storage.getUid(),
|
|
||||||
// privateKey:getPrivateKeyList,
|
|
||||||
// );
|
|
||||||
IoSenderManage.senderGetStarLockStatuInfo(
|
IoSenderManage.senderGetStarLockStatuInfo(
|
||||||
lockID: BlueManage().connectDeviceName,
|
lockID: BlueManage().connectDeviceName,
|
||||||
userID: await Storage.getUid(),
|
userID: await Storage.getUid(),
|
||||||
@ -362,8 +354,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//失败
|
//失败
|
||||||
// state.sureBtnState.value = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,12 +367,16 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
// dismissEasyLoading();
|
// dismissEasyLoading();
|
||||||
|
|
||||||
AppLog.log('开始获取锁状态');
|
AppLog.log('开始获取锁状态');
|
||||||
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
|
final List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
|
final String getUTCDate = formatDate(
|
||||||
final String getUTCDate = formatDate(DateTime.fromMillisecondsSinceEpoch(state.serverTime*1000), <String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]);
|
DateTime.fromMillisecondsSinceEpoch(state.serverTime * 1000),
|
||||||
final String getLocalDate = formatDate(DateTime.fromMillisecondsSinceEpoch(getLocalTime()*1000), <String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]);
|
<String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]);
|
||||||
|
final String getLocalDate = formatDate(
|
||||||
|
DateTime.fromMillisecondsSinceEpoch(getLocalTime() * 1000),
|
||||||
|
<String>[yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss]);
|
||||||
|
|
||||||
AppLog.log('state.serverTime:${state.serverTime} getUTCDate:$getUTCDate '
|
AppLog.log('state.serverTime:${state.serverTime} getUTCDate:$getUTCDate '
|
||||||
'getLocalTime:${getLocalTime()} getLocalDate:$getLocalDate '
|
'getLocalTime:${getLocalTime()} getLocalDate:$getLocalDate '
|
||||||
@ -394,10 +389,6 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
isBeforeAddUser: true,
|
isBeforeAddUser: true,
|
||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
// } else if (state == BluetoothConnectionState.disconnected) {
|
|
||||||
// dismissEasyLoading();
|
|
||||||
// }
|
|
||||||
// }, isAddEquipment: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startScanBlueList() {
|
void startScanBlueList() {
|
||||||
@ -490,7 +481,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
).packageData());
|
).packageData());
|
||||||
} else if (deviceConnectionState ==
|
} else if (deviceConnectionState ==
|
||||||
BluetoothConnectionState.disconnected) {}
|
BluetoothConnectionState.disconnected) {}
|
||||||
},isAddEquipment: true);
|
}, isAddEquipment: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//循环传输升级固件包
|
//循环传输升级固件包
|
||||||
@ -536,7 +527,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
logic: this,
|
logic: this,
|
||||||
),
|
),
|
||||||
barrierDismissible: false)
|
barrierDismissible: false)
|
||||||
.then((value) => state.oTAProgressDialog = false);
|
.then((dynamic value) => state.oTAProgressDialog = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//清楚 ata 安装文件
|
//清楚 ata 安装文件
|
||||||
@ -632,9 +623,10 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从服务器获取锁的时间 开锁时传入
|
// 从服务器获取锁的时间 开锁时传入
|
||||||
Future<void> getServerDatetime() async{
|
Future<void> getServerDatetime() async {
|
||||||
final GetServerDatetimeEntity entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:false);
|
final GetServerDatetimeEntity entity =
|
||||||
if(entity.errorCode!.codeIsSuccessful){
|
await ApiRepository.to.getServerDatetimeData(isUnShowLoading: false);
|
||||||
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
state.serverTime = entity.data!.date! ~/ 1000;
|
state.serverTime = entity.data!.date! ~/ 1000;
|
||||||
|
|
||||||
if (state.otaState.value) {
|
if (state.otaState.value) {
|
||||||
@ -642,12 +634,10 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
} else {
|
} else {
|
||||||
connect(state.selectLockName.value);
|
connect(state.selectLockName.value);
|
||||||
}
|
}
|
||||||
// state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
|
||||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getLocalTime(){
|
int getLocalTime() {
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
final Duration timeZoneOffset = now.timeZoneOffset;
|
final Duration timeZoneOffset = now.timeZoneOffset;
|
||||||
AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds');
|
AppLog.log('timeZoneOffset.inSeconds:$timeZoneOffset.inSeconds');
|
||||||
@ -657,9 +647,7 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
_initReplySubscription();
|
getNearByLimits();
|
||||||
state.ifCurrentScreen.value = true;
|
|
||||||
startScanBlueList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -672,4 +660,18 @@ class NearbyLockLogic extends BaseGetXController {
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
_replySubscription?.cancel();
|
_replySubscription?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> getNearByLimits() async {
|
||||||
|
if (!Platform.isIOS) {
|
||||||
|
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
|
||||||
|
final bool locationRequest =
|
||||||
|
await PermissionDialog.request(Permission.location);
|
||||||
|
if (!bluetoothRequest || !locationRequest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_initReplySubscription();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
|
startScanBlueList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/flavors.dart';
|
import 'package:star_lock/flavors.dart';
|
||||||
import '../../../app_settings/app_colors.dart';
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../blue/blue_manage.dart';
|
|
||||||
import '../../../tools/appRouteObserver.dart';
|
import '../../../tools/appRouteObserver.dart';
|
||||||
import '../../../tools/titleAppBar.dart';
|
import '../../../tools/titleAppBar.dart';
|
||||||
import '../../../translations/trans_lib.dart';
|
import '../../../translations/trans_lib.dart';
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||||
import 'package:star_lock/flavors.dart';
|
import 'package:star_lock/flavors.dart';
|
||||||
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
||||||
|
import 'package:star_lock/tools/commonItem.dart';
|
||||||
|
import 'package:star_lock/tools/customer_tool.dart';
|
||||||
|
|
||||||
import '../../appRouters.dart';
|
import '../../appRouters.dart';
|
||||||
import '../../app_settings/app_colors.dart';
|
import '../../app_settings/app_colors.dart';
|
||||||
@ -204,6 +205,12 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
|||||||
Get.back();
|
Get.back();
|
||||||
Get.toNamed(Routers.lockMallPage);
|
Get.toNamed(Routers.lockMallPage);
|
||||||
}),
|
}),
|
||||||
|
if (F.isSKY)
|
||||||
|
mineItem('images/mine/icon_mine_main_shoppingcart.png',
|
||||||
|
TranslationLoader.lanKeys!.supportStaff!.tr, () {
|
||||||
|
Get.back();
|
||||||
|
CustomerTool.openCustomerService();
|
||||||
|
}),
|
||||||
mineItem('images/mine/icon_mine_main_about.png',
|
mineItem('images/mine/icon_mine_main_about.png',
|
||||||
TranslationLoader.lanKeys!.about!.tr, () {
|
TranslationLoader.lanKeys!.about!.tr, () {
|
||||||
Get.back();
|
Get.back();
|
||||||
|
|||||||
@ -353,12 +353,13 @@ class _MineSetPageState extends State<MineSetPage>
|
|||||||
action: () {
|
action: () {
|
||||||
logic.showToast('功能暂未开放'.tr);
|
logic.showToast('功能暂未开放'.tr);
|
||||||
}),
|
}),
|
||||||
CommonItem(
|
if (F.isXHJ)
|
||||||
leftTitel: TranslationLoader.lanKeys!.supportStaff!.tr,
|
CommonItem(
|
||||||
isHaveLine: widget.showAbout,
|
leftTitel: TranslationLoader.lanKeys!.supportStaff!.tr,
|
||||||
isHaveDirection: true,
|
isHaveLine: widget.showAbout,
|
||||||
action: CustomerTool.openCustomerService,
|
isHaveDirection: true,
|
||||||
),
|
action: CustomerTool.openCustomerService,
|
||||||
|
),
|
||||||
if (widget.showAbout)
|
if (widget.showAbout)
|
||||||
CommonItem(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.about!.tr,
|
leftTitel: TranslationLoader.lanKeys!.about!.tr,
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/app_settings/app_settings.dart';
|
import 'package:star_lock/app_settings/app_settings.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
import 'package:star_lock/translations/trans_lib.dart';
|
|
||||||
|
|
||||||
class PermissionDialog {
|
class PermissionDialog {
|
||||||
static Map<Permission, String> titles = <Permission, String>{
|
static Map<Permission, String> titles = <Permission, String>{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user