Merge branch 'master' of gitee.com:starlock-cn/app-starlock

# Conflicts:
#	star_lock/images/lan/lan_en.json
合并代码
This commit is contained in:
Daisy 2024-04-24 17:21:23 +08:00
commit 46c4c3df4b
30 changed files with 1567 additions and 495 deletions

View File

@ -769,9 +769,6 @@
"异常警告":"Abnormal warning", "异常警告":"Abnormal warning",
"短信提醒":"SMS reminder", "短信提醒":"SMS reminder",
"邮件提醒":"Email reminder", "邮件提醒":"Email reminder",
"关锁":"关锁",
"功能":"功能",
"配件":"配件",
"N天未开门提醒":"N days did not open the door reminder", "N天未开门提醒":"N days did not open the door reminder",
"当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网":"When forced to open the lock, the use of coercive fingerprint will trigger the alarm, the alarm message will be pushed to the administrator, the function requires the lock network", "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网":"When forced to open the lock, the use of coercive fingerprint will trigger the alarm, the alarm message will be pushed to the administrator, the function requires the lock network",
"胁迫指纹":"Stress fingerprint", "胁迫指纹":"Stress fingerprint",
@ -779,5 +776,8 @@
"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网":"After the above set time, the lock is not opened, the system will send a reminder message to the specified object, this function requires the lock network", "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网":"After the above set time, the lock is not opened, the system will send a reminder message to the specified object, this function requires the lock network",
"打开提醒后当锁电量低于20%、10%和5%系统会给指定对象发送提醒消息。电量读取方式网关读取或APP读取。":"After the reminder is enabled, when the lock power is below 20%, 10%, and 5%, the system will send a reminder message to the specified object. Power reading mode: gateway reading or APP reading.", "打开提醒后当锁电量低于20%、10%和5%系统会给指定对象发送提醒消息。电量读取方式网关读取或APP读取。":"After the reminder is enabled, when the lock power is below 20%, 10%, and 5%, the system will send a reminder message to the specified object. Power reading mode: gateway reading or APP reading.",
"门未开时间":"Door not open time", "门未开时间":"Door not open time",
"添加和使用面容开锁时:":"Add and use Face when unlocking:" "添加和使用面容开锁时:":"Add and use Face when unlocking:",
"关锁":"close lock",
"功能":"function",
"配件":"parts"
} }

View File

@ -41,7 +41,41 @@ PODS:
- ReachabilitySwift - ReachabilitySwift
- device_info_plus (0.0.1): - device_info_plus (0.0.1):
- Flutter - Flutter
- DKImagePickerController/Core (4.3.8):
- DKImagePickerController/ImageDataManager
- DKImagePickerController/Resource
- DKImagePickerController/ImageDataManager (4.3.8)
- DKImagePickerController/PhotoGallery (4.3.8):
- DKImagePickerController/Core
- DKPhotoGallery
- DKImagePickerController/Resource (4.3.8)
- DKPhotoGallery (0.0.17):
- DKPhotoGallery/Core (= 0.0.17)
- DKPhotoGallery/Model (= 0.0.17)
- DKPhotoGallery/Preview (= 0.0.17)
- DKPhotoGallery/Resource (= 0.0.17)
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Core (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Preview
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Model (0.0.17):
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Preview (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Resource
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Resource (0.0.17):
- SDWebImage
- SwiftyGif
- EMASRest (11.1.1.2) - EMASRest (11.1.1.2)
- file_picker (0.0.1):
- DKImagePickerController/PhotoGallery
- Flutter
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_blue_plus (0.0.1): - flutter_blue_plus (0.0.1):
- Flutter - Flutter
@ -95,12 +129,16 @@ PODS:
- permission_handler_apple (9.3.0): - permission_handler_apple (9.3.0):
- Flutter - Flutter
- ReachabilitySwift (5.2.2) - ReachabilitySwift (5.2.2)
- SDWebImage (5.19.1):
- SDWebImage/Core (= 5.19.1)
- SDWebImage/Core (5.19.1)
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- sqflite (0.0.3): - sqflite (0.0.3):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- SwiftyGif (5.4.5)
- system_settings (0.0.1): - system_settings (0.0.1):
- Flutter - Flutter
- Toast (4.1.1) - Toast (4.1.1)
@ -126,6 +164,7 @@ DEPENDENCIES:
- camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`) - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`) - flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
@ -163,11 +202,15 @@ SPEC REPOS:
- AMap3DMap - AMap3DMap
- AMapFoundation - AMapFoundation
- AMapLocation - AMapLocation
- DKImagePickerController
- DKPhotoGallery
- GoogleMaps - GoogleMaps
- ios-voice-processor - ios-voice-processor
- JCore - JCore
- JPush - JPush
- ReachabilitySwift - ReachabilitySwift
- SDWebImage
- SwiftyGif
- Toast - Toast
- WechatOpenSDK-XCFramework - WechatOpenSDK-XCFramework
@ -194,6 +237,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/connectivity_plus/ios" :path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus: device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios" :path: ".symlinks/plugins/device_info_plus/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
Flutter: Flutter:
:path: Flutter :path: Flutter
flutter_blue_plus: flutter_blue_plus:
@ -261,7 +306,10 @@ SPEC CHECKSUMS:
camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68 camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
DKImagePickerController: a7836546cfdfe014171694f643a7d575bc8ace7f
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
EMASRest: 8df6f87836767a9415ad5cc4af739bc9d215b475 EMASRest: 8df6f87836767a9415ad5cc4af739bc9d215b475
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96 flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086 flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
@ -284,8 +332,10 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149 ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149
SDWebImage: 40b0b4053e36c660a764958bff99eed16610acbb
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
system_settings: 8f5cdbfa72c677fc8d665b863bcc20d393d87e9d system_settings: 8f5cdbfa72c677fc8d665b863bcc20d393d87e9d
Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

View File

@ -57,6 +57,7 @@ import 'login/login/starLock_login_page.dart';
import 'login/register/starLock_register_page.dart'; import 'login/register/starLock_register_page.dart';
import 'login/selectCountryRegion/selectCountryRegion_page.dart'; import 'login/selectCountryRegion/selectCountryRegion_page.dart';
import 'main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart'; import 'main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_page.dart';
import 'main/lockDetail/card/addCardType/addCardType_page.dart';
import 'main/lockDetail/card/addICCard/addICCard_page.dart'; import 'main/lockDetail/card/addICCard/addICCard_page.dart';
import 'main/lockDetail/card/cardDetail/cardDetail_page.dart'; import 'main/lockDetail/card/cardDetail/cardDetail_page.dart';
import 'main/lockDetail/card/cardList/cardList_page.dart'; import 'main/lockDetail/card/cardList/cardList_page.dart';
@ -416,7 +417,8 @@ abstract class Routers {
'/AddRemoteControlManagePage'; // '/AddRemoteControlManagePage'; //
static const cardListPage = '/CardListPage'; // static const cardListPage = '/CardListPage'; //
static const addCardTypeManagePage = '/AddCardTypeManagePage'; // // static const addCardTypeManagePage = '/AddCardTypeManagePage'; //
static const addCardPage = '/AddCardPage'; //
static const cardDetailPage = '/CardDetailPage'; // static const cardDetailPage = '/CardDetailPage'; //
static const fingerprintListPage = '/FingerprintListPage'; // static const fingerprintListPage = '/FingerprintListPage'; //
static const addFingerprintTypeManagePage = static const addFingerprintTypeManagePage =
@ -1009,9 +1011,12 @@ abstract class AppRouters {
name: Routers.addRemoteControlManagePage, name: Routers.addRemoteControlManagePage,
page: () => const AddRemoteControlManagePage()), page: () => const AddRemoteControlManagePage()),
GetPage(name: Routers.cardListPage, page: () => const CardListPage()), GetPage(name: Routers.cardListPage, page: () => const CardListPage()),
// GetPage(
// name: Routers.addCardTypeManagePage,
// page: () => const AddCardTypeManagePage()),
GetPage( GetPage(
name: Routers.addCardTypeManagePage, name: Routers.addCardPage,
page: () => const AddCardTypeManagePage()), page: () => const AddCardPage()),
GetPage(name: Routers.cardDetailPage, page: () => const CardDetailPage()), GetPage(name: Routers.cardDetailPage, page: () => const CardDetailPage()),
GetPage( GetPage(
name: Routers.fingerprintListPage, name: Routers.fingerprintListPage,

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
@ -12,7 +11,8 @@ import 'reciver_data.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
// //
typedef ConnectStateCallBack = Function(BluetoothConnectionState connectionState); typedef ConnectStateCallBack = Function(
BluetoothConnectionState connectionState);
typedef ScanDevicesCallBack = Function(List<ScanResult>); typedef ScanDevicesCallBack = Function(List<ScanResult>);
class BlueManage { class BlueManage {
@ -57,7 +57,8 @@ class BlueManage {
ScanResult? scanResult; ScanResult? scanResult;
// //
BluetoothConnectionState? bluetoothConnectionState = BluetoothConnectionState.disconnected; BluetoothConnectionState? bluetoothConnectionState =
BluetoothConnectionState.disconnected;
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown; BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription; StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription;
@ -80,6 +81,7 @@ class BlueManage {
void _initBlue() { void _initBlue() {
Get.log("蓝牙功能初始化监听"); Get.log("蓝牙功能初始化监听");
FlutterBluePlus.setLogLevel(LogLevel.error, color: true);
_initSendStreamSubscription(); _initSendStreamSubscription();
_initAdapterStateStateSubscription(); _initAdapterStateStateSubscription();
// _initListenscanResults(); // _initListenscanResults();
@ -94,7 +96,8 @@ class BlueManage {
} }
void _initAdapterStateStateSubscription() { void _initAdapterStateStateSubscription() {
_adapterStateStateSubscription ??= FlutterBluePlus.adapterState.listen((state) { _adapterStateStateSubscription ??=
FlutterBluePlus.adapterState.listen((state) {
_adapterState = state; _adapterState = state;
}); });
} }
@ -142,14 +145,18 @@ class BlueManage {
_connectionStateSubscription?.cancel(); _connectionStateSubscription?.cancel();
_connectionStateSubscription = null; _connectionStateSubscription = null;
_connectionStateSubscription = bluetoothConnectDevice!.connectionState.listen((state) async { _connectionStateSubscription =
bluetoothConnectDevice!.connectionState.listen((state) async {
bluetoothConnectionState = state; bluetoothConnectionState = state;
print("蓝牙连接状态:$state"); print("蓝牙连接状态:$state");
}); });
} }
void _initSendStreamSubscription() { void _initSendStreamSubscription() {
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) { _sendStreamSubscription ??= EventBusManager()
.eventBus!
.on<EventSendModel>()
.listen((EventSendModel model) {
if (model.sendChannel == DataChannel.ble) { if (model.sendChannel == DataChannel.ble) {
FlutterBluePlus.isSupported.then((isAvailable) async { FlutterBluePlus.isSupported.then((isAvailable) async {
if (isAvailable) { if (isAvailable) {
@ -157,9 +164,7 @@ class BlueManage {
// //
writeCharacteristicWithResponse(model.data); writeCharacteristicWithResponse(model.data);
} else { } else {
try { try {} catch (e) {
} catch (e) {
print("Error Turning On:"); print("Error Turning On:");
} }
} }
@ -172,7 +177,8 @@ class BlueManage {
} }
/// ///
Future<void> startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async { Future<void> startScanSingle(String deviceName, int timeout,
ScanDevicesCallBack scanDevicesCallBack) async {
FlutterBluePlus.isSupported.then((isAvailable) async { FlutterBluePlus.isSupported.then((isAvailable) async {
if (isAvailable) { if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
@ -180,8 +186,10 @@ class BlueManage {
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout)); FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
Completer<dynamic> completer = Completer<dynamic>(); Completer<dynamic> completer = Completer<dynamic>();
var subscription = FlutterBluePlus.scanResults.listen((results) { var subscription = FlutterBluePlus.scanResults.listen((results) {
print("startScanSingle扫描到的设备:$results"); // print("startScanSingle扫描到的设备:$results");
bool isExit = results.any((element) => (element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName)); bool isExit = results.any((element) =>
(element.device.platformName == deviceName) ||
(element.advertisementData.advName == deviceName));
if (isExit) { if (isExit) {
for (var scanResult in results) { for (var scanResult in results) {
if (((scanResult.advertisementData.serviceUuids.isNotEmpty if (((scanResult.advertisementData.serviceUuids.isNotEmpty
@ -191,8 +199,11 @@ class BlueManage {
.contains("758824")) && .contains("758824")) &&
(scanResult.rssi >= -100)) { (scanResult.rssi >= -100)) {
// id相同的元素 // id相同的元素
final knownDeviceIndex = scanDevices final knownDeviceIndex = scanDevices.indexWhere((d) =>
.indexWhere((d) => (d.device.platformName == scanResult.device.platformName) || (d.advertisementData.advName == scanResult.advertisementData.advName)); (d.device.platformName ==
scanResult.device.platformName) ||
(d.advertisementData.advName ==
scanResult.advertisementData.advName));
// -1 // -1
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult; scanDevices[knownDeviceIndex] = scanResult;
@ -231,7 +242,8 @@ class BlueManage {
} }
/// ///
Future<void> startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack, {List<Guid>? idList}) async { Future<void> startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack,
{List<Guid>? idList}) async {
FlutterBluePlus.isSupported.then((isAvailable) async { FlutterBluePlus.isSupported.then((isAvailable) async {
if (isAvailable) { if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
@ -255,8 +267,11 @@ class BlueManage {
.contains("758824")) && .contains("758824")) &&
(scanResult.rssi >= -100)) { (scanResult.rssi >= -100)) {
// id相同的元素 // id相同的元素
final knownDeviceIndex = scanDevices final knownDeviceIndex = scanDevices.indexWhere((d) =>
.indexWhere((d) => (d.device.platformName == scanResult.device.platformName) || (d.advertisementData.advName == scanResult.advertisementData.advName)); (d.device.platformName ==
scanResult.device.platformName) ||
(d.advertisementData.advName ==
scanResult.advertisementData.advName));
// -1 // -1
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult; scanDevices[knownDeviceIndex] = scanResult;
@ -294,7 +309,9 @@ class BlueManage {
} }
/// List senderData, /// List senderData,
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async { Future<void> bludSendData(
String deviceName, ConnectStateCallBack stateCallBack,
{bool isAddEquipment = false}) async {
FlutterBluePlus.isSupported.then((isAvailable) async { FlutterBluePlus.isSupported.then((isAvailable) async {
if (isAvailable) { if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
@ -321,33 +338,43 @@ class BlueManage {
} }
/// ///
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack, Future<void> _connect(
String deviceName, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
connectDeviceName = deviceName; connectDeviceName = deviceName;
List<ScanResult> devicesList = scanDevices; List<ScanResult> devicesList = scanDevices;
// //
bool isExistDevice = scanDevices.any((element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName); bool isExistDevice = scanDevices.any((element) =>
element.device.platformName == connectDeviceName ||
element.advertisementData.advName == connectDeviceName);
if (isAddEquipment == false && isExistDevice == false) { if (isAddEquipment == false && isExistDevice == false) {
// startScan(10, (scanDevices){ // startScan(10, (scanDevices){
startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) {
print("扫描到的设备:$scanDevices"); print("扫描到的设备:$scanDevices");
devicesList = scanDevices; devicesList = scanDevices;
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment); _connectDevice(devicesList, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
}); });
} else { } else {
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment); _connectDevice(devicesList, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
} }
} }
Future<void> _connectDevice( Future<void> _connectDevice(List<ScanResult> devicesList, String deviceName,
List<ScanResult> devicesList, String deviceName, ConnectStateCallBack connectStateCallBack, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
// //
print("devicesList:$devicesList"); print("devicesList:$devicesList");
final knownDeviceIndex = devicesList.indexWhere((d) => (d.device.platformName == deviceName) || (d.advertisementData.advName == deviceName)); final knownDeviceIndex = devicesList.indexWhere((d) =>
(d.device.platformName == deviceName) ||
(d.advertisementData.advName == deviceName));
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
// //
connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName.isNotEmpty ? devicesList[knownDeviceIndex].advertisementData.advName : devicesList[knownDeviceIndex].device.platformName; connectDeviceMacAddress =
devicesList[knownDeviceIndex].advertisementData.advName.isNotEmpty
? devicesList[knownDeviceIndex].advertisementData.advName
: devicesList[knownDeviceIndex].device.platformName;
bluetoothConnectDevice = devicesList[knownDeviceIndex].device; bluetoothConnectDevice = devicesList[knownDeviceIndex].device;
print('bluetoothConnectDevice: $bluetoothConnectDevice'); print('bluetoothConnectDevice: $bluetoothConnectDevice');
@ -356,7 +383,8 @@ class BlueManage {
_initGetMtuSubscription(); _initGetMtuSubscription();
_initListenConnectionState(); _initListenConnectionState();
} }
print("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName"); print(
"1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
// stopScan(); // stopScan();
if (connectDeviceMacAddress.isEmpty) { if (connectDeviceMacAddress.isEmpty) {
// connectStateCallBack(BluetoothConnectionState.disconnected!); // connectStateCallBack(BluetoothConnectionState.disconnected!);
@ -366,7 +394,8 @@ class BlueManage {
print("调用了停止扫描的方法"); print("调用了停止扫描的方法");
await stopScan(); await stopScan();
if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") && isAddEquipment == false) { if ((scanResult!.advertisementData.serviceUuids[0].toString()[31] == "0") &&
isAddEquipment == false) {
connectStateCallBack(BluetoothConnectionState.disconnected); connectStateCallBack(BluetoothConnectionState.disconnected);
EasyLoading.showToast("该锁已被重置", duration: 2000.milliseconds); EasyLoading.showToast("该锁已被重置", duration: 2000.milliseconds);
return; return;
@ -403,12 +432,14 @@ class BlueManage {
" service.characteristics:${service.characteristics}" " service.characteristics:${service.characteristics}"
" service.includedServices:${service.includedServices}"); " service.includedServices:${service.includedServices}");
if (service.uuid == _serviceIdConnect) { if (service.uuid == _serviceIdConnect) {
for (BluetoothCharacteristic characteristic in service.characteristics) { for (BluetoothCharacteristic characteristic
in service.characteristics) {
// Get.log("22222characteristic.remoteId:${characteristic.remoteId}" // Get.log("22222characteristic.remoteId:${characteristic.remoteId}"
// " characteristic.uuid:${characteristic.uuid}" // " characteristic.uuid:${characteristic.uuid}"
// " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}" // " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
// " characteristic.characteristicUuid:${characteristic.characteristicUuid}"); // " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
if (characteristic.characteristicUuid == _characteristicIdSubscription) { if (characteristic.characteristicUuid ==
_characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic); _subScribeToCharacteristic(characteristic);
print('Discovering services finished'); print('Discovering services finished');
bluetoothConnectionState = BluetoothConnectionState.connected; bluetoothConnectionState = BluetoothConnectionState.connected;
@ -446,18 +477,21 @@ class BlueManage {
} }
// code to handle incoming data // code to handle incoming data
// print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data"); // print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) { if ((data[0] == 0xEF) &&
(data[1] == 0x01) &&
(data[2] == 0xEE) &&
(data[3] == 0x02)) {
// //
// //
dataLen = data[8] * 256 + data[9]; // 16 dataLen = data[8] * 256 + data[9]; // 16
print("dataLen1111:$dataLen getDataLength:${data.length} data:$data"); // print("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
if (dataLen! + 12 > data.length) { if (dataLen! + 12 > data.length) {
// //
allData.addAll(data); allData.addAll(data);
} else { } else {
// //
allData.addAll(data); allData.addAll(data);
print("dataLen2222:$dataLen getDataLength:${data.length}"); // print("dataLen2222:$dataLen getDataLength:${data.length}");
CommandReciverManager.appDataReceive(allData); CommandReciverManager.appDataReceive(allData);
// //
allData = <int>[]; allData = <int>[];
@ -466,7 +500,8 @@ class BlueManage {
// //
allData.addAll(data); allData.addAll(data);
// var len = allData[8] * 256 + allData[9]; // var len = allData[8] * 256 + allData[9];
print("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData"); print(
"dataLen3333:$dataLen allData.length:${allData.length} allData:$allData");
if ((dataLen! + 14) <= allData.length) { if ((dataLen! + 14) <= allData.length) {
print("44444数据被解析了"); print("44444数据被解析了");
// //
@ -530,44 +565,44 @@ class BlueManage {
// //
Future<void> writeCharacteristicWithResponse(List<int> value) async { Future<void> writeCharacteristicWithResponse(List<int> value) async {
bluetoothConnectDevice!.discoverServices().then((services) async { List<BluetoothService> services =
for (BluetoothService service in services) { await bluetoothConnectDevice!.discoverServices();
// print("33333 service.remoteId:${service.remoteId}" for (BluetoothService service in services) {
// " service.uuid:${service.uuid}\n\n" // print("33333 service.remoteId:${service.remoteId}"
// " service.characteristics:${service.characteristics}\n\n" // " service.uuid:${service.uuid}\n\n"
// " service.includedServices:${service.includedServices}"); // " service.characteristics:${service.characteristics}\n\n"
if (service.uuid == _serviceIdConnect) { // " service.includedServices:${service.includedServices}");
for (BluetoothCharacteristic characteristic in service.characteristics) { if (service.uuid == _serviceIdConnect) {
// print("44444 characteristic.remoteId:${characteristic.remoteId}" for (BluetoothCharacteristic characteristic
// " characteristic.uuid:${characteristic.uuid}\n\n" in service.characteristics) {
// " characteristic.secondaryServiceUuid:${characteristic // print("44444 characteristic.remoteId:${characteristic.remoteId}"
// .secondaryServiceUuid}\n\n" // " characteristic.uuid:${characteristic.uuid}\n\n"
// " characteristic.characteristicUuid:${characteristic // " characteristic.secondaryServiceUuid:${characteristic
// .characteristicUuid}"); // .secondaryServiceUuid}\n\n"
if (characteristic.characteristicUuid == _characteristicIdWrite) { // " characteristic.characteristicUuid:${characteristic
try { // .characteristicUuid}");
List<int> valueList = value; if (characteristic.characteristicUuid == _characteristicIdWrite) {
List subData = splitList(valueList, _mtuSize!); try {
print('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData'); List<int> valueList = value;
List subData = splitList(valueList, _mtuSize!);
for (int i = 0; i < subData.length; i++) { // print('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData');
await characteristic.write(subData[i]).then((value) async { for (int i = 0; i < subData.length; i++) {
await Future.delayed(const Duration(milliseconds: 1)).then(( await characteristic.write(subData[i],withoutResponse: true).then((value) async {
value) async { // await Future.delayed(const Duration(milliseconds: 1)).then((
print('分包发送成功了'); // value) async {
}); // print('分包发送成功了');
}); // });
} });
} on Exception catch (e, s) {
print('Error occurred when writing: $e');
// Get.log(s);
rethrow;
} }
} on Exception catch (e, s) {
print('Error occurred when writing: $e');
// Get.log(s);
rethrow;
} }
} }
} }
} }
}); }
// List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices(); // List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
// BluetoothCharacteristic characteristic = services // BluetoothCharacteristic characteristic = services
// .firstWhere((service) => service.uuid == _serviceIdWrite) // .firstWhere((service) => service.uuid == _serviceIdWrite)

View File

@ -0,0 +1,13 @@
// ignore_for_file: non_constant_identifier_names
class IoModelVendor {
static String vendor_XHJ = 'XHJ';
static String model_XHJ_SYD = 'SYD-BLE-01';
static String model_XHJ_JL = 'JL-BLE-01';
static String vendor_XL = 'XL';
static String model_XL_BLE = 'JL-BLE-01';
static String model_XL_WIFI = 'JL-WIFI-01';
}

View File

@ -0,0 +1,149 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:get/get.dart';
import '../io_tool/io_tool.dart';
import '../sm4Encipher/sm4.dart';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
//oat升级
class OTAUpgradeCommand extends SenderProtocol {
String? lockID;
String? userID;
String? keyID;
int? platform;
int? product;
String? hwVersion;
String? fwVersion;
int? fwSize;
String? fwMD5;
int? needAuthor;
List<int>? publicKey;
List<int>? privateKey;
List<int>? token;
OTAUpgradeCommand(
{this.lockID,
this.userID,
this.keyID,
this.platform,
this.product,
this.hwVersion,
this.fwVersion,
this.fwSize,
this.fwMD5,
this.needAuthor,
this.publicKey,
this.privateKey,
this.token})
: super(CommandType.startOATUpgrade);
@override
List<int> messageDetail() {
List<int> data = [];
List<int> ebcData = [];
//
int type = commandType!.typeValue;
double typeDouble = type / 256;
int type1 = typeDouble.toInt();
int type2 = type % 256;
data.add(type1);
data.add(type2);
// id 40
int lockIDLength = utf8.encode(lockID!).length;
data.addAll(utf8.encode(lockID!));
data = getFixedLengthList(data, 40 - lockIDLength);
//userID 20
int userIDLength = utf8.encode(userID!).length;
data.addAll(utf8.encode(userID!));
data = getFixedLengthList(data, 20 - userIDLength);
//platform 2
int platform0 = (platform! & 0xFF00) >> 8;
int platform1 = platform! & 0xFF;
data.add(platform0);
data.add(platform1);
//product 2
int product0 = (product! & 0xFF00) >> 8;
int product1 = product! & 0xFF;
data.add(product0);
data.add(product1);
//HwVersion 20
int hwVersionLength = utf8.encode(hwVersion!).length;
data.addAll(utf8.encode(hwVersion!));
data = getFixedLengthList(data, 20 - hwVersionLength);
//FwVersion 20
int fwVersionLength = utf8.encode(fwVersion!).length;
data.addAll(utf8.encode(fwVersion!));
data = getFixedLengthList(data, 20 - fwVersionLength);
//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);
// token 4 Token 0 token失效或者第一次发送的时候token为0
data.addAll(token!);
if (needAuthor == 0) {
//AuthCodeLen 1
data.add(0);
} else {
List<int> authCodeData = [];
//authUserID
authCodeData.addAll(utf8.encode(userID!));
//KeyID
authCodeData.addAll(utf8.encode(keyID!));
//token 4 Token 0
authCodeData.addAll(token!);
authCodeData.addAll(publicKey!);
// KeyIDauthUserIDmd5加密之后就是authCode
var authCode = crypto.md5.convert(authCodeData);
data.add(authCode.bytes.length);
data.addAll(authCode.bytes);
}
if ((data.length % 16) != 0) {
int add = (16 - data.length % 16);
for (int i = 0; i < add; i++) {
data.add(0);
}
}
Get.log("${commandType!.typeName} SM4Data:$data");
// LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
return ebcData;
}
}
class OTAUpgradeReply extends Reply {
OTAUpgradeReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
int status = data[6];
errorWithStstus(status);
}
}

View File

@ -0,0 +1,74 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:get/get.dart';
import '../io_tool/io_tool.dart';
import '../sm4Encipher/sm4.dart';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
//oat升级
class ProcessOtaUpgradeCommand extends SenderProtocol {
int? index;
int? size;
List<int>? data;
ProcessOtaUpgradeCommand({
this.index,
this.size,
this.data,
}) : super(CommandType.processOTAUpgrade);
@override
List<int> messageDetail() {
List<int> data = [];
//
int type = commandType!.typeValue;
double typeDouble = type / 256;
int type1 = typeDouble.toInt();
int type2 = type % 256;
data.add(type1);
data.add(type2);
//index 2
ByteData indexBytes = ByteData(2); // 4
indexBytes.setInt16(0, index!);
List<int> indexList = indexBytes.buffer.asUint8List();
data.addAll(indexList);
//size 2
ByteData bytes = ByteData(2); // 4
bytes.setInt16(0, size!);
List<int> byteList = bytes.buffer.asUint8List();
data.addAll(byteList);
data.addAll(this.data!);
//
return data;
}
}
class ProcessOtaUpgradeReply extends Reply {
ProcessOtaUpgradeReply.parseData(
CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
int status = data[2];
errorWithStstus(status);
}
}
class ConfirmationOTAUpgradeReply extends Reply {
ConfirmationOTAUpgradeReply.parseData(
CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
int status = data[2];
errorWithStstus(status);
}
}

View File

@ -14,11 +14,11 @@ abstract class Reply{
Reply.parseData(this.commandType, List<int> dataDetail); Reply.parseData(this.commandType, List<int> dataDetail);
void errorWithStstus(int status){ void errorWithStstus(int status){
Get.log("errorWithStstus status:$status commandType:$commandType"); // Get.log("errorWithStstus status:$status commandType:$commandType");
switch(status){ switch(status){
case 0x00: case 0x00:
// //
Get.log("$commandType成功"); // Get.log("$commandType成功");
break; break;
case 0x01: case 0x01:
// //
@ -134,4 +134,9 @@ abstract class Reply{
void showErrorMessage(String message){ void showErrorMessage(String message){
EasyLoading.showToast(message, duration: 2000.milliseconds); EasyLoading.showToast(message, duration: 2000.milliseconds);
} }
@override
String toString() {
return 'Reply{commandType: $commandType, status: $status, data: $data}';
}
} }

View File

@ -12,11 +12,17 @@ abstract class SenderProtocol extends IOData {
// var uint8View1 = Uint8List(300); // var uint8View1 = Uint8List(300);
CommandType? commandType; // CommandType? commandType; //
final List<int> header = [0XEF, 0X01, 0XEE, 0X02]; // 0XEF01EE02 4 final List<int> header = [
final int ask = 0X01 ; // 0X01 0X11 1 0XEF,
0X01,
0XEE,
0X02
]; // 0XEF01EE02 4
final int ask = 0X01; // 0X01 0X11 1
int? _commandIndex = 1; // int? _commandIndex = 1; //
int identifier = 0x20; // 4 4 1 01AES1282SM43SM4 int identifier =
0x20; // 4 4 1 01AES1282SM43SM4
List<int>? commandData = []; // List<int>? commandData = []; //
// final int? tail = 0xFF; // CRC 2 // final int? tail = 0xFF; // CRC 2
@ -40,9 +46,9 @@ abstract class SenderProtocol extends IOData {
// //
int commandIndexChange = _commandIndex!; int commandIndexChange = _commandIndex!;
double commandIndexChangeDouble = commandIndexChange/256; double commandIndexChangeDouble = commandIndexChange / 256;
int commandIndexChang1 = commandIndexChangeDouble.toInt(); int commandIndexChang1 = commandIndexChangeDouble.toInt();
int commandIndexChang2 = commandIndexChange%256; int commandIndexChang2 = commandIndexChange % 256;
commandList.add(commandIndexChang1); commandList.add(commandIndexChang1);
commandList.add(commandIndexChang2); commandList.add(commandIndexChang2);
// print("_commandIndex:$_commandIndex commandIndexChang1$commandIndexChang1 commandIndexChang2:$commandIndexChang2"); // print("_commandIndex:$_commandIndex commandIndexChang1$commandIndexChang1 commandIndexChang2:$commandIndexChang2");
@ -57,11 +63,11 @@ abstract class SenderProtocol extends IOData {
// commandList.add(dataLength); // commandList.add(dataLength);
// print("dataLen:$dataLen"); // print("dataLen:$dataLen");
// var dataLen = 42; // var dataLen = 42;
double dataLength = dataLen/256; double dataLength = dataLen / 256;
commandList.add(dataLength.toInt()); commandList.add(dataLength.toInt());
commandList.add(dataLen%256); commandList.add(dataLen % 256);
commandList.add(dataLength.toInt()); commandList.add(dataLength.toInt());
commandList.add(dataLen%256); commandList.add(dataLen % 256);
// //
commandList.addAll(commandData!); // commandList.addAll(commandData!); //
@ -69,46 +75,284 @@ abstract class SenderProtocol extends IOData {
// //
var mcrc = crc_16(commandList); var mcrc = crc_16(commandList);
double mcrcDouble = mcrc/256; double mcrcDouble = mcrc / 256;
int mcrcDouble1 = mcrcDouble.toInt(); int mcrcDouble1 = mcrcDouble.toInt();
int mcrcDouble2 = mcrc%256; int mcrcDouble2 = mcrc % 256;
commandList.add(mcrcDouble1); // commandList.add(mcrcDouble1); //
commandList.add(mcrcDouble2); commandList.add(mcrcDouble2);
// print("mcrc:$mcrc");
// print("mcrcDouble1:$mcrcDouble1");
// print("mcrcDouble2:$mcrcDouble2");
return commandList; return commandList;
} }
//TODO: //TODO:
int dataSourceLength() => commandData!.length; int dataSourceLength() => commandData!.length;
var crcTable =[ var crcTable = [
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x0000,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x1021,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x2042,
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x3063,
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x4084,
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x50a5,
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x60c6,
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x70e7,
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x8108,
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0x9129,
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa14a,
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xb16b,
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xc18c,
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xd1ad,
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xe1ce,
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0]; 0xf1ef,
0x1231,
0x0210,
0x3273,
0x2252,
0x52b5,
0x4294,
0x72f7,
0x62d6,
0x9339,
0x8318,
0xb37b,
0xa35a,
0xd3bd,
0xc39c,
0xf3ff,
0xe3de,
0x2462,
0x3443,
0x0420,
0x1401,
0x64e6,
0x74c7,
0x44a4,
0x5485,
0xa56a,
0xb54b,
0x8528,
0x9509,
0xe5ee,
0xf5cf,
0xc5ac,
0xd58d,
0x3653,
0x2672,
0x1611,
0x0630,
0x76d7,
0x66f6,
0x5695,
0x46b4,
0xb75b,
0xa77a,
0x9719,
0x8738,
0xf7df,
0xe7fe,
0xd79d,
0xc7bc,
0x48c4,
0x58e5,
0x6886,
0x78a7,
0x0840,
0x1861,
0x2802,
0x3823,
0xc9cc,
0xd9ed,
0xe98e,
0xf9af,
0x8948,
0x9969,
0xa90a,
0xb92b,
0x5af5,
0x4ad4,
0x7ab7,
0x6a96,
0x1a71,
0x0a50,
0x3a33,
0x2a12,
0xdbfd,
0xcbdc,
0xfbbf,
0xeb9e,
0x9b79,
0x8b58,
0xbb3b,
0xab1a,
0x6ca6,
0x7c87,
0x4ce4,
0x5cc5,
0x2c22,
0x3c03,
0x0c60,
0x1c41,
0xedae,
0xfd8f,
0xcdec,
0xddcd,
0xad2a,
0xbd0b,
0x8d68,
0x9d49,
0x7e97,
0x6eb6,
0x5ed5,
0x4ef4,
0x3e13,
0x2e32,
0x1e51,
0x0e70,
0xff9f,
0xefbe,
0xdfdd,
0xcffc,
0xbf1b,
0xaf3a,
0x9f59,
0x8f78,
0x9188,
0x81a9,
0xb1ca,
0xa1eb,
0xd10c,
0xc12d,
0xf14e,
0xe16f,
0x1080,
0x00a1,
0x30c2,
0x20e3,
0x5004,
0x4025,
0x7046,
0x6067,
0x83b9,
0x9398,
0xa3fb,
0xb3da,
0xc33d,
0xd31c,
0xe37f,
0xf35e,
0x02b1,
0x1290,
0x22f3,
0x32d2,
0x4235,
0x5214,
0x6277,
0x7256,
0xb5ea,
0xa5cb,
0x95a8,
0x8589,
0xf56e,
0xe54f,
0xd52c,
0xc50d,
0x34e2,
0x24c3,
0x14a0,
0x0481,
0x7466,
0x6447,
0x5424,
0x4405,
0xa7db,
0xb7fa,
0x8799,
0x97b8,
0xe75f,
0xf77e,
0xc71d,
0xd73c,
0x26d3,
0x36f2,
0x0691,
0x16b0,
0x6657,
0x7676,
0x4615,
0x5634,
0xd94c,
0xc96d,
0xf90e,
0xe92f,
0x99c8,
0x89e9,
0xb98a,
0xa9ab,
0x5844,
0x4865,
0x7806,
0x6827,
0x18c0,
0x08e1,
0x3882,
0x28a3,
0xcb7d,
0xdb5c,
0xeb3f,
0xfb1e,
0x8bf9,
0x9bd8,
0xabbb,
0xbb9a,
0x4a75,
0x5a54,
0x6a37,
0x7a16,
0x0af1,
0x1ad0,
0x2ab3,
0x3a92,
0xfd2e,
0xed0f,
0xdd6c,
0xcd4d,
0xbdaa,
0xad8b,
0x9de8,
0x8dc9,
0x7c26,
0x6c07,
0x5c64,
0x4c45,
0x3ca2,
0x2c83,
0x1ce0,
0x0cc1,
0xef1f,
0xff3e,
0xcf5d,
0xdf7c,
0xaf9b,
0xbfba,
0x8fd9,
0x9ff8,
0x6e17,
0x7e36,
0x4e55,
0x5e74,
0x2e93,
0x3eb2,
0x0ed1,
0x1ef0
];
int crc_16(buffer) { int crc_16(buffer) {
var len = buffer.length; var len = buffer.length;
var value_ = 0x0000;//0xa635; //CRC类型设定 var value_ = 0x0000; //0xa635; //CRC类型设定
var tmp; var tmp;
for (var i = 0; i < buffer.length; i++) for (var i = 0; i < buffer.length; i++) {
{
tmp = reverse8(buffer[i]); tmp = reverse8(buffer[i]);
value_ = ((value_ << 8) ^ crcTable[((value_ >> 8) ^ tmp) & 0xFF]) & 0xFFFF; value_ =
((value_ << 8) ^ crcTable[((value_ >> 8) ^ tmp) & 0xFF]) & 0xFFFF;
} }
value_ = reverse16(value_); value_ = reverse16(value_);
return value_; return value_;
@ -116,22 +360,21 @@ abstract class SenderProtocol extends IOData {
int reverse8(data) { int reverse8(data) {
var i; var i;
var temp=0; var temp = 0;
for(i=0;i<8;i++) { for (i = 0; i < 8; i++) {
// //
temp |= ((data>>i) & 0x01)<<(7-i); temp |= ((data >> i) & 0x01) << (7 - i);
} }
return temp; return temp;
} }
int reverse16(data) { int reverse16(data) {
var i; var i;
var temp=0; var temp = 0;
for(i=0;i<16;i++) { for (i = 0; i < 16; i++) {
// //
temp |= ((data>>i) & 0x0001)<<(15-i); temp |= ((data >> i) & 0x0001) << (15 - i);
} }
return temp; return temp;
} }
}
}

View File

@ -1,15 +1,12 @@
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
/// ///
enum DataChannel{ enum DataChannel { ble, udp }
ble,
udp
}
extension Extension on DataChannel { extension Extension on DataChannel {
bool get isBLE => this == DataChannel.ble; bool get isBLE => this == DataChannel.ble;
bool get isUDP => this == DataChannel.udp;
bool get isUDP => this == DataChannel.udp;
} }
class EventSendModel { class EventSendModel {
@ -20,8 +17,16 @@ class EventSendModel {
String? deviceId; String? deviceId;
Uuid? serviceId; Uuid? serviceId;
Uuid? characteristicId; Uuid? characteristicId;
bool? allowLongWrite = false;
EventSendModel({required this.data,this.topic,this.sendChannel, this.deviceId, this.serviceId, this.characteristicId}); EventSendModel(
{required this.data,
this.topic,
this.sendChannel,
this.deviceId,
this.serviceId,
this.characteristicId,
this.allowLongWrite});
} }
/// ///
@ -30,26 +35,23 @@ class EventReceiveModel {
String? tag = ''; String? tag = '';
DataChannel? sendChannel; DataChannel? sendChannel;
EventReceiveModel({ EventReceiveModel({required this.data, this.sendChannel, this.tag});
required this.data,
this.sendChannel,
this.tag});
} }
/// ///
class EventParseModel { class EventParseModel {
int? type; int? type;
int? commandIndex; int? commandIndex;
dynamic data; dynamic data;
EventParseModel({required this.type, required this.data, this.commandIndex}); EventParseModel({required this.type, required this.data, this.commandIndex});
} }
///debug info model ///debug info model
class StateModel { class StateModel {
final String title; final String title;
final String subTitle; final String subTitle;
final bool result; final bool result;
StateModel({this.title= '',this.subTitle = '',this.result = false});
} StateModel({this.title = '', this.subTitle = '', this.result = false});
}

View File

@ -1,4 +1,3 @@
//TODO: //TODO:
enum CommandType { enum CommandType {
addUser, // = 0x3001 addUser, // = 0x3001
@ -13,6 +12,9 @@ enum CommandType {
getLockPrivateKey, // = 0x3091 getLockPrivateKey, // = 0x3091
calibrationTime, // = 0x30f0 calibrationTime, // = 0x30f0
readStarLockStatusInfo, // 0x3040 readStarLockStatusInfo, // 0x3040
startOATUpgrade, //OTA升级开始 0x30E0
confirmationOTAUpgrade, //OTA升级开始 0x30E1
processOTAUpgrade, //OTA升级过程 0x30E2
generalExtendedCommond, // = 0x3030 generalExtendedCommond, // = 0x3030
gecChangeAdministratorPassword, // - = 2 gecChangeAdministratorPassword, // - = 2
@ -41,11 +43,10 @@ enum CommandType {
gecAddFaceConfirmation, // - = 84 gecAddFaceConfirmation, // - = 84
} }
extension ExtensionCommandType on CommandType { extension ExtensionCommandType on CommandType {
static CommandType getCommandType(int value) {
static CommandType getCommandType(int value){
CommandType type = CommandType.readLockStatusInfo; CommandType type = CommandType.readLockStatusInfo;
switch(value){ switch (value) {
case 0x3001: case 0x3001:
{ {
type = CommandType.addUser; type = CommandType.addUser;
@ -111,6 +112,21 @@ extension ExtensionCommandType on CommandType {
type = CommandType.readStarLockStatusInfo; type = CommandType.readStarLockStatusInfo;
} }
break; break;
case 0x30E0:
{
type = CommandType.startOATUpgrade;
}
break;
case 0x30E1:
{
type = CommandType.processOTAUpgrade;
}
break;
case 0x30E2:
{
type = CommandType.confirmationOTAUpgrade;
}
break;
default: default:
{ {
type = CommandType.readLockStatusInfo; type = CommandType.readLockStatusInfo;
@ -122,7 +138,7 @@ extension ExtensionCommandType on CommandType {
int get typeValue { int get typeValue {
int type = 0x300A; int type = 0x300A;
switch(this){ switch (this) {
case CommandType.addUser: case CommandType.addUser:
type = 0x3001; type = 0x3001;
break; break;
@ -162,6 +178,15 @@ extension ExtensionCommandType on CommandType {
case CommandType.readStarLockStatusInfo: case CommandType.readStarLockStatusInfo:
type = 0x3040; type = 0x3040;
break; break;
case CommandType.startOATUpgrade:
type = 0x30E0;
break;
case CommandType.processOTAUpgrade:
type = 0x30E1;
break;
case CommandType.confirmationOTAUpgrade:
type = 0x30E2;
break;
default: default:
type = 0x300A; type = 0x300A;
break; break;
@ -171,10 +196,13 @@ extension ExtensionCommandType on CommandType {
return type; return type;
} }
//
int get identifierValue { int get identifierValue {
int type = 0x23; int type = 0x23;
switch(this){ switch (this) {
case CommandType.getLockPublicKey: case CommandType.getLockPublicKey:
case CommandType.processOTAUpgrade:
//
type = 0x20; type = 0x20;
break; break;
case CommandType.getLockPrivateKey: case CommandType.getLockPrivateKey:
@ -187,64 +215,73 @@ extension ExtensionCommandType on CommandType {
return type; return type;
} }
String get typeName { String get typeName {
String t = ''; String t = '';
switch(typeValue){ switch (typeValue) {
case 0x3001: case 0x3001:
t = '增加用户'; t = '增加用户';
break; break;
case 0x3002: case 0x3002:
t = '删除用户'; t = '删除用户';
break; break;
case 0x3003: case 0x3003:
t = '修改用户'; t = '修改用户';
break; break;
case 0x3004: case 0x3004:
t = '恢复出厂设置'; t = '恢复出厂设置';
break; break;
case 0x3005: case 0x3005:
t = '开门'; t = '开门';
break; break;
case 0x300A: case 0x300A:
t = '读取锁状态信息'; t = '读取锁状态信息';
break; break;
case 0x300B: case 0x300B:
t = '转移权限'; t = '转移权限';
break; break;
case 0x3020: case 0x3020:
t = '开门记录上报'; t = '开门记录上报';
break; break;
case 0x3030: case 0x3030:
t = '通用扩展指令'; t = '通用扩展指令';
break; break;
case 0x3090: case 0x3090:
t = '获取锁公钥'; t = '获取锁公钥';
break; break;
case 0x3091: case 0x3091:
t = '获取锁私钥'; t = '获取锁私钥';
break; break;
case 0x30f0: case 0x30f0:
t = '校时'; t = '校时';
break; break;
case 0x30f1: case 0x30f1:
t = '同步位置信息'; t = '同步位置信息';
break; break;
case 0x30f2: case 0x30f2:
t = '运维开锁'; t = '运维开锁';
break; break;
case 0x3016: case 0x3016:
t = '写酒店信息'; t = '写酒店信息';
break; break;
case 0x3017: case 0x3017:
t = '读酒店信息'; t = '读酒店信息';
break; break;
case 0x3040: case 0x3040:
t = '读星锁状态信息'; t = '读星锁状态信息';
break;
case 0x30E0:
t = 'oat升级';
break;
case 0x30E2:
t = '确认oat升级';
break;
case 0x30E1:
t = 'oat升级过程';
break; break;
default: default:
t = '读星锁状态信息'; t = '读星锁状态信息';
break; break;
} }
return t; return t;
} }
} }

View File

@ -9,6 +9,8 @@ import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
import 'package:star_lock/blue/io_protocol/io_editUser.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart';
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart'; import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
@ -20,11 +22,14 @@ import 'package:star_lock/blue/io_protocol/io_timing.dart';
import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart'; import 'package:star_lock/blue/io_protocol/io_transferPermissions.dart';
import '../tools/storage.dart'; import '../tools/storage.dart';
// import 'io_protocol/io_addFingerprint.dart'; // import 'io_protocol/io_addFingerprint.dart';
import 'io_protocol/io_addFingerprintWithTimeCycleCoercion.dart'; import 'io_protocol/io_addFingerprintWithTimeCycleCoercion.dart';
// import 'io_protocol/io_addICCard.dart'; // import 'io_protocol/io_addICCard.dart';
import 'io_protocol/io_addICCardWithTimeCycleCoercion.dart'; import 'io_protocol/io_addICCardWithTimeCycleCoercion.dart';
import 'io_protocol/io_addStressFingerprint.dart'; import 'io_protocol/io_addStressFingerprint.dart';
// import 'io_protocol/io_addStressICCard.dart'; // import 'io_protocol/io_addStressICCard.dart';
import 'io_protocol/io_addStressPassword.dart'; import 'io_protocol/io_addStressPassword.dart';
import 'io_protocol/io_addUser.dart'; import 'io_protocol/io_addUser.dart';
@ -59,7 +64,7 @@ class CommandReciverManager {
return; return;
} }
Get.log("appDataReceiveData:$data"); // &&(data[4] == 0x11) // Get.log("appDataReceiveData:$data"); // &&(data[4] == 0x11)
if ((data[0] == 0xEF) && if ((data[0] == 0xEF) &&
(data[1] == 0x01) && (data[1] == 0x01) &&
(data[2] == 0xEE) && (data[2] == 0xEE) &&
@ -69,7 +74,7 @@ class CommandReciverManager {
var dataLen = data[8] * 256 + data[9]; // 16 var dataLen = data[8] * 256 + data[9]; // 16
var oriLen = data[10] * 256 + data[11]; // 16 var oriLen = data[10] * 256 + data[11]; // 16
print("dataLen:$dataLen oriLen:$oriLen"); // print("dataLen:$dataLen oriLen:$oriLen");
// List<int> dataList = []; // List<int> dataList = [];
List<int> oriDataList = []; List<int> oriDataList = [];
switch (tmpType) { switch (tmpType) {
@ -109,11 +114,11 @@ class CommandReciverManager {
oriDataList = SM4.decrypt(getDataList, oriDataList = SM4.decrypt(getDataList,
key: getPrivateKeyList, mode: SM4CryptoMode.ECB); key: getPrivateKeyList, mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen); oriDataList = oriDataList.sublist(0, oriLen);
print("SM4 oriDataList:$oriDataList"); // print("SM4 oriDataList:$oriDataList");
break; break;
} }
parseData(oriDataList).then((value) async { parseData(oriDataList).then((value) async {
Get.log("parseData222 data:$value"); // Get.log("parseData222 data:$value");
EasyLoading.dismiss(); EasyLoading.dismiss();
await EventBusManager().eventBusFir(value); await EventBusManager().eventBusFir(value);
}).catchError((error) { }).catchError((error) {
@ -129,7 +134,7 @@ class CommandReciverManager {
CommandType commandType = ExtensionCommandType.getCommandType(cmd); CommandType commandType = ExtensionCommandType.getCommandType(cmd);
await IoManager().increaseCommandIndex(); await IoManager().increaseCommandIndex();
// data.removeRange(0, 2); // data.removeRange(0, 2);
Get.log("parseData cmd:$cmd commandType:$commandType data:$data"); // Get.log("parseData cmd:$cmd commandType:$commandType data:$data");
var reply; var reply;
switch (commandType) { switch (commandType) {
case CommandType.getLockPublicKey: case CommandType.getLockPublicKey:
@ -154,7 +159,7 @@ class CommandReciverManager {
break; break;
case CommandType.openLock: case CommandType.openLock:
{ {
Get.log("openLockReply data:$data"); // Get.log("openLockReply data:$data");
reply = OpenDoorReply.parseData(commandType, data); reply = OpenDoorReply.parseData(commandType, data);
} }
break; break;
@ -189,6 +194,21 @@ class CommandReciverManager {
reply = GetStarLockStatuInfoReply.parseData(commandType, data); reply = GetStarLockStatuInfoReply.parseData(commandType, data);
} }
break; break;
case CommandType.startOATUpgrade:
{
reply = OTAUpgradeReply.parseData(commandType, data);
}
break;
case CommandType.confirmationOTAUpgrade:
{
reply = ConfirmationOTAUpgradeReply.parseData(commandType, data);
}
break;
case CommandType.processOTAUpgrade:
{
reply = ProcessOtaUpgradeReply.parseData(commandType, data);
}
break;
case CommandType.generalExtendedCommond: case CommandType.generalExtendedCommond:
{ {
// //
@ -279,8 +299,9 @@ class CommandReciverManager {
case 36: case 36:
{ {
// (...) // (...)
reply = SenderAddFingerprintWithTimeCycleCoercionReply.parseData( reply =
commandType, data); SenderAddFingerprintWithTimeCycleCoercionReply.parseData(
commandType, data);
} }
break; break;
case 40: case 40:

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import '../app_settings/app_settings.dart'; import '../app_settings/app_settings.dart';
@ -11,22 +10,26 @@ import 'io_tool/manager_event_bus.dart';
import 'sender_beforeDataManage.dart'; import 'sender_beforeDataManage.dart';
typedef CommandSendCallBack = void Function(ErrorType errorType); typedef CommandSendCallBack = void Function(ErrorType errorType);
class CommandSenderManager {
class CommandSenderManager {
static final CommandSenderManager _manager = CommandSenderManager._init(); static final CommandSenderManager _manager = CommandSenderManager._init();
factory CommandSenderManager()=>_manager;
static CommandSenderManager getInstance()=>_manager; factory CommandSenderManager() => _manager;
CommandSenderManager._init(){
static CommandSenderManager getInstance() => _manager;
CommandSenderManager._init() {
init(); init();
} }
init(){ init() {
initLockAddUserSucceedEvent(); initLockAddUserSucceedEvent();
} }
// //
StreamSubscription? _passCurrentLockInformationEvent; StreamSubscription? _passCurrentLockInformationEvent;
List<int> dataBeforeAddTheUser = []; List<int> dataBeforeAddTheUser = [];
void initLockAddUserSucceedEvent() { void initLockAddUserSucceedEvent() {
// eventBus // eventBus
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) { _passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
@ -55,7 +58,7 @@ class CommandSenderManager {
} }
List<int> value = command.packageData(); List<int> value = command.packageData();
print("CommonDataManage().currentLockUserNo:${CommonDataManage().currentLockUserNo}"); // print("CommonDataManage().currentLockUserNo:${CommonDataManage().currentLockUserNo}");
if(CommonDataManage().currentLockUserNo == 0){ if(CommonDataManage().currentLockUserNo == 0){
// //
var entity = await SenderBeforeDataManage().getAddUserKeyData(); var entity = await SenderBeforeDataManage().getAddUserKeyData();
@ -63,7 +66,7 @@ class CommandSenderManager {
dataBeforeAddTheUser = value; dataBeforeAddTheUser = value;
return; return;
}else{ }else{
print("继续发送数据了继续发送数据了继续发送数据了"); // print("继续发送数据了继续发送数据了继续发送数据了");
_sendNormalData(value); _sendNormalData(value);
} }
} }
@ -132,4 +135,4 @@ class CommandSenderManager {
dispose() { dispose() {
_passCurrentLockInformationEvent?.cancel(); _passCurrentLockInformationEvent?.cancel();
} }
} }

View File

@ -1,9 +1,12 @@
import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart';
// import 'package:star_lock/blue/io_protocol/io_addICCard.dart'; // import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
// import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart'; // import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart';
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart'; import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
import 'package:star_lock/blue/io_protocol/io_processOtaUpgrade.dart';
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
@ -359,23 +362,22 @@ class IoSenderManage {
//todo:(...) //todo:(...)
static void senderAddFingerprintWithTimeCycleCoercionCommand( static void senderAddFingerprintWithTimeCycleCoercionCommand(
{ {required String? keyID,
required String? keyID, required String? userID,
required String? userID, required int? fingerNo,
required int? fingerNo, required int? useCountLimit,
required int? useCountLimit, required int? isForce,
required int? isForce, required List<int>? token,
required List<int>? token, required int? isRound,
required int? isRound, required int? weekRound,
required int? weekRound, required int? startDate,
required int? startDate, required int? endDate,
required int? endDate, required String? startTime,
required String? startTime, required String? endTime,
required String? endTime, required int? needAuthor,
required int? needAuthor, required List<int>? signKey,
required List<int>? signKey, required List<int>? privateKey,
required List<int>? privateKey, CommandSendCallBack? callBack}) {
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData( CommandSenderManager().managerSendData(
command: SenderAddFingerprintWithTimeCycleCoercionCommand( command: SenderAddFingerprintWithTimeCycleCoercionCommand(
keyID: keyID, keyID: keyID,
@ -428,23 +430,22 @@ class IoSenderManage {
//todo:(...) //todo:(...)
static void senderAddCardWithTimeCycleCoercionCommand( static void senderAddCardWithTimeCycleCoercionCommand(
{ {required String? keyID,
required String? keyID, required String? userID,
required String? userID, required int? cardNo,
required int? cardNo, required int? useCountLimit,
required int? useCountLimit, required int? isForce,
required int? isForce, required List<int>? token,
required List<int>? token, required int? isRound,
required int? isRound, required int? weekRound,
required int? weekRound, required int? startDate,
required int? startDate, required int? endDate,
required int? endDate, required String? startTime,
required String? startTime, required String? endTime,
required String? endTime, required int? needAuthor,
required int? needAuthor, required List<int>? signKey,
required List<int>? signKey, required List<int>? privateKey,
required List<int>? privateKey, CommandSendCallBack? callBack}) {
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData( CommandSenderManager().managerSendData(
command: SenderAddICCardWithTimeCycleCoercionCommand( command: SenderAddICCardWithTimeCycleCoercionCommand(
keyID: keyID, keyID: keyID,
@ -469,20 +470,20 @@ class IoSenderManage {
//todo: //todo:
static void senderAddFaceCommand( static void senderAddFaceCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
required int? faceNo, required int? faceNo,
required int? useCountLimit, required int? useCountLimit,
required int? isForce, required int? isForce,
required List<int>? token, required List<int>? token,
required int? isRound, required int? isRound,
required int? weekRound, required int? weekRound,
required int? startDate, required int? startDate,
required int? endDate, required int? endDate,
required String? startTime, required String? startTime,
required String? endTime, required String? endTime,
required int? needAuthor, required int? needAuthor,
required List<int>? signKey, required List<int>? signKey,
required List<int>? privateKey, required List<int>? privateKey,
CommandSendCallBack? callBack}) { CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData( CommandSenderManager().managerSendData(
command: SenderAddFaceCommand( command: SenderAddFaceCommand(
@ -709,12 +710,12 @@ class IoSenderManage {
//todo:wifi列表 //todo:wifi列表
static void getWifiListCommand( static void getWifiListCommand(
{required String? keyID, {required String? keyID,
required String? userID, required String? userID,
required List<int>? token, required List<int>? token,
required int? needAuthor, required int? needAuthor,
required List<int>? publicKey, required List<int>? publicKey,
required List<int>? privateKey, required List<int>? privateKey,
CommandSendCallBack? callBack}) { CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData( CommandSenderManager().managerSendData(
command: SenderGetWifiCommand( command: SenderGetWifiCommand(
keyID: keyID, keyID: keyID,
@ -977,4 +978,54 @@ class IoSenderManage {
), ),
callBack: callBack); callBack: callBack);
} }
//ota
static void senderOTAUpgradeCommand(
{required String? lockID,
required String? userID,
required String? keyID,
required int? platform,
required int? product,
required String? hwVersion,
required String? fwVersion,
required int? fwSize,
required String? fwMD5,
required int? needAuthor,
required List<int>? token,
required List<int>? publicKey,
required List<int>? privateKey,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: OTAUpgradeCommand(
lockID: lockID,
userID: userID,
keyID: keyID,
platform: platform,
product: product,
hwVersion: hwVersion,
fwVersion: fwVersion,
fwSize: fwSize,
fwMD5: fwMD5,
token: token,
needAuthor: needAuthor,
publicKey: publicKey,
privateKey: privateKey,
),
callBack: callBack);
}
//ota
static void senderProcessOtaUpgradeCommand(
{required int? index,
required int? size,
required List<int>? data,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: ProcessOtaUpgradeCommand(
index: index,
size: size,
data: data,
),
callBack: callBack);
}
} }

View File

@ -50,6 +50,7 @@ class _AddCardManageTabbarState extends State<AddCardManageTabbar>
length: widget.fromType == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length, length: widget.fromType == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length,
initialIndex: widget.initialIndex); initialIndex: widget.initialIndex);
_tabController.addListener(() { _tabController.addListener(() {
print("_tabController.indexIsChanging:${_tabController.indexIsChanging} _tabController.index:${_tabController.index}");
if (_tabController.animation!.value == _tabController.index) { if (_tabController.animation!.value == _tabController.index) {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
} }
@ -107,8 +108,8 @@ class _AddCardManageTabbarState extends State<AddCardManageTabbar>
controller: _tabController, controller: _tabController,
children: children:
widget.fromType == 1 widget.fromType == 1
? _itemTabs.map((ItemView item) => AddCardPage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName: widget.fromTypeTwoStaffName)).toList() ? _itemTabs.map((ItemView item) => AddCardPage()).toList()
: _fromCheckInTypeItemTabs.map((ItemView item) => AddCardPage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName: widget.fromTypeTwoStaffName)).toList(), : _fromCheckInTypeItemTabs.map((ItemView item) => AddCardPage()).toList(),
), ),
); );
} }

View File

@ -12,21 +12,23 @@ class AddCardTypeLogic extends BaseGetXController{
// //
void addCardData() async { void addCardData() async {
var fingerprintType = 0; // :1;23:4 var carType = 0; // :1;23:4
var startDate = ""; var startDate = "";
var endDate = ""; var endDate = "";
var startTime = ""; var startTime = "";
var endTime = ""; var endTime = "";
if (state.selectType.value == "0") { if (state.selectType.value == "0") {
fingerprintType = 1; print("永久卡永久卡永久卡");
carType = 1;
startDate = "0"; startDate = "0";
endDate = "0"; endDate = "0";
startTime = "0"; startTime = "0";
endTime = "0"; endTime = "0";
} else if (state.selectType.value == "1") { } else if (state.selectType.value == "1") {
fingerprintType = 2; print("限时卡限时卡限时卡");
startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); carType = 2;
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString();
startTime = "0"; startTime = "0";
endTime = "0"; endTime = "0";
@ -49,15 +51,16 @@ class AddCardTypeLogic extends BaseGetXController{
return; return;
} }
} else if (state.selectType.value == "2") { } else if (state.selectType.value == "2") {
if (state.beginTime.value.isEmpty) { print("循环卡循环卡循环卡");
if (state.cycleBeginTime.value.isEmpty) {
showToast("请选择有效期".tr); showToast("请选择有效期".tr);
return; return;
} }
startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString(); startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString(); startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString();
endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString(); endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
fingerprintType = 4; carType = 4;
} }
// var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1: 2: // var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1: 2:
@ -67,7 +70,7 @@ class AddCardTypeLogic extends BaseGetXController{
"addType": "1", "addType": "1",
"cardName": state.nameController.text, "cardName": state.nameController.text,
"cardNumber": "123456", "cardNumber": "123456",
"cardType": fingerprintType.toString(), "cardType": carType.toString(),
"isCoerced": state.isStressFingerprint.value == false ? "1" : "2", "isCoerced": state.isStressFingerprint.value == false ? "1" : "2",
"startDate": startDate, "startDate": startDate,
"weekDay": state.weekdaysList.value, "weekDay": state.weekdaysList.value,

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -8,110 +9,113 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
import '../../../../tools/dateTool.dart'; import '../../../../tools/dateTool.dart';
import '../../../../tools/storage.dart'; import '../../../../tools/storage.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart'; import '../../../../translations/trans_lib.dart';
import 'addCardType_logic.dart'; import 'addCardType_logic.dart';
class AddCardPage extends StatefulWidget { class AddCardPage extends StatefulWidget {
final String selectType; // const AddCardPage({Key? key}) : super(key: key);
final int lockId;
final int fromType; // // 1 2
final String fromTypeTwoStaffName; //
const AddCardPage(
{Key? key,
required this.selectType,
required this.lockId,
required this.fromType,
required this.fromTypeTwoStaffName})
: super(key: key);
@override @override
State<AddCardPage> createState() => _AddCardPageState(); State<AddCardPage> createState() => _AddCardPageState();
} }
class _AddCardPageState extends State<AddCardPage> { class _AddCardPageState extends State<AddCardPage> with SingleTickerProviderStateMixin {
final logic = Get.put(AddCardTypeLogic()); final logic = Get.put(AddCardTypeLogic());
final state = Get.find<AddCardTypeLogic>().state; final state = Get.find<AddCardTypeLogic>().state;
@override
Widget build(BuildContext context) {
state.selectType.value = widget.selectType;
state.lockId.value = widget.lockId;
if (widget.fromTypeTwoStaffName.isNotEmpty) {
state.nameController.text = widget.fromTypeTwoStaffName;
}
state.fromType.value = widget.fromType;
return SingleChildScrollView(
child: indexChangeWidget()
);
}
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) { state.tabController = TabController(
if (state.selectType.value == "1") { vsync: this,
state.beginTime.value = DateTool().dateToYMDHNString( length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length,
DateTime.now().millisecondsSinceEpoch.toString()); // initialIndex: 0);
state.endTime.value = DateTool().dateToYMDHNString( state.tabController.addListener(() {
DateTime.now().millisecondsSinceEpoch.toString()); // WidgetsBinding.instance.addPostFrameCallback((_) {
} else { state.selectType.value = state.tabController.index.toString();
state.beginTime.value = ""; // });
state.endTime.value = ""; //
if (state.tabController.animation!.value == state.tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
} }
}); });
} }
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.card!.tr}",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
_tabBar(),
_pageWidget(),
],
),
);
}
Widget indexChangeWidget() { Widget indexChangeWidget() {
switch (int.parse(widget.selectType)) { switch (int.parse(state.selectType.value)) {
case 0: case 0:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
TranslationLoader.lanKeys!.name!.tr, perpetualKeyWidget(
TranslationLoader.lanKeys!.pleaseEnter!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseEnter!.tr,
keyBottomWidget() state.nameController),
], keyBottomWidget()
],
),
); );
} }
case 1: case 1:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
TranslationLoader.lanKeys!.name!.tr, perpetualKeyWidget(
TranslationLoader.lanKeys!.pleaseEnter!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseEnter!.tr,
keyTimeLimitWidget(), state.nameController),
// SizedBox(height: 10.h), keyTimeLimitWidget(),
keyBottomWidget() // SizedBox(height: 10.h),
], keyBottomWidget()
],
),
); );
} }
case 2: case 2:
{ {
// //
return Column( return SingleChildScrollView(
children: [ child: Column(
perpetualKeyWidget( children: [
TranslationLoader.lanKeys!.name!.tr, perpetualKeyWidget(
TranslationLoader.lanKeys!.pleaseEnter!.tr, TranslationLoader.lanKeys!.name!.tr,
state.nameController), TranslationLoader.lanKeys!.pleaseEnter!.tr,
keyCyclicDate(), state.nameController),
SizedBox(height: 10.h), keyCyclicDate(),
keyBottomWidget() SizedBox(height: 10.h),
], keyBottomWidget()
],
),
); );
} }
default: default:
@ -140,23 +144,23 @@ class _AddCardPageState extends State<AddCardPage> {
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value, rightTitle: state.timeLimitBeginTime.value,
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) { onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value, rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) { onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1); state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1);
}); });
})), })),
Container(height: 10.h), Container(height: 10.h),
@ -170,21 +174,21 @@ class _AddCardPageState extends State<AddCardPage> {
children: [ children: [
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr, leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "${state.beginTime.value}\n${state.endTime.value}", rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: { var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value, 'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value, 'starDate': state.cycleBeginTime.value,
'endDate': state.endTime.value, 'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value, 'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value 'endTime': state.failureDateTime.value
}); });
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.endTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
} }
@ -197,18 +201,17 @@ class _AddCardPageState extends State<AddCardPage> {
isHaveDirection: true, isHaveDirection: true,
isHaveLine: true, isHaveLine: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
arguments: { 'validityValue': state.weekdaysList.value,
'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value,
'starDate': state.beginTime.value, 'endDate': state.cycleEndTime.value,
'endDate': state.endTime.value, 'starTime': state.effectiveDateTime.value,
'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value
'endTime': state.failureDateTime.value });
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.endTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
} }
@ -217,25 +220,22 @@ class _AddCardPageState extends State<AddCardPage> {
visible: state.effectiveDateTime.value.isNotEmpty, visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem( child: CommonItem(
leftTitel: "有效时间".tr, leftTitel: "有效时间".tr,
rightTitle: rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}",
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true, isHaveDirection: true,
action: () async { action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
arguments: { 'validityValue': state.weekdaysList.value,
'validityValue': state.weekdaysList.value, 'starDate': state.cycleBeginTime.value,
'starDate': state.beginTime.value, 'endDate': state.cycleEndTime.value,
'endDate': state.endTime.value, 'starTime': state.effectiveDateTime.value,
'starTime': state.effectiveDateTime.value, 'endTime': state.failureDateTime.value
'endTime': state.failureDateTime.value });
});
if (result != null && result.isNotEmpty) { if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue']; state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate']; state.cycleBeginTime.value = result['starDate'];
state.endTime.value = result['endDate']; state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime']; state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime']; state.failureDateTime.value = result['endTime'];
Get.back(result: result);
} }
}))), }))),
], ],
@ -290,25 +290,6 @@ class _AddCardPageState extends State<AddCardPage> {
); );
} }
String getAppBarTitle(int type) {
String title;
switch (type) {
case 0:
title = TranslationLoader.lanKeys!.stressCard!.tr;
break;
case 1:
title = TranslationLoader.lanKeys!.stressFingerprint!.tr;
break;
case 2:
title = TranslationLoader.lanKeys!.remoteControl!.tr;
break;
default:
title = "";
break;
}
return title;
}
// //
Widget getTFWidget(String tfStr) { Widget getTFWidget(String tfStr) {
return Container( return Container(
@ -387,4 +368,70 @@ class _AddCardPageState extends State<AddCardPage> {
}, },
); );
} }
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"),
];
final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
];
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode());
},
tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
child: SizedBox(
width: 1.sw / 5,
child: Text(item.title, textAlign: TextAlign.center)));
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: state.tabController,
children:
state.fromType.value == 1
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList()
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(),
),
);
}
} }
class ItemView {
const ItemView({required this.title, required this.selectType});
final String title;
final String selectType;
}

View File

@ -2,6 +2,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../../tools/dateTool.dart';
class AddCardTypeState{ class AddCardTypeState{
final lockId = 0.obs; final lockId = 0.obs;
@ -10,16 +12,24 @@ class AddCardTypeState{
final isStressFingerprint = false.obs; final isStressFingerprint = false.obs;
final isAdministrator = false.obs;// final isAdministrator = false.obs;//
var beginTime = "".obs;// var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var endTime = "".obs;// var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var cycleBeginTime = "".obs;//
var cycleEndTime = "".obs;//
var effectiveDateTime = "".obs;// var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;// var failureDateTime = "".obs;//
var weekdaysList = [].obs; var weekdaysList = [].obs;
var fromTypeTwoStaffName = "".obs; //
final TextEditingController nameController = TextEditingController(); final TextEditingController nameController = TextEditingController();
late TabController tabController;
AddCardTypeState() { AddCardTypeState() {
// Map map = Get.arguments; Map map = Get.arguments;
// lockId.value = map["lockId"]; lockId.value = map["lockId"];
// fromType.value = map["fromType"]; fromType.value = map["fromType"];
// 1 2
if(fromType.value == 2){
fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; //
}
} }
} }

View File

@ -104,7 +104,7 @@ class _CardListPageState extends State<CardListPage> with RouteAware {
AddBottomWhiteBtn( AddBottomWhiteBtn(
btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}', btnName: '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.card!.tr}',
onClick: () async { onClick: () async {
var data = await Get.toNamed(Routers.addCardTypeManagePage, arguments: { var data = await Get.toNamed(Routers.addCardPage, arguments: {
"lockId": state.lockId.value, "lockId": state.lockId.value,
"fromType": 1 // 1 2 "fromType": 1 // 1 2
}); });

View File

@ -151,7 +151,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
} }
var data = await Get.toNamed( var data = await Get.toNamed(
Routers.addCardTypeManagePage, Routers.addCardPage,
arguments: { arguments: {
"lockId": state.getKeyInfosData.value.lockId, "lockId": state.getKeyInfosData.value.lockId,
"fromType": 2, // 1 2 "fromType": 2, // 1 2

View File

@ -34,7 +34,7 @@ class LockDetailLogic extends BaseGetXController {
// //
void initReplySubscription() { void initReplySubscription() {
state.replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { state.replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
Get.log("锁详情收到了蓝牙解析消息 reply:${reply.commandType}"); // Get.log("锁详情收到了蓝牙解析消息 reply:${reply.commandType}");
// //
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
_replyOpenLock(reply); _replyOpenLock(reply);
@ -496,7 +496,7 @@ class LockDetailLogic extends BaseGetXController {
void getLockNetToken() async { void getLockNetToken() async {
LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockNetToken = entity.data!.token!; state.lockNetToken = entity.data!.token!.toString();
Get.log("state.lockNetToken:${state.lockNetToken}"); Get.log("state.lockNetToken:${state.lockNetToken}");
openDoorAction(); openDoorAction();
}else{ }else{

View File

@ -27,7 +27,7 @@ class LockNetTokenEntity {
} }
class Data { class Data {
String? token; int? token;
Data({this.token}); Data({this.token});

View File

@ -1,14 +1,41 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:crypto/crypto.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/blue/io_protocol/io_otaUpgrade.dart';
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/advancedCalendar/src/datetime_util.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/pickers/time_picker/time_utils.dart';
import 'package:star_lock/tools/storage.dart';
import 'lockEscalation_state.dart'; import 'lockEscalation_state.dart';
class LockEscalationLogic extends BaseGetXController{ class LockEscalationLogic extends BaseGetXController {
LockEscalationState state = LockEscalationState(); LockEscalationState state = LockEscalationState();
StreamSubscription<Reply>? _replySubscription;
int otaCount = 0;
int otaIndex = 0;
Uint8List? otaBin;
int startSecond = 0;
// //
Future<void> setLockSetGeneralSetting() async{ Future<void> setLockSetGeneralSetting() async {
// var entity = await ApiRepository.to.getLockVersionInfoData( // var entity = await ApiRepository.to.getLockVersionInfoData(
// lockId: state.getKeyInfosData.value.lockId.toString(), // lockId: state.getKeyInfosData.value.lockId.toString(),
// ); // );
@ -17,24 +44,193 @@ class LockEscalationLogic extends BaseGetXController{
// } // }
} }
//
Future<void> otaUpdate() async {
var status = await PermissionDialog.request(
Permission.storage, '需要访问读写权限才能使用手动升级固件');
if (status != true) {
return;
}
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result == null || result.files.single.path is! String) {
return;
}
File file = File(result.files.single.path!);
Uint8List data = await file.readAsBytes();
Map? headJson = await getHeadFile(data);
if (headJson is! Map) {
return;
}
otaBin = await checkFile(data, headJson);
if (otaBin == null) {
return;
}
startOTAData();
blueOTAUpgrade(headJson);
}
// ota
void blueOTAUpgrade(Map data) {
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!);
String lockID = CommonDataManage.shareManager()
?.currentLockSetInfoData
.lockId
?.toString() ??
'';
String keyID =
CommonDataManage.shareManager()?.currentKeyInfo.keyId?.toString() ??
'';
BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand(
lockID: lockID,
userID: await Storage.getUid(),
keyID: keyID,
platform: int.tryParse(data['platform']) ?? 0,
product: int.tryParse(data['product']) ?? 0,
hwVersion: data['hwVersion'],
fwVersion: data['fwVersion'],
fwSize: data['fwSize'],
fwMD5: data['fwMd5'],
needAuthor: 1,
token: getTokenList,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList)
.packageData());
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {}
});
}
//
Future<void> processOtaUpgrade() async {
if (!state.otaUpdateIng.value) {
return;
}
int length = otaBin?.length ?? 0;
if (otaCount == 0) {
//
int difference = length % 240;
otaCount = length ~/ 240 + (difference > 0 ? 1 : 0);
startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000;
}
if (otaCount <= otaIndex) {
int now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
String msg = '传输完成 时间:${now - startSecond}';
closeOTADAta();
print(msg);
showToast(msg);
return;
}
int star = otaIndex * 240;
int end = (otaIndex + 1) * 240;
if (end > length) {
end = length;
}
List<int> data = otaBin!.sublist(star, end);
state.otaProgress.value = otaIndex / otaCount;
await BlueManage().writeCharacteristicWithResponse(
ProcessOtaUpgradeCommand(index: otaIndex, size: length, data: data)
.packageData());
}
// ota升级
void startOTAData() {
state.otaUpdateIng.value = true;
}
// ata
void closeOTADAta() {
state.otaUpdateIng.value = false;
state.otaProgress.value = 0;
otaIndex = 0;
otaCount = 0;
startSecond = 0;
otaBin = null;
}
//
void getBack() {
if (state.otaUpdateIng.value) {
closeOTADAta();
} else {
Get.back();
}
}
//
Future<Map?> getHeadFile(Uint8List data) async {
//
String header = utf8.decode(data.sublist(0, 12));
if (header != 'SYD-BIN-DATA') {
showToast('非SYD固件请选择正确的文件');
return null;
}
//
Uint8List metaLenList = data.sublist(12, 16);
int metaLen = ByteData.sublistView(metaLenList).getUint32(0);
if (metaLen < 2 || metaLen > 10240) {
showToast('元数据长度错误');
return null;
}
//
Uint8List metaStrList = data.sublist(16, 16 + metaLen);
String metaStr = utf8.decode(metaStrList);
print(metaStr);
var meta = jsonDecode(metaStr);
return meta..['metaLen'] = metaLen;
}
// bin
Future<Uint8List?> checkFile(Uint8List data, Map meta) async {
num binOffset = 16 + (meta['metaLen'] ?? 0);
//
Uint8List bin = data.sublist(binOffset.toInt(), data.length);
//md5
// String md5Str = md5.convert(bin).toString();
// if (md5Str != meta['fwMd5']) {
// showToast('固件MD5校验失败');
// return false;
// }
if (bin.length != meta['fwSize']) {
showToast('固件校验失败');
return null;
}
return bin;
}
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
print("onReady()");
setLockSetGeneralSetting(); setLockSetGeneralSetting();
} }
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
print("onInit()"); _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) {
if (reply is OTAUpgradeReply && reply.status == 0x00) {
//
processOtaUpgrade();
} else if (reply is ProcessOtaUpgradeReply && reply.status == 0x00) {
otaIndex++;
processOtaUpgrade();
} else if (reply is ConfirmationOTAUpgradeReply && reply.status == 0x00) {
closeOTADAta();
showToast('固件升级完成');
}
});
} }
@override @override
void onClose() { void onClose() {
// TODO: implement onClose _replySubscription?.cancel();
} }
} }

View File

@ -16,66 +16,152 @@ class LockEscalationPage extends StatefulWidget {
} }
class _LockEscalationPageState extends State<LockEscalationPage> { class _LockEscalationPageState extends State<LockEscalationPage> {
final logic = Get.put(LockEscalationLogic());
final state = Get.find<LockEscalationLogic>().state;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return GetBuilder<LockEscalationLogic>(
backgroundColor: Colors.white, init: LockEscalationLogic(),
appBar: TitleAppBar( builder: (LockEscalationLogic logic) {
barTitle: TranslationLoader.lanKeys!.lockEscalation!.tr, return Scaffold(
haveBack: true, backgroundColor: Colors.white,
backgroundColor: AppColors.mainColor), appBar: TitleAppBar(
body: Container( barTitle: TranslationLoader.lanKeys!.lockEscalation!.tr,
padding: EdgeInsets.all(30.w), haveBack: true,
child: Column( backgroundColor: AppColors.mainColor,
children: [ backAction: logic.getBack,
SizedBox(
height: 60.h,
), ),
Row( body: Container(
mainAxisAlignment: MainAxisAlignment.center, padding: EdgeInsets.all(30.w),
children: [ child: Column(
Image.asset( children: [
'images/main/icon_main_lockSet_lockEscalation.png', Obx(() {
width: 36.w, return logic.state.otaUpdateIng.value
height: 36.w, ? PopScope(
), canPop: false,
SizedBox( onPopInvoked: (didPop) async {
width: 10.w, if (logic.state.otaUpdateIng.value) {
), logic.closeOTADAta();
Text( }
TranslationLoader.lanKeys!.haveNewVersion!.tr, },
style: child: SizedBox(),
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), )
) : SizedBox();
], }),
), SizedBox(
SizedBox( height: 60.h,
height: 30.h, ),
), Row(
Text( mainAxisAlignment: MainAxisAlignment.center,
"${TranslationLoader.lanKeys!.currentVersion!.tr}1.0.0", children: [
style: TextStyle( Image.asset(
fontSize: 18.sp, color: AppColors.darkGrayTextColor), 'images/main/icon_main_lockSet_lockEscalation.png',
), width: 36.w,
SizedBox( height: 36.w,
height: 10.h, ),
), SizedBox(
Text( width: 10.w,
// "${TranslationLoader.lanKeys!.newVersion!.tr}1.0.1", ),
"未发现新版本", Text(
style: TextStyle(color: AppColors.mainColor, fontSize: 18.sp), TranslationLoader.lanKeys!.haveNewVersion!.tr,
), style: TextStyle(
SizedBox( fontSize: 24.sp, fontWeight: FontWeight.w600),
height: 40.h, )
), ],
SubmitBtn( ),
btnName: TranslationLoader.lanKeys!.upgrade!.tr, SizedBox(
onClick: () {}), height: 30.h,
], ),
), Text(
)); "${TranslationLoader.lanKeys!.currentVersion!.tr}1.0.0",
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
SizedBox(
height: 10.h,
),
Obx(() {
return !logic.state.otaUpdateIng.value
? Stack(
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),
),
),
),
Positioned(
right: 80.w,
child: 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),
),
),
),
],
),
);
}),
SizedBox(
height: 40.h,
),
Obx(() {
return !logic.state.otaUpdateIng.value
? SubmitBtn(
btnName: TranslationLoader.lanKeys!.upgrade!.tr,
onClick: () {})
: SizedBox();
}),
],
),
));
});
} }
} }

View File

@ -1,4 +1,6 @@
import 'package:get/get.dart';
class LockEscalationState{ class LockEscalationState {
var otaUpdateIng = false.obs;
var otaProgress = 0.00.obs;
} }

View File

@ -10,12 +10,14 @@ import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/eventBusEventManage.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_modelVendor.dart';
import '../../../../blue/io_reply.dart'; import '../../../../blue/io_reply.dart';
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart'; import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart'; import '../../../../blue/sender_manage.dart';
import '../../../../tools/baseGetXController.dart'; import '../../../../tools/baseGetXController.dart';
import '../../../../tools/commonDataManage.dart';
import '../../../../tools/dateTool.dart'; import '../../../../tools/dateTool.dart';
import '../../../../tools/storage.dart'; import '../../../../tools/storage.dart';
@ -46,31 +48,36 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
String lockId = state.keyInfo.value.lockId.toString(); String lockId = state.keyInfo.value.lockId.toString();
String getKeyType = state.widgetType.value.toString(); String getKeyType = state.widgetType.value.toString();
if (state.nameController.text.isEmpty) { if (state.nameController.text.isEmpty) {
showToast("请输入姓名".tr); showToast("请输入姓名".tr);
return; return;
} }
//
if (state.widgetType.value == 4) {
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("生效时间不能小于当前时间".tr);
return;
}
}
if (state.widgetType.value == 0) { if (state.widgetType.value == 0) {
// //
getKeyType = '2'; getKeyType = '2';
} else if (state.widgetType.value == 1) { } else if (state.widgetType.value == 1) {
// //
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { // 鸿
showToast("生效时间不能小于当前时间".tr); if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XHJ && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_SYD || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XHJ_JL)){
return; if (endDate <= DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("失效时间要大于当前时间".tr);
return;
}
} }
if (startDate >= endDate) { //
showToast("失效时间要大于生效时间".tr); if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
return; //
if (startDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("生效时间不能小于当前时间".tr);
return;
}
if (startDate >= endDate) {
showToast("失效时间要大于生效时间".tr);
return;
}
} }
getKeyType = '3'; getKeyType = '3';
} else if (state.widgetType.value == 2) { } else if (state.widgetType.value == 2) {
@ -80,9 +87,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
// //
} else if (state.widgetType.value == 4) { } else if (state.widgetType.value == 4) {
// //
// //
if (endDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) { if(CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)){
showToast("结束时间不能小于当前时间".tr); if (endDate < DateTool().dateToTimestamp(DateTool().getNowDateWithType(3), 1)) {
showToast("结束时间不能小于当前时间".tr);
return;
}
}
if (state.loopStartHours.value >= state.loopEndHours.value) {
showToast("失效时间要大于生效时间".tr);
return; return;
} }

View File

@ -7,6 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/style/default_style.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart'; import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
@ -14,6 +15,7 @@ import 'package:star_lock/tools/storage.dart';
import '../../../../appRouters.dart'; import '../../../../appRouters.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_modelVendor.dart';
import '../../../../tools/NativeInteractionTool.dart'; import '../../../../tools/NativeInteractionTool.dart';
import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart'; import '../../../../tools/commonItem.dart';
@ -193,22 +195,25 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
Widget keyTimeLimitWidget() { Widget keyTimeLimitWidget() {
return Column( return Column(
children: [ children: [
CommonItem( Visibility(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, visible: CommonDataManage().currentKeyInfo.vendor == "XHJ" ? false : true,
rightTitle: state.beginTime.value, child: CommonItem(
isHaveLine: true, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
isHaveDirection: true, rightTitle: state.beginTime.value,
action: () { isHaveLine: true,
Pickers.showDatePicker(context, mode: state.widgetType.value == 3 ? DateMode.YMDHM:DateMode.YMDH, onConfirm: (p) { isHaveDirection: true,
if (state.widgetType.value == 3) { action: () {
// Pickers.showDatePicker(context, mode: state.widgetType.value == 3 ? DateMode.YMDHM:DateMode.YMDH, onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1); if (state.widgetType.value == 3) {
} else { //
state.beginTime.value = DateTool().getYMDHNDateString(p, 4); state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
} } else {
Get.log("beginTime:${state.beginTime.value}"); state.beginTime.value = DateTool().getYMDHNDateString(p, 4);
}); }
}), Get.log("beginTime:${state.beginTime.value}");
});
}),
),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value, rightTitle: state.endTime.value,
@ -286,16 +291,19 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
]; ];
showPickerView(context, pickerDataList); showPickerView(context, pickerDataList);
}), }),
CommonItem( Visibility(
leftTitel: '结束日期', visible: (CommonDataManage().currentKeyInfo.vendor == IoModelVendor.vendor_XL && (CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_BLE || CommonDataManage().currentKeyInfo.model == IoModelVendor.model_XL_WIFI)) ? true : false,
rightTitle: state.endTime.value, child: CommonItem(
isHaveLine: true, leftTitel: '结束日期',
isHaveDirection: true, rightTitle: state.endTime.value,
action: () { isHaveLine: true,
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { isHaveDirection: true,
state.endTime.value = DateTool().getYMDHNDateString(p, 4); action: () {
}); Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) {
}), state.endTime.value = DateTool().getYMDHNDateString(p, 4);
});
}),
),
CommonItem( CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.loopEffectiveDate.value, rightTitle: state.loopEffectiveDate.value,

View File

@ -122,6 +122,10 @@ class LockListInfoItemEntity {
int? senderUserId; int? senderUserId;
int? electricQuantityDate; int? electricQuantityDate;
int? electricQuantityStandby; int? electricQuantityStandby;
int? isOnlyManageSelf;
int? restoreCount;
String? model;
String? vendor;
Bluetooth? bluetooth; Bluetooth? bluetooth;
LockFeature? lockFeature; LockFeature? lockFeature;
LockSetting? lockSetting; LockSetting? lockSetting;
@ -153,7 +157,11 @@ class LockListInfoItemEntity {
this.lockUserNo, this.lockUserNo,
this.electricQuantityDate, this.electricQuantityDate,
this.electricQuantityStandby, this.electricQuantityStandby,
this.senderUserId}); this.senderUserId,
this.isOnlyManageSelf,
this.restoreCount,
this.model,
this.vendor});
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) { LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
keyId = json['keyId']; keyId = json['keyId'];
@ -180,6 +188,10 @@ class LockListInfoItemEntity {
senderUserId = json['senderUserId']; senderUserId = json['senderUserId'];
electricQuantityDate = json['electricQuantityDate']; electricQuantityDate = json['electricQuantityDate'];
electricQuantityStandby = json['electricQuantityStandby']; electricQuantityStandby = json['electricQuantityStandby'];
isOnlyManageSelf = json['isOnlyManageSelf'];
restoreCount = json['restoreCount'];
model = json['model'];
vendor = json['vendor'];
bluetooth = json['bluetooth'] != null bluetooth = json['bluetooth'] != null
? Bluetooth.fromJson(json['bluetooth']) ? Bluetooth.fromJson(json['bluetooth'])
: null; : null;
@ -217,6 +229,10 @@ class LockListInfoItemEntity {
data['senderUserId'] = senderUserId; data['senderUserId'] = senderUserId;
data['electricQuantityDate'] = electricQuantityDate; data['electricQuantityDate'] = electricQuantityDate;
data['electricQuantityStandby'] = electricQuantityStandby; data['electricQuantityStandby'] = electricQuantityStandby;
data['isOnlyManageSelf'] = isOnlyManageSelf;
data['restoreCount'] = restoreCount;
data['model'] = model;
data['vendor'] = vendor;
if (bluetooth != null) { if (bluetooth != null) {
data['bluetooth'] = bluetooth!.toJson(); data['bluetooth'] = bluetooth!.toJson();
} }

View File

@ -84,7 +84,7 @@ class PermissionDialog {
} }
// //
static Future<bool> request(Permission permission) async { static Future<bool> request(Permission permission, [String? content]) async {
if (Get.context == null) { if (Get.context == null) {
return false; return false;
} }
@ -99,7 +99,7 @@ class PermissionDialog {
canPop: false, canPop: false,
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'),
content: Text(contents[permission] ?? ''), content: Text(content ?? contents[permission] ?? ''),
actions: [ actions: [
CupertinoDialogAction( CupertinoDialogAction(
child: Text('不允许'.tr), child: Text('不允许'.tr),

View File

@ -94,7 +94,7 @@ dependencies:
#跳转到外部 #跳转到外部
url_launcher: ^6.1.10 url_launcher: ^6.1.10
#蓝牙 #蓝牙
# flutter_reactive_ble: ^5.1.1 # flutter_reactive_ble: ^5.1.1
flutter_blue_plus: ^1.31.16 flutter_blue_plus: ^1.31.16
# #
event_bus: ^2.0.0 event_bus: ^2.0.0
@ -123,7 +123,7 @@ dependencies:
# 谷歌地图 # 谷歌地图
google_maps_flutter: ^2.2.5 google_maps_flutter: ^2.2.5
# geocoding: ^2.1.0 # geocoding: ^2.1.0
# 允许App发现网络的相关信息并且进行相应的配置 # 允许App发现网络的相关信息并且进行相应的配置
network_info_plus: ^4.0.2 network_info_plus: ^4.0.2
@ -144,12 +144,12 @@ dependencies:
image_gallery_saver: ^2.0.3 image_gallery_saver: ^2.0.3
convert: ^3.1.1 convert: ^3.1.1
just_audio: ^0.9.36 just_audio: ^0.9.36
# flutter_sound: ^9.2.13 # flutter_sound: ^9.2.13
# ffmpeg_kit_flutter: 5.1.0-LTS # ffmpeg_kit_flutter: 5.1.0-LTS
fast_gbk: ^1.0.0 fast_gbk: ^1.0.0
flutter_pcm_sound: ^1.1.0 flutter_pcm_sound: ^1.1.0
intl: ^0.18.0 intl: ^0.18.0
# flutter_audio_capture: <1.1.5 # flutter_audio_capture: <1.1.5
flutter_voice_processor: ^1.1.1 flutter_voice_processor: ^1.1.1
#监听网络连接状态 #监听网络连接状态
@ -165,6 +165,7 @@ dependencies:
system_settings: ^2.0.0 system_settings: ^2.0.0
expandable: ^5.0.1 expandable: ^5.0.1
colorfilter_generator: ^0.0.8 colorfilter_generator: ^0.0.8
file_picker: ^5.3.1
dev_dependencies: dev_dependencies: