1.0.81版本打包给宿舍门测试
This commit is contained in:
parent
552c787c5a
commit
9336e83434
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user