1.0.81版本打包给宿舍门测试

This commit is contained in:
魏少阳 2024-09-30 10:35:44 +08:00
parent 552c787c5a
commit 9336e83434
7 changed files with 145 additions and 60 deletions

View File

@ -141,14 +141,16 @@ class BlueManage {
} }
/// ///
Future<void> startScanSingle(String deviceName, int timeout, Future<void> startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async {
ScanDevicesCallBack scanDevicesCallBack) async {
final DateTime start = DateTime.now(); final DateTime start = DateTime.now();
FlutterBluePlus.isSupported.then((bool isAvailable) async { FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) { if (isAvailable) {
// AppLog.log('startScanSingle 蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState'); // AppLog.log('startScanSingle 蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState');
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
try { try {
BuglyTool.uploadException(
message: 'startScanSingle:$deviceName',
detail: 'startScanSingle$deviceName 开始指定设备名称的扫描蓝牙设备');
//android 3 //android 3
final int divisor = Platform.isAndroid ? 3 : 1; final int divisor = Platform.isAndroid ? 3 : 1;
FlutterBluePlus.startScan( FlutterBluePlus.startScan(
@ -166,6 +168,9 @@ class BlueManage {
start.millisecondsSinceEpoch; start.millisecondsSinceEpoch;
AppLog.log( AppLog.log(
'扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒'); '扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
BuglyTool.uploadException(
message: 'startScanSingle:$deviceName',
detail: 'startScanSingle$deviceName 监听扫描结果 扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
if (isExit) { if (isExit) {
for (final ScanResult scanResult in results) { for (final ScanResult scanResult in results) {
if (((scanResult.advertisementData.serviceUuids.isNotEmpty if (((scanResult.advertisementData.serviceUuids.isNotEmpty
@ -187,28 +192,33 @@ class BlueManage {
} else { } else {
scanDevices.add(scanResult); scanDevices.add(scanResult);
} }
BuglyTool.uploadException(
message: 'startScanSingle:$deviceName',
detail: 'startScanSingle$deviceName 查询到的结果scanResult:$scanResult');
} }
} }
completer.complete(); completer.complete();
} }
}, onError: (e) { }, onError: (e) {
AppLog.log( BuglyTool.uploadException(
'扫描失败:$e', message: 'startScanSingle:$deviceName',
); detail: 'startScanSingle$deviceName 监听扫描结果失败 e:${e.toString()}');
AppLog.log('扫描失败:$e',);
}); });
FlutterBluePlus.cancelWhenScanComplete(subscription); FlutterBluePlus.cancelWhenScanComplete(subscription);
await completer.future; await completer.future;
scanDevicesCallBack(scanDevices); scanDevicesCallBack(scanDevices);
subscription.cancel(); subscription.cancel();
} catch (e) { } catch (e) {
BuglyTool.uploadException(
message: 'startScanSingle:$deviceName',
detail: 'startScanSingle$deviceName startScanSingle内部逻辑整形失败 e:${e.toString()}');
AppLog.log('扫描失败'); AppLog.log('扫描失败');
} }
} else { } else {
try { try {
if (Platform.isAndroid) { openBlue();
await FlutterBluePlus.turnOn();
}
} catch (e) { } catch (e) {
AppLog.log('蓝牙打开失败'); AppLog.log('蓝牙打开失败');
} }
@ -268,9 +278,7 @@ class BlueManage {
} }
} else { } else {
try { try {
if (Platform.isAndroid) { openBlue();
await FlutterBluePlus.turnOn();
}
} catch (e) { } catch (e) {
AppLog.log('蓝牙打开失败'); AppLog.log('蓝牙打开失败');
} }
@ -291,24 +299,36 @@ class BlueManage {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
// //
if (bluetoothConnectionState != BluetoothConnectionState.connected) { if (bluetoothConnectionState != BluetoothConnectionState.connected) {
BuglyTool.uploadException(
message: 'blueSendData 蓝牙未连接',
detail: 'blueSendData 蓝牙未连接}');
_connect(deviceName, (BluetoothConnectionState state) { _connect(deviceName, (BluetoothConnectionState state) {
stateCallBack(bluetoothConnectionState!); stateCallBack(bluetoothConnectionState!);
}, isAddEquipment: isAddEquipment); }, isAddEquipment: isAddEquipment);
} else { } else {
BuglyTool.uploadException(
message: 'blueSendData 蓝牙是连接状态',
detail: 'blueSendData 蓝牙是连接状态,直接回调}');
stateCallBack(bluetoothConnectionState!); stateCallBack(bluetoothConnectionState!);
} }
} else { } else {
BuglyTool.uploadException(
message: 'blueSendData 蓝牙未打开',
detail: 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on}');
try { try {
stateCallBack(BluetoothConnectionState.disconnected); stateCallBack(BluetoothConnectionState.disconnected);
openBlue(); openBlue();
} catch (e) { } catch (e) {
AppLog.log('蓝牙打开失败'); AppLog.log('蓝牙打开失败');
BuglyTool.uploadException(
message: 'blueSendData 蓝牙打开失败',
detail: 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on}');
} }
} }
} else { } else {
BuglyTool.uploadException( BuglyTool.uploadException(
message: 'blueSendData isAvailable状态', message: 'blueSendData isAvailable状态',
detail: 'blueSendData isAvailable不可用--json'); detail: 'blueSendData isAvailable不可用--isAvailable:$isAvailable');
// FlutterBuglyPlugin.reportException(exceptionName: 'blueSendData isAvailable状态', reason: 'blueSendData isAvailable不可用'); // FlutterBuglyPlugin.reportException(exceptionName: 'blueSendData isAvailable状态', reason: 'blueSendData isAvailable不可用');
AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作'); AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
} }
@ -320,33 +340,47 @@ class BlueManage {
String deviceName, ConnectStateCallBack connectStateCallBack, String deviceName, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
connectDeviceName = deviceName; connectDeviceName = deviceName;
//
final List<ScanResult> devicesList = scanDevices; final List<ScanResult> devicesList = scanDevices;
// true是有缓存设备
final bool isExistDevice = isExistScanDevices(connectDeviceName); final bool isExistDevice = isExistScanDevices(connectDeviceName);
final bool isCurrentDevice = //
CommonDataManage().currentKeyInfo.lockName == deviceName; final bool isCurrentDevice = CommonDataManage().currentKeyInfo.lockName == deviceName;
// mac地址
final String? mac = CommonDataManage().currentKeyInfo.mac; final String? mac = CommonDataManage().currentKeyInfo.mac;
AppLog.log('开始连接 是否存在缓存:$isExistDevice 是否是当前设备:$isCurrentDevice mac$mac'); AppLog.log('开始连接 是否存在缓存:$isExistDevice 是否是当前设备:$isCurrentDevice mac$mac');
if (GetPlatform.isAndroid && if (GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) {
!isExistDevice && // mac地址不为空
isCurrentDevice && BuglyTool.uploadException(
mac != null) { message: '_connect:$deviceName',
detail: '_connect:$deviceName GetPlatform.isAndroid:${GetPlatform.isAndroid} isExistDevice:$isExistDevice mac:$mac');
scanSingleTimer?.cancel(); scanSingleTimer?.cancel();
//android // android
await doNotSearchBLE(mac, connectStateCallBack, await doNotSearchBLE(mac, connectStateCallBack, isAddEquipment: isAddEquipment);
isAddEquipment: isAddEquipment); //
scanSingleTimer = Timer(3.seconds, () { scanSingleTimer = Timer(3.seconds, () {
scanSingleTimer?.cancel(); scanSingleTimer?.cancel();
BuglyTool.uploadException(
message: '_connect:$deviceName',
detail: '_connect$deviceName scanSingleTimer 调用 startScanSingle');
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null); startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) => null);
}); });
} else if (isAddEquipment == false && isExistDevice == false) { } else if (isAddEquipment == false && isExistDevice == false) {
//使 //使
BuglyTool.uploadException(
message: '_connect:$deviceName',
detail: '_connect$deviceName isAddEquipment:$isAddEquipment isExistDevice:$isExistDevice 下一步调用startScanSingle');
// AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment'); // AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, _connectDevice(scanDevices, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment); isAddEquipment: isAddEquipment);
}); });
} else { } else {
BuglyTool.uploadException(
message: '_connect:$deviceName',
detail: '_connect$deviceName 直接调用_connectDevice');
// AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment'); // AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
_connectDevice(devicesList, deviceName, connectStateCallBack, _connectDevice(devicesList, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment); isAddEquipment: isAddEquipment);
@ -355,21 +389,21 @@ class BlueManage {
// //
bool isExistScanDevices(String connectDeviceName) { bool isExistScanDevices(String connectDeviceName) {
final bool isExistDevice = scanDevices.any((ScanResult element) => final bool isExistDevice = scanDevices.any((ScanResult element) => element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName);
element.device.platformName == connectDeviceName ||
element.advertisementData.advName == connectDeviceName);
return isExistDevice; return isExistDevice;
} }
Future<void> _connectDevice( Future<void> _connectDevice(
List<ScanResult> devicesList, List<ScanResult> devicesList,
String deviceName, String deviceName,
ConnectStateCallBack connectStateCallBack, { ConnectStateCallBack connectStateCallBack,
bool isAddEquipment = false, // {
bool isReconnect = true, // bool isAddEquipment = false, //
}) async { bool isReconnect = true, //
}) async {
// //
// AppLog.log("devicesList:$devicesList"); // AppLog.log("devicesList:$devicesList");
final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) => final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) =>
(d.device.platformName == deviceName) || (d.device.platformName == deviceName) ||
(d.advertisementData.advName == deviceName)); (d.advertisementData.advName == deviceName));
@ -390,16 +424,27 @@ class BlueManage {
_initListenConnectionState(); _initListenConnectionState();
} }
if (scanResult == null || connectDeviceMacAddress.isEmpty) { if (scanResult == null || connectDeviceMacAddress.isEmpty) {
BuglyTool.uploadException(
message: '_connectDevice:$deviceName',
detail: '_connectDevice$deviceName scanResult:$scanResult connectDeviceMacAddress$connectDeviceMacAddress scanResult == null || connectDeviceMacAddress.isEmpty不往下执行');
return; return;
} }
AppLog.log('调用了停止扫描的方法'); AppLog.log('调用了停止扫描的方法');
await stopScan(); await stopScan();
BuglyTool.uploadException(
message: '_connectDevice:$deviceName',
detail: '_connectDevice$deviceName devicesList$devicesList isReconnect:$isReconnect knownDeviceIndex$knownDeviceIndex 调用了停止扫描方法');
if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') && if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') &&
isAddEquipment == false) { isAddEquipment == false) {
// //
if (isReconnect == true) { if (isReconnect == true) {
AppLog.log('该锁已被重置, 重新发送扫描命令'); AppLog.log('该锁已被重置, 重新发送扫描命令');
BuglyTool.uploadException(
message: '_connectDevice:$deviceName',
detail: '_connectDevice$deviceName 该锁已被重置, 重新发送扫描命令 serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}');
scanDevices.clear(); scanDevices.clear();
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, _connectDevice(scanDevices, deviceName, connectStateCallBack,
@ -420,12 +465,19 @@ class BlueManage {
Future<void> doNotSearchBLE( Future<void> doNotSearchBLE(
String masAdds, ConnectStateCallBack connectStateCallBack, String masAdds, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async { {bool isAddEquipment = false}) async {
BuglyTool.uploadException(
message: 'doNotSearchBLE:$masAdds',
detail: 'doNotSearchBLE$masAdds 调用doNotSearchBLE');
await FlutterBluePlus.stopScan(); await FlutterBluePlus.stopScan();
if (bluetoothConnectDevice == null || if (bluetoothConnectDevice == null ||
bluetoothConnectDevice?.remoteId.str != masAdds) { bluetoothConnectDevice?.remoteId.str != masAdds) {
bluetoothConnectDevice = BluetoothDevice.fromId(masAdds); bluetoothConnectDevice = BluetoothDevice.fromId(masAdds);
_initGetMtuSubscription(); _initGetMtuSubscription();
_initListenConnectionState(); _initListenConnectionState();
}else{
BuglyTool.uploadException(
message: 'doNotSearchBLE:$masAdds',
detail: 'doNotSearchBLE$masAdds 未调用_initGetMtuSubscription()、_initListenConnectionState()');
} }
// //
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack, await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack,
@ -454,25 +506,36 @@ class BlueManage {
if (attempt >= maxAttempts) { if (attempt >= maxAttempts) {
AppLog.log('$maxAttempts次后尝试连接失败'); AppLog.log('$maxAttempts次后尝试连接失败');
BuglyTool.uploadException(
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败');
connectStateCallBack(BluetoothConnectionState.disconnected); connectStateCallBack(BluetoothConnectionState.disconnected);
} }
if (bluetoothConnectionState == BluetoothConnectionState.connected) { if (bluetoothConnectionState == BluetoothConnectionState.connected) {
try { try {
final List<BluetoothService> services = final List<BluetoothService> services = await bluetoothConnectDevice.discoverServices();
await bluetoothConnectDevice.discoverServices();
// //
for (final BluetoothService service in services) { for (final BluetoothService service in services) {
if (service.uuid == _serviceIdConnect) { if (service.uuid == _serviceIdConnect) {
for (final BluetoothCharacteristic characteristic for (final BluetoothCharacteristic characteristic in service.characteristics) {
in service.characteristics) { if (characteristic.characteristicUuid == _characteristicIdSubscription) {
if (characteristic.characteristicUuid ==
_characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic); _subScribeToCharacteristic(characteristic);
bluetoothConnectionState = BluetoothConnectionState.connected; bluetoothConnectionState = BluetoothConnectionState.connected;
connectStateCallBack(bluetoothConnectionState!); connectStateCallBack(bluetoothConnectionState!);
BuglyTool.uploadException(
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} 发现服务,连接成功,订阅数据');
} else{
BuglyTool.uploadException(
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} characteristic.characteristicUuid != _characteristicIdSubscription 失败');
} }
} }
}else{
BuglyTool.uploadException(
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} service.uuid != _serviceIdConnec 失败');
} }
} }
} on Exception catch (e) { } on Exception catch (e) {
@ -480,6 +543,9 @@ class BlueManage {
connectStateCallBack(bluetoothConnectionState!); connectStateCallBack(bluetoothConnectionState!);
AppLog.log( AppLog.log(
'发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState'); '发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState');
BuglyTool.uploadException(
message: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} 发现服务时报错 e$e');
rethrow; rethrow;
} }
} }

View File

@ -81,7 +81,7 @@ class SenderCancelAddCardCommand extends SenderProtocol {
data.addAll(subData); data.addAll(subData);
if ((data.length % 16) != 0) { if ((data.length % 16) != 0) {
int add = (16 - data.length % 16); int add = 16 - data.length % 16;
for (int i = 0; i < add; i++) { for (int i = 0; i < add; i++) {
data.add(0); data.add(0);
} }

View File

@ -206,8 +206,7 @@ class DoorLockLogLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
state.currentDate = entity.data!.currentDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000;
AppLog.log( AppLog.log('entity.data!.currentDate!:${entity.data!.currentDate!} currentDate:${state.currentDate}');
'entity.data!.currentDate!:${entity.data!.currentDate!} currentDate:${state.currentDate}');
senderReferEventRecordTime(); senderReferEventRecordTime();
} }
} }

View File

@ -61,6 +61,8 @@ class LockDetailLogic extends BaseGetXController {
Future<void> _replyOpenLock(Reply reply) async { Future<void> _replyOpenLock(Reply reply) async {
final int status = reply.data[6]; final int status = reply.data[6];
BuglyTool.uploadException(message: '_replyOpenLock', detail: '_replyOpenLock:${reply.data}');
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -330,14 +332,6 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
showBlueConnetctToastTimer(
outTimer: 20,
action: () {
// FlutterBuglyPlugin.reportException(exceptionName: '开门超时处理', reason: '开门超时,断开连接');
BuglyTool.uploadException(message: '开门超时处理', detail: '开门超时,断开连接--json');
resetOpenDoorState();
blueManageDisconnect();
});
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -347,11 +341,31 @@ class LockDetailLogic extends BaseGetXController {
final List<String>? token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
BlueManage() final String command = OpenLockCommand(
.blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, lockID: BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { userID: await Storage.getUid(),
openMode: state.openDoorModel,
openTime: getUTCNetTime(),
onlineToken: state.lockNetToken,
token: getTokenList,
needAuthor: 1,
signKey: signKeyDataList,
privateKey: getPrivateKeyList,
).toString();
AppLog.log('command:${command}');
showBlueConnetctToastTimer(
outTimer: 20,
action: () {
// FlutterBuglyPlugin.reportException(exceptionName: '开门超时处理', reason: '开门超时,断开连接');
BuglyTool.uploadException(message: '开门超时处理', detail: '开门超时,断开连接--$command');
resetOpenDoorState();
blueManageDisconnect();
});
BlueManage().blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--json',data: {'key1':'value1','key2':'value2'}); BuglyTool.uploadException(message: '蓝牙连接成功', detail: '蓝牙连接成功,发送开锁指令--$command');
// FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令'); // FlutterBuglyPlugin.reportException(exceptionName: '蓝牙连接成功', reason: '蓝牙连接成功,发送开锁指令');
IoSenderManage.senderOpenLock( IoSenderManage.senderOpenLock(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
@ -364,13 +378,12 @@ class LockDetailLogic extends BaseGetXController {
signKey: signKeyDataList, signKey: signKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
); );
} else if (deviceConnectionState == } else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
BuglyTool.uploadException(message: '蓝牙连接失败', detail: '蓝牙连接失败,断开连接--$command');
if (state.ifCurrentScreen.value == true) { if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); showBlueConnetctToast();
} }
resetOpenDoorState(); resetOpenDoorState();
} }
}); });
@ -453,6 +466,9 @@ class LockDetailLogic extends BaseGetXController {
// AppLog.log('从服务器获取联网token:${state.lockNetToken}'); // AppLog.log('从服务器获取联网token:${state.lockNetToken}');
openDoorAction(); openDoorAction();
} else { } else {
BuglyTool.uploadException(
message: '点击了需要联网开锁 2',
detail: '点击了需要联网开锁 获取连网token失败');
showToast('网络访问失败,请检查网络是否正常'.tr, something: () { showToast('网络访问失败,请检查网络是否正常'.tr, something: () {
resetOpenDoorState(); resetOpenDoorState();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();

View File

@ -22,6 +22,7 @@ import '../../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../../tools/appRouteObserver.dart'; import '../../../tools/appRouteObserver.dart';
import '../../../tools/dateTool.dart'; import '../../../tools/dateTool.dart';
import '../../../tools/eventBusEventManage.dart'; import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart';
import '../../../translations/trans_lib.dart'; import '../../../translations/trans_lib.dart';
import '../../lockMian/entity/lockListInfo_entity.dart'; import '../../lockMian/entity/lockListInfo_entity.dart';
import 'lockDetail_logic.dart'; import 'lockDetail_logic.dart';
@ -1432,14 +1433,14 @@ class _LockDetailPageState extends State<LockDetailPage>
state.openLockBtnState.value = 1; state.openLockBtnState.value = 1;
state.animationController!.forward(); state.animationController!.forward();
AppLog.log('点击开锁'); AppLog.log('点击开锁');
BuglyTool.time = DateTime.now().millisecondsSinceEpoch;
if (isOpenLockNeedOnline) { if (isOpenLockNeedOnline) {
// //
state.openDoorModel = 0; state.openDoorModel = 0;
// FlutterBuglyPlugin.reportException(exceptionName: '点击了不需要联网开锁'); // FlutterBuglyPlugin.reportException(exceptionName: '点击了不需要联网开锁');
BuglyTool.uploadException( BuglyTool.uploadException(
message: '点击了不需要联网开锁', message: '点击了不需要联网开锁',
detail: '点击了不需要联网开锁--------json', detail: '点击了不需要联网开锁 openDoorModel:${state.openDoorModel}');
data: {'key1': 'value1', 'key2': 'value2'});
AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网'); AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网');
logic.openDoorAction(); logic.openDoorAction();
} else { } else {
@ -1448,8 +1449,7 @@ class _LockDetailPageState extends State<LockDetailPage>
// FlutterBuglyPlugin.reportException(exceptionName: '点击了需要联网开锁'); // FlutterBuglyPlugin.reportException(exceptionName: '点击了需要联网开锁');
BuglyTool.uploadException( BuglyTool.uploadException(
message: '点击了需要联网开锁', message: '点击了需要联网开锁',
detail: '点击了需要联网开锁---json', detail: '点击了需要联网开锁 openDoorModel:${state.openDoorModel}');
data: {'key1': 'value1', 'key2': 'value2'});
AppLog.log('点击开锁 state.openDoorModel = 2 需要联网'); AppLog.log('点击开锁 state.openDoorModel = 2 需要联网');
logic.getLockNetToken(); logic.getLockNetToken();
} }

View File

@ -13,6 +13,9 @@ import 'package:star_lock/tools/storage.dart';
/// ///
/// ///
class BuglyTool { class BuglyTool {
static int time = 0;
static Future<void> init() async { static Future<void> init() async {
if (F.isProductionEnv) { if (F.isProductionEnv) {
// //
@ -57,11 +60,11 @@ class BuglyTool {
FlutterBugly.setUserId(userId?.toString() ?? ''); FlutterBugly.setUserId(userId?.toString() ?? '');
} }
static void uploadException({ static Future<void> uploadException({
required String message, required String message,
required String detail, required String detail,
Map? data, Map? data,
}) { }) async {
FlutterBugly.uploadException(message: message, detail: detail, data: data); FlutterBugly.uploadException(message: '${(await Storage.getMobile())!.isNotEmpty ? (await Storage.getMobile()) : (await Storage.getEmail())}+$time ---' + message, detail: detail, data: data);
} }
} }

View File

@ -92,8 +92,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 1.0.78+2024082701测试国际化功能 # 1.0.78+2024082701测试国际化功能
# 1.0.79+2024083001测试所有国家国际化功能 # 1.0.79+2024083001测试所有国家国际化功能
# 1.0.79+2024083001测试开完锁数据上传功能 # 1.0.79+2024083001测试开完锁数据上传功能
# 1.0.81+2024092901添加开锁数据收集功能
version: 1.0.79+2024090201 version: 1.0.81+2024090201
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'