|
|
|
@ -113,7 +113,7 @@ class BleManager extends GetxService { |
|
|
|
// 经典蓝牙实例 |
|
|
|
|
|
|
|
// 当前连接的设备信息 |
|
|
|
String? _currentDeviceAddress; |
|
|
|
String? currentDeviceAddress; |
|
|
|
String? _currentDeviceName; |
|
|
|
|
|
|
|
// BLE连接状态 |
|
|
|
@ -513,7 +513,7 @@ class BleManager extends GetxService { |
|
|
|
(firmwareVersion != null || batteryLevel != null)) { |
|
|
|
Logger.info('lxm--设备信息不存在,创建新的设备信息对象'); |
|
|
|
// 使用保存的设备信息创建新的DeviceInfo对象 |
|
|
|
String deviceAddress = _currentDeviceAddress ?? ""; |
|
|
|
String deviceAddress = currentDeviceAddress ?? ""; |
|
|
|
String deviceName = _currentDeviceName ?? ""; |
|
|
|
|
|
|
|
Logger.info('lxm--创建新的设备信息对象: address=$deviceAddress, name=$deviceName'); |
|
|
|
@ -561,7 +561,7 @@ class BleManager extends GetxService { |
|
|
|
void clearDeviceInfo() { |
|
|
|
Logger.info('清除设备信息'); |
|
|
|
deviceInfo.value = null; |
|
|
|
_currentDeviceAddress = null; |
|
|
|
currentDeviceAddress = null; |
|
|
|
_currentDeviceName = null; |
|
|
|
} |
|
|
|
|
|
|
|
@ -573,7 +573,7 @@ class BleManager extends GetxService { |
|
|
|
// 确保设备信息对象存在 |
|
|
|
if (deviceInfo.value == null && _isConnected.value) { |
|
|
|
// 创建初始设备信息对象 |
|
|
|
String deviceAddress = _currentDeviceAddress ?? ""; |
|
|
|
String deviceAddress = currentDeviceAddress ?? ""; |
|
|
|
String deviceName = _currentDeviceName ?? ""; |
|
|
|
|
|
|
|
Logger.info('初始化设备信息对象: address=$deviceAddress, name=$deviceName'); |
|
|
|
@ -1036,12 +1036,12 @@ class BleManager extends GetxService { |
|
|
|
try { |
|
|
|
// 保存设备地址信息 |
|
|
|
if (macAddress != null) { |
|
|
|
_currentDeviceAddress = macAddress; |
|
|
|
currentDeviceAddress = macAddress; |
|
|
|
// 从蓝牙管理器获取设备名称 |
|
|
|
final bluetoothManager = Get.find<BluetoothManager>(); |
|
|
|
_currentDeviceName = bluetoothManager.currentDevice?.name ?? ""; |
|
|
|
Logger.info( |
|
|
|
'保存设备信息: address=$_currentDeviceAddress, name=$_currentDeviceName'); |
|
|
|
'保存设备信息: address=$currentDeviceAddress, name=$_currentDeviceName'); |
|
|
|
} |
|
|
|
|
|
|
|
return await _bleService.registerBackgroundScan(macAddress: macAddress); |
|
|
|
|