修复问题

This commit is contained in:
魏少阳 2024-01-03 15:33:53 +08:00
parent ef5a7c63fb
commit 1210ad9110
13 changed files with 174 additions and 156 deletions

View File

@ -27,6 +27,10 @@ PODS:
- AMapFoundation (1.8.2) - AMapFoundation (1.8.2)
- AMapLocation (2.10.0): - AMapLocation (2.10.0):
- AMapFoundation (>= 1.8.0) - AMapFoundation (>= 1.8.0)
- audio_session (0.0.1):
- Flutter
- audioplayers_darwin (0.0.1):
- Flutter
- auto_orientation (0.0.1): - auto_orientation (0.0.1):
- Flutter - Flutter
- camera_avfoundation (0.0.1): - camera_avfoundation (0.0.1):
@ -37,22 +41,38 @@ PODS:
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_native_contact_picker (0.0.1): - flutter_native_contact_picker (0.0.1):
- Flutter - Flutter
- flutter_pcm_sound (0.0.1):
- Flutter
- flutter_sound (9.2.13):
- Flutter
- flutter_sound_core (= 9.2.13)
- flutter_sound_core (9.2.13)
- flutter_voice_processor (1.1.0):
- Flutter
- ios-voice-processor (~> 1.1.0)
- fluttertoast (0.0.2): - fluttertoast (0.0.2):
- Flutter - Flutter
- Toast - Toast
- FMDB (2.7.5): - FMDB (2.7.5):
- FMDB/standard (= 2.7.5) - FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- g711_flutter (0.0.1):
- Flutter
- google_maps_flutter_ios (0.0.1): - google_maps_flutter_ios (0.0.1):
- Flutter - Flutter
- GoogleMaps (< 9.0) - GoogleMaps (< 9.0)
- GoogleMaps (5.2.0): - GoogleMaps (6.2.1):
- GoogleMaps/Maps (= 5.2.0) - GoogleMaps/Maps (= 6.2.1)
- GoogleMaps/Base (5.2.0) - GoogleMaps/Base (6.2.1)
- GoogleMaps/Maps (5.2.0): - GoogleMaps/Maps (6.2.1):
- GoogleMaps/Base - GoogleMaps/Base
- image_gallery_saver (2.0.2):
- Flutter
- image_picker_ios (0.0.1): - image_picker_ios (0.0.1):
- Flutter - Flutter
- ios-voice-processor (1.1.0)
- just_audio (0.0.1):
- Flutter
- network_info_plus (0.0.1): - network_info_plus (0.0.1):
- Flutter - Flutter
- package_info_plus (0.4.5): - package_info_plus (0.4.5):
@ -73,7 +93,7 @@ PODS:
- sqflite (0.0.3): - sqflite (0.0.3):
- Flutter - Flutter
- FMDB (>= 2.7.5) - FMDB (>= 2.7.5)
- SwiftProtobuf (1.25.1) - SwiftProtobuf (1.25.2)
- Toast (4.0.0) - Toast (4.0.0)
- url_launcher_ios (0.0.1): - url_launcher_ios (0.0.1):
- Flutter - Flutter
@ -88,14 +108,22 @@ DEPENDENCIES:
- aliyun_push (from `.symlinks/plugins/aliyun_push/ios`) - aliyun_push (from `.symlinks/plugins/aliyun_push/ios`)
- amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`) - amap_flutter_location (from `.symlinks/plugins/amap_flutter_location/ios`)
- amap_flutter_map (from `.symlinks/plugins/amap_flutter_map/ios`) - amap_flutter_map (from `.symlinks/plugins/amap_flutter_map/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
- auto_orientation (from `.symlinks/plugins/auto_orientation/ios`) - auto_orientation (from `.symlinks/plugins/auto_orientation/ios`)
- camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`) - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`) - flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
- flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`)
- flutter_sound (from `.symlinks/plugins/flutter_sound/ios`)
- flutter_voice_processor (from `.symlinks/plugins/flutter_voice_processor/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- g711_flutter (from `.symlinks/plugins/g711_flutter/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
- network_info_plus (from `.symlinks/plugins/network_info_plus/ios`) - network_info_plus (from `.symlinks/plugins/network_info_plus/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
@ -119,8 +147,10 @@ SPEC REPOS:
- AMap3DMap - AMap3DMap
- AMapFoundation - AMapFoundation
- AMapLocation - AMapLocation
- flutter_sound_core
- FMDB - FMDB
- GoogleMaps - GoogleMaps
- ios-voice-processor
- Protobuf - Protobuf
- SwiftProtobuf - SwiftProtobuf
- Toast - Toast
@ -134,6 +164,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/amap_flutter_location/ios" :path: ".symlinks/plugins/amap_flutter_location/ios"
amap_flutter_map: amap_flutter_map:
:path: ".symlinks/plugins/amap_flutter_map/ios" :path: ".symlinks/plugins/amap_flutter_map/ios"
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
audioplayers_darwin:
:path: ".symlinks/plugins/audioplayers_darwin/ios"
auto_orientation: auto_orientation:
:path: ".symlinks/plugins/auto_orientation/ios" :path: ".symlinks/plugins/auto_orientation/ios"
camera_avfoundation: camera_avfoundation:
@ -144,12 +178,24 @@ EXTERNAL SOURCES:
:path: Flutter :path: Flutter
flutter_native_contact_picker: flutter_native_contact_picker:
:path: ".symlinks/plugins/flutter_native_contact_picker/ios" :path: ".symlinks/plugins/flutter_native_contact_picker/ios"
flutter_pcm_sound:
:path: ".symlinks/plugins/flutter_pcm_sound/ios"
flutter_sound:
:path: ".symlinks/plugins/flutter_sound/ios"
flutter_voice_processor:
:path: ".symlinks/plugins/flutter_voice_processor/ios"
fluttertoast: fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios" :path: ".symlinks/plugins/fluttertoast/ios"
g711_flutter:
:path: ".symlinks/plugins/g711_flutter/ios"
google_maps_flutter_ios: google_maps_flutter_ios:
:path: ".symlinks/plugins/google_maps_flutter_ios/ios" :path: ".symlinks/plugins/google_maps_flutter_ios/ios"
image_gallery_saver:
:path: ".symlinks/plugins/image_gallery_saver/ios"
image_picker_ios: image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios" :path: ".symlinks/plugins/image_picker_ios/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
network_info_plus: network_info_plus:
:path: ".symlinks/plugins/network_info_plus/ios" :path: ".symlinks/plugins/network_info_plus/ios"
package_info_plus: package_info_plus:
@ -184,17 +230,27 @@ SPEC CHECKSUMS:
amap_flutter_map: 979e54d227cedac6c7504a2151bfbf3bcf96760a amap_flutter_map: 979e54d227cedac6c7504a2151bfbf3bcf96760a
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033 AMapLocation: 5248aec2455ebb5d104b367813c946430a2ee033
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
EMASRest: 8df6f87836767a9415ad5cc4af739bc9d215b475 EMASRest: 8df6f87836767a9415ad5cc4af739bc9d215b475
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907 flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900
flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae
flutter_voice_processor: 53afbf59ad3feb82f4a379fea9ed8dc98495210f
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
g711_flutter: 8f2769052d2cf3549f83d11e1c42d81d94441123
google_maps_flutter_ios: 590249c67f34f422122c232f2a626192adbc78ee google_maps_flutter_ios: 590249c67f34f422122c232f2a626192adbc78ee
GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693 GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
@ -203,12 +259,12 @@ SPEC CHECKSUMS:
reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
SwiftProtobuf: 69f02cd54fb03201c5e6bf8b76f687c5ef7541a3 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126 video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
PODFILE CHECKSUM: adf6d8caf5faa9ea4ee2a2ea37f5aea37a6520d7 PODFILE CHECKSUM: 42aa7ffc6134b996f93caa6a9b6a2b5b580ff28a
COCOAPODS: 1.14.3 COCOAPODS: 1.14.3

View File

@ -65,6 +65,10 @@
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
<string>Main</string> <string>Main</string>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>

View File

@ -58,10 +58,7 @@ class BlueManage {
} }
void _initSendStreamSubscription() { void _initSendStreamSubscription() {
_sendStreamSubscription ??= EventBusManager() _sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
.eventBus!
.on<EventSendModel>()
.listen((EventSendModel model) {
if (model.sendChannel == DataChannel.ble) { if (model.sendChannel == DataChannel.ble) {
// managerAppWriteData(model.data); // managerAppWriteData(model.data);
writeCharacteristicWithResponse(model.data); writeCharacteristicWithResponse(model.data);
@ -72,21 +69,15 @@ class BlueManage {
/// ///
void startScan({List<Uuid>? idList}) { void startScan({List<Uuid>? idList}) {
scanDevices.clear(); scanDevices.clear();
_scanSubscription = _flutterReactiveBle! _scanSubscription = _flutterReactiveBle!.scanForDevices(withServices: idList ?? []).listen((device) {
.scanForDevices(withServices: idList ?? [])
.listen((device) {
// //
if (device.name.isEmpty) { if (device.name.isEmpty) {
return; return;
} }
// print("startScanDevice:$device"); // print("startScanDevice:$device");
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "") if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
.toString()
.contains("758824")) &&
(device.rssi >= -100)) {
// id相同的元素 // id相同的元素
final knownDeviceIndex = final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
scanDevices.indexWhere((d) => d.id == device.id);
// -1 // -1
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = device; scanDevices[knownDeviceIndex] = device;
@ -115,9 +106,7 @@ class BlueManage {
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack) async { Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack) async {
connectDeviceName = deviceName; connectDeviceName = deviceName;
// //
final knownDeviceIndex = final knownDeviceIndex = scanDevices.indexWhere((d) => d.name == deviceName);
scanDevices.indexWhere((d) => d.name == deviceName);
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
// //
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id; connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
@ -156,21 +145,17 @@ class BlueManage {
// Completer完成 // Completer完成
await completer.future; await completer.future;
} }
print( print("connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
"connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
if (connectDeviceMacAddress.isEmpty) { if (connectDeviceMacAddress.isEmpty) {
return; return;
} }
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 10)).listen((connectionStateUpdate) async { _currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 10)).listen((connectionStateUpdate) async {
// //
deviceConnectionState = connectionStateUpdate.connectionState; deviceConnectionState = connectionStateUpdate.connectionState;
print( print('deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}');
'deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}'); if (connectionStateUpdate.connectionState == DeviceConnectionState.connected) {
if (connectionStateUpdate.connectionState ==
DeviceConnectionState.connected) {
// //
try { try {
_subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: characteristicIdSubscription, serviceId: serviceIdConnect, deviceId: connectDeviceMacAddress)); _subScribeToCharacteristic(QualifiedCharacteristic(characteristicId: characteristicIdSubscription, serviceId: serviceIdConnect, deviceId: connectDeviceMacAddress));
@ -188,13 +173,11 @@ class BlueManage {
deviceConnectionState = connectionStateUpdate.connectionState; deviceConnectionState = connectionStateUpdate.connectionState;
connectStateCallBack(deviceConnectionState!); connectStateCallBack(deviceConnectionState!);
} }
print( print('ConnectionState for device $connectDeviceMacAddress : ${connectionStateUpdate.connectionState}');
'ConnectionState for device $connectDeviceMacAddress : ${connectionStateUpdate.connectionState}');
}, onError: (Object e) { }, onError: (Object e) {
deviceConnectionState = DeviceConnectionState.disconnected; deviceConnectionState = DeviceConnectionState.disconnected;
connectStateCallBack(deviceConnectionState!); connectStateCallBack(deviceConnectionState!);
print( print('Connecting to device $connectDeviceMacAddress resulted in error $e');
'Connecting to device $connectDeviceMacAddress resulted in error $e');
}); });
} }
@ -202,26 +185,21 @@ class BlueManage {
var allData = <int>[]; var allData = <int>[];
int? dataLen; int? dataLen;
_subScribeToCharacteristic(QualifiedCharacteristic characteristic) { _subScribeToCharacteristic(QualifiedCharacteristic characteristic) {
_flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen( _flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen((data) {
(data) {
// code to handle incoming data // code to handle incoming data
print( // print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
"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}"); // print("dataLen1111:$dataLen getDataLength:${data.length}");
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>[];
@ -230,9 +208,9 @@ 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"); // print("dataLen3333:$dataLen");
if ((dataLen! + 14) <= allData.length) { if ((dataLen! + 14) <= allData.length) {
print("44444数据被解析了"); // print("44444数据被解析了");
// //
CommandReciverManager.appDataReceive(allData); CommandReciverManager.appDataReceive(allData);
// //

View File

@ -128,6 +128,10 @@ class ConfiguringWifiLogic extends BaseGetXController{
// //
print("${reply.commandType}校验错误"); print("${reply.commandType}校验错误");
break;
case 0xff:
//
Toast.show(msg: "配网失败");
break; break;
default: default:
// //
@ -141,8 +145,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
Future<void> senderConfiguringWifiAction() async { Future<void> senderConfiguringWifiAction() async {
showEasyLoading(); showEasyLoading();
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
dismissEasyLoading();
if (connectionState == DeviceConnectionState.connected){ if (connectionState == DeviceConnectionState.connected){
dismissEasyLoading();
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -169,13 +173,13 @@ class ConfiguringWifiLogic extends BaseGetXController{
serversList.add(int.parse(element)); serversList.add(int.parse(element));
} }
print('Resolved google.com to address: ${addresses.first.address} serversList${serversList}'); print('Resolved google.com to address: ${addresses.first.address} serversList${serversList}');
double typeDouble = int.parse(item.port!) / 256;
int type1 = typeDouble.toInt();
int type2 = int.parse(item.port!) % 256;
serversList.add(type1);
serversList.add(type2);
} }
double typeDouble = int.parse(item.port!) / 256;
int type1 = typeDouble.toInt();
int type2 = int.parse(item.port!) % 256;
serversList.add(type1);
serversList.add(type2);
} }
String? phone = ''; String? phone = '';
@ -200,6 +204,9 @@ class ConfiguringWifiLogic extends BaseGetXController{
publicKey: publicKeyDataList, publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
} else if (connectionState == DeviceConnectionState.disconnected) {
dismissEasyLoading();
showBlueConnetctToast();
} }
}); });
} }

View File

@ -27,9 +27,7 @@ import 'checkingInInfoData_entity.dart';
import 'lockSet_state.dart'; import 'lockSet_state.dart';
typedef BlockSetStateCallback = void Function(); typedef BlockSetStateCallback = void Function();
typedef BlockSetCheckInCallback = void Function( typedef BlockSetCheckInCallback = void Function(CheckingInInfoDataEntity checkingInInfoDataEntity);
CheckingInInfoDataEntity checkingInInfoDataEntity);
typedef BlockDeletNumberCheckPasswordCallback = void Function();
class LockSetLogic extends BaseGetXController { class LockSetLogic extends BaseGetXController {
final LockSetState state = LockSetState(); final LockSetState state = LockSetState();
@ -258,9 +256,10 @@ class LockSetLogic extends BaseGetXController {
// //
Future<void> deletUserAction() async { Future<void> deletUserAction() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceName, showEasyLoading();
(DeviceConnectionState connectionState) async { BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) { if (connectionState == DeviceConnectionState.connected) {
dismissEasyLoading();
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -283,6 +282,7 @@ class LockSetLogic extends BaseGetXController {
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
token: getTokenList); token: getTokenList);
} else if (connectionState == DeviceConnectionState.disconnected) { } else if (connectionState == DeviceConnectionState.disconnected) {
dismissEasyLoading();
showDeletAlertTipDialog(Get.context!); showDeletAlertTipDialog(Get.context!);
} }
}); });
@ -291,8 +291,7 @@ class LockSetLogic extends BaseGetXController {
// //
Future<void> factoryDataResetAction() async { Future<void> factoryDataResetAction() async {
showEasyLoading(); showEasyLoading();
BlueManage().judgeReconnect(BlueManage().connectDeviceName, BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
(DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) { if (connectionState == DeviceConnectionState.connected) {
dismissEasyLoading(); dismissEasyLoading();
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -348,8 +347,7 @@ class LockSetLogic extends BaseGetXController {
// () // ()
Future<void> sendBurglarAlarm(int type) async { Future<void> sendBurglarAlarm(int type) async {
showEasyLoading(); showEasyLoading();
BlueManage().judgeReconnect(BlueManage().connectDeviceName, BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
(DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) { if (connectionState == DeviceConnectionState.connected) {
dismissEasyLoading(); dismissEasyLoading();
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -473,41 +471,32 @@ class LockSetLogic extends BaseGetXController {
password: state.passwordTF.text, password: state.passwordTF.text,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// blockDeletNumberCheckPasswordCallback();
Get.back(); Get.back();
// if(state.currentDeviceUUid.value[31] == "1"){ if(state.currentDeviceUUid.value.isEmpty){
//
// showDeletAlertTipDialog(Get.context!);
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) { }else{
// //
factoryDataResetAction(); if(state.currentDeviceUUid.value[31] == "1"){
} else { //
// if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
if (BlueManage().connectDeviceMacAddress.isNotEmpty) { //
// factoryDataResetAction();
deletUserAction(); } else {
} else { //
deletUserAction();
}
}else if(state.currentDeviceUUid.value[31] == "0"){
//
showDeletAlertTipDialog(Get.context!); showDeletAlertTipDialog(Get.context!);
} }
} }
// }else if(state.currentDeviceUUid.value[31] == "0"){
// //
// if(state.getKeyInfosData.value.isLockOwner == 1){
// //
// deletLockInfoData();
// }else{
// //
// deletKeyData();
// }
// }
} }
} }
// //
void openCheckingInData( void openCheckingInData(BlockSetCheckInCallback blockSetCheckInCallback) async {
BlockSetCheckInCallback blockSetCheckInCallback) async {
var entity = await ApiRepository.to.openCheckingInData( var entity = await ApiRepository.to.openCheckingInData(
lockId: state.lockSetInfoData.value.lockId.toString(), lockId: state.lockSetInfoData.value.lockId.toString(),
); );
@ -528,10 +517,8 @@ class LockSetLogic extends BaseGetXController {
state.isAttendance.value = (state.isAttendance.value == 1 ? 0 : 1); state.isAttendance.value = (state.isAttendance.value == 1 ? 0 : 1);
state.lockSettingInfo.value.attendance = state.isAttendance.value; state.lockSettingInfo.value.attendance = state.isAttendance.value;
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType( eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.attendance!));
0, state.lockSettingInfo.value.attendance!)); print("state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
print(
"state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
Toast.show(msg: "设置成功"); Toast.show(msg: "设置成功");
} }
} }
@ -545,10 +532,8 @@ class LockSetLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
state.isLockPickingReminder.value = state.isLockPickingReminder.value = (state.isLockPickingReminder.value == 1 ? 0 : 1);
(state.isLockPickingReminder.value == 1 ? 0 : 1); state.lockSettingInfo.value.unlockReminderPush = state.isLockPickingReminder.value;
state.lockSettingInfo.value.unlockReminderPush =
state.isLockPickingReminder.value;
Toast.show(msg: "设置成功"); Toast.show(msg: "设置成功");
} else {} } else {}
} }
@ -562,15 +547,11 @@ class LockSetLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
state.isOpenLockNeedOnline.value = state.isOpenLockNeedOnline.value = (state.isOpenLockNeedOnline.value == 1 ? 0 : 1);
(state.isOpenLockNeedOnline.value == 1 ? 0 : 1); state.lockSettingInfo.value.appUnlockOnline = state.isOpenLockNeedOnline.value;
state.lockSettingInfo.value.appUnlockOnline =
state.isOpenLockNeedOnline.value;
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType( eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.appUnlockOnline!));
0, state.lockSettingInfo.value.appUnlockOnline!)); print("state.lockSettingInfo.value.appUnlockOnline:${state.lockSettingInfo.value.appUnlockOnline}");
print(
"state.lockSettingInfo.value.appUnlockOnline:${state.lockSettingInfo.value.appUnlockOnline}");
Toast.show(msg: "设置成功"); Toast.show(msg: "设置成功");
} }
} }
@ -579,21 +560,20 @@ class LockSetLogic extends BaseGetXController {
StreamSubscription? _passCurrentLockInformationEvent; StreamSubscription? _passCurrentLockInformationEvent;
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
// eventBus // eventBus
_passCurrentLockInformationEvent = _passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
// state.lockSetInfoData.value = event.keyInfo; // state.lockSetInfoData.value = event.keyInfo;
blockSetStateCallback(); blockSetStateCallback();
}); });
} }
// Uuid删除当前锁时 APP的时候扫描如果未被连接就传uuid过去 late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
StreamSubscription? _scanAllDeviceFindCurrentDeviceConnectedEvent; void _scanListDiscoveredDeviceSubscriptionAction() {
void initLoadDataScanAllDeviceFindCurrentDeviceAction() { _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
// eventBus final knownDeviceIndex = list.indexWhere((d) => d.name == BlueManage().connectDeviceName);
_scanAllDeviceFindCurrentDeviceConnectedEvent = eventBus if (knownDeviceIndex >= 0) {
.on<ScanAllDeviceFindCurrentDeviceConnectedEvent>() //
.listen((event) { state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
state.currentDeviceUUid.value = event.uuid; }
}); });
} }
@ -615,8 +595,7 @@ class LockSetLogic extends BaseGetXController {
child: Text(TranslationLoader.lanKeys!.sure!.tr), child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
1) {
// //
deletLockInfoData(); deletLockInfoData();
} else { } else {
@ -640,7 +619,7 @@ class LockSetLogic extends BaseGetXController {
getLockSettingInfoData(); getLockSettingInfoData();
_initReplySubscription(); _initReplySubscription();
initLoadDataScanAllDeviceFindCurrentDeviceAction(); _scanListDiscoveredDeviceSubscriptionAction();
} }
@override @override
@ -655,6 +634,6 @@ class LockSetLogic extends BaseGetXController {
// TODO: implement onClose // TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
_passCurrentLockInformationEvent!.cancel(); _passCurrentLockInformationEvent!.cancel();
_scanAllDeviceFindCurrentDeviceConnectedEvent!.cancel(); _scanListDiscoveredDeviceSubscription.cancel();
} }
} }

View File

@ -65,11 +65,6 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> _replyOpenLock(Reply reply) async { Future<void> _replyOpenLock(Reply reply) async {
var tokenData = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(tokenData);
print("openDoorToken:$tokenData");
Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6]; int status = reply.data[6];
print("status:$status"); print("status:$status");
@ -98,6 +93,11 @@ class LockDetailLogic extends BaseGetXController {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);
var tokenData = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(tokenData);
Storage.setStringList(saveBlueToken, saveStrList);
print("openDoorToken:$tokenData");
IoSenderManage.senderOpenLock( IoSenderManage.senderOpenLock(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
@ -353,14 +353,9 @@ class LockDetailLogic extends BaseGetXController {
var signKey = await Storage.getStringList(saveBlueSignKey); var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); List<int> signKeyDataList = changeStringListToIntList(signKey!);
bool isHave = await Storage.ifHaveKey(saveBlueToken); var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList; List<int> getTokenList = changeStringListToIntList(token!);
if (isHave) {
var token = await Storage.getStringList(saveBlueToken);
getTokenList = changeStringListToIntList(token!);
} else {
getTokenList = [0, 0, 0, 0];
}
print("openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); print("openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList");
IoSenderManage.senderOpenLock( IoSenderManage.senderOpenLock(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
@ -374,7 +369,10 @@ class LockDetailLogic extends BaseGetXController {
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
}else if (deviceConnectionState == DeviceConnectionState.disconnected){ }else if (deviceConnectionState == DeviceConnectionState.disconnected){
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开"); if(state.lockState.value != 2){
// 2 toast
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
}
state.lockState.value = 4; state.lockState.value = 4;
state.animationController.reset(); state.animationController.reset();
state.animationController.forward(); state.animationController.forward();

View File

@ -66,7 +66,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
var saveSignKeyList = changeIntListToStringList(signKeyData); var saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList); Storage.setStringList(saveBlueSignKey, saveSignKeyList);
Storage.setStringList(saveBlueToken, [0, 0, 0, 0]); var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
Storage.setStringList(saveBlueToken, saveTokenList);
// logic.startScanAction(); // logic.startScanAction();
listeningAnimations(); listeningAnimations();

View File

@ -396,7 +396,9 @@ class LockMonitoringLogic extends BaseGetXController {
print("锁详情界面销毁了"); print("锁详情界面销毁了");
_getTVDataRefreshUIEvent!.cancel(); _getTVDataRefreshUIEvent!.cancel();
_getUDPStatusRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel();
state.oneMinuteTimeTimer.cancel(); if(state.oneMinuteTimeTimer != null){
state.oneMinuteTimeTimer.cancel();
}
stopProcessing(); stopProcessing();
} }
} }

View File

@ -33,7 +33,7 @@ class NearbyLockLogic extends BaseGetXController {
IoSenderManage.getPublicKey(lockId: deviceName); IoSenderManage.getPublicKey(lockId: deviceName);
}else if (state == DeviceConnectionState.disconnected) { }else if (state == DeviceConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
showBlueConnetctToast(); // showBlueConnetctToast();
} }
}); });
} }
@ -181,8 +181,7 @@ class NearbyLockLogic extends BaseGetXController {
var serialNum0 = reply.data.sublist(84, 100); var serialNum0 = reply.data.sublist(84, 100);
var serialNum0Str = utf8String(serialNum0); var serialNum0Str = utf8String(serialNum0);
// state.lockInfo["serialNum0"] = serialNum0Str; // state.lockInfo["serialNum0"] = serialNum0Str;
state.lockInfo["serialNum0"] = state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
"${DateTime.now().millisecondsSinceEpoch ~/ 10}";
// print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}"); // print("serialNum0Str:$serialNum0Str serialNum0Str:${serialNum0Str.length}");
// //
@ -345,19 +344,13 @@ class NearbyLockLogic extends BaseGetXController {
}); });
} }
late StreamSubscription<List<DiscoveredDevice>> late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
_scanListDiscoveredDeviceSubscription;
void _scanListDiscoveredDeviceSubscriptionAction() { void _scanListDiscoveredDeviceSubscriptionAction() {
_scanListDiscoveredDeviceSubscription = EventBusManager() _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
.eventBus!
.on<List<DiscoveredDevice>>()
.listen((List<DiscoveredDevice> list) {
state.devices.clear(); state.devices.clear();
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
DiscoveredDevice device = list[i]; DiscoveredDevice device = list[i];
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "") if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString()[31] != "1")) {
.toString()[31] !=
"1")) {
state.devices.add(list[i]); state.devices.add(list[i]);
} }
} }

View File

@ -103,10 +103,13 @@ class SaveLockLogic extends BaseGetXController {
// //
Future<void> addUserConnectBlue() async { Future<void> addUserConnectBlue() async {
// print("111111");
// //
showEasyLoading(); showEasyLoading();
BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async { BlueManage().judgeReconnect(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
// print("222222");
if (state == DeviceConnectionState.connected){ if (state == DeviceConnectionState.connected){
// print("333333");
dismissEasyLoading(); dismissEasyLoading();
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -138,6 +141,7 @@ class SaveLockLogic extends BaseGetXController {
token: getTokenList token: getTokenList
); );
} else if (state == DeviceConnectionState.disconnected) { } else if (state == DeviceConnectionState.disconnected) {
print("444444");
dismissEasyLoading(); dismissEasyLoading();
showBlueConnetctToast(); showBlueConnetctToast();
} }
@ -212,7 +216,7 @@ class SaveLockLogic extends BaseGetXController {
@override @override
void onClose() { void onClose() {
// TODO: implement onClose // TODO: implement onClose
super.onClose();
_replySubscription.cancel(); _replySubscription.cancel();
super.onClose();
} }
} }

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';

View File

@ -1,6 +1,7 @@
abstract class Api { abstract class Api {
static String baseAddress = "https://pre.lock.star-lock.cn:8093"; // // static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //
// static String baseAddress = "http://192.168.56.101:8099"; // static String baseAddress = "http://192.168.56.101:8099"; //
// static String baseAddress = "http://192.168.1.15:8022"; //
final String baseUrl = "$baseAddress/api"; final String baseUrl = "$baseAddress/api";

View File

@ -32,12 +32,6 @@ class ChickInAddStaffCardAndFingerprintBlockNumberEvent {
ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number); ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number);
} }
/// Uuid删除当前锁时 APP的时候扫描如果未被连接就传uuid过去
class ScanAllDeviceFindCurrentDeviceConnectedEvent {
String uuid;
ScanAllDeviceFindCurrentDeviceConnectedEvent(this.uuid);
}
/// ///
class ChangeLanguageBlockLastLanguageEvent { class ChangeLanguageBlockLastLanguageEvent {
String languageTitle; String languageTitle;