diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index f76d56d6..d618407b 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -20,12 +20,13 @@ class NearbyLockLogic extends BaseGetXController { final NearbyLockState state = NearbyLockState(); // 点击连接设备 - void connect(String deviceName){ + void connect(String deviceName) { showEasyLoading(); - BlueManage().bludSendData(deviceName, (BluetoothConnectionState state) async { + BlueManage().bludSendData(deviceName, + (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { IoSenderManage.getPublicKey(lockId: deviceName); - }else if (state == BluetoothConnectionState.disconnected) { + } else if (state == BluetoothConnectionState.disconnected) { dismissEasyLoading(); } }, isAddEquipment: true); @@ -34,7 +35,8 @@ class NearbyLockLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { if (reply is GetPublicKeyReply) { _replyGetPublicKey(reply); } @@ -141,8 +143,8 @@ class NearbyLockLogic extends BaseGetXController { // 厂商名称 var vendor = reply.data.sublist(3, 23); var vendorStr = utf8String(vendor); - // state.lockInfo["vendor"] = vendorStr; - state.lockInfo["vendor"] = "XL"; + state.lockInfo["vendor"] = vendorStr; + // state.lockInfo["vendor"] = "XL"; Get.log("vendor:$vendor vendorStr:$vendorStr reply.data:${reply.data}"); // 锁设备类型 @@ -173,7 +175,8 @@ class NearbyLockLogic extends BaseGetXController { var serialNum0Str = utf8String(serialNum0); state.lockInfo["serialNum0"] = serialNum0Str; // state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}"; - Get.log("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}"); + Get.log( + "serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}"); // 成品商序列号 var serialNum1 = reply.data.sublist(100, 116); @@ -236,11 +239,12 @@ class NearbyLockLogic extends BaseGetXController { // 锁特征值说明(本机能支持的功能) // 获取到锁给的字符数组 var featureNetxLength = index + featureValueLength + 1; - if(reply.data.length < featureNetxLength){ + if (reply.data.length < featureNetxLength) { showToast("锁数据异常,请重试"); return; } - var featureValue = reply.data.sublist(index + 1, index + featureValueLength + 1); + var featureValue = + reply.data.sublist(index + 1, index + featureValueLength + 1); String featureValueStr = asciiString(featureValue); state.featureValue = featureValueStr; // List allFeatureValueTwoList = charListChangeIntList(featureValue); @@ -251,11 +255,12 @@ class NearbyLockLogic extends BaseGetXController { var featureEnValLength = reply.data[index]; // 使能锁特征值说明(本机启用的功能) var featureEnNextLength = index + featureEnValLength + 1; - if(reply.data.length < featureEnNextLength){ + if (reply.data.length < featureEnNextLength) { showToast("锁数据异常,请重试"); return; } - var featureEnVal = reply.data.sublist(index + 1, index + featureEnValLength + 1); + var featureEnVal = + reply.data.sublist(index + 1, index + featureEnValLength + 1); String featureEnValStr = asciiString(featureEnVal); state.featureSettingValue = featureEnValStr; // List allFeatureEnValTwoList = charListChangeIntList(featureEnVal); @@ -317,7 +322,8 @@ class NearbyLockLogic extends BaseGetXController { Future _getStarLockStatus() async { // print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}"); // 进来之后首先连接 - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState state) async { if (state == BluetoothConnectionState.connected) { dismissEasyLoading(); var privateKey = await Storage.getStringList(saveBluePrivateKey); @@ -351,19 +357,23 @@ class NearbyLockLogic extends BaseGetXController { // }); // } - void startScanBlueList(){ - BlueManage().startScan(2000, (List list){ + void startScanBlueList() { + BlueManage().startScan(2000, (List list) { state.devices.clear(); for (int i = 0; i < list.length; i++) { ScanResult device = list[i]; - if (((device.advertisementData.serviceUuids.isNotEmpty ? device.advertisementData.serviceUuids[0] : "").toString()[31] != "1")) { + if (((device.advertisementData.serviceUuids.isNotEmpty + ? device.advertisementData.serviceUuids[0] + : "") + .toString()[31] != + "1")) { state.devices.add(list[i]); } } }); } - void stopScanBlueList(){ + void stopScanBlueList() { BlueManage().disconnect(); BlueManage().stopScan(); }