更新安卓通知栏提示
This commit is contained in:
@@ -110,8 +110,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
updateAll();
|
||||
} else {
|
||||
safeShowNotification(res.msg ?? "获取设备状态异常");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -122,8 +122,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
updateAll();
|
||||
} else {
|
||||
safeShowNotification(res.msg ?? "获取设备状态异常");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
}
|
||||
}).catchError((e, stack) {
|
||||
print("updateDeviceStatus 执行异常: $e\n$stack");
|
||||
@@ -140,127 +140,6 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
_statusTimer = null;
|
||||
}
|
||||
|
||||
// Future<ApiResponse> updateDeviceStatus() async {
|
||||
// try {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.get_bluetooth_device_status;
|
||||
// String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
|
||||
// if (model.devicelist != null && model.devicelist!.isNotEmpty) {
|
||||
// final macParams = model.devicelist!
|
||||
// .map((device) => "mac=${Uri.encodeQueryComponent(device.mac!)}")
|
||||
// .join("&");
|
||||
|
||||
// if (queryUrl.contains('?')) {
|
||||
// queryUrl += '&$macParams';
|
||||
// } else {
|
||||
// queryUrl += '?$macParams';
|
||||
// }
|
||||
// String? language = "";
|
||||
// if (languageController.selectLanguage != null) {
|
||||
// language = languageController.selectLanguage.value!.language_code;
|
||||
// }
|
||||
// if (language != null && language.isNotEmpty) {
|
||||
// if (queryUrl.contains("?")) {
|
||||
// queryUrl += "&lang=$language";
|
||||
// } else {
|
||||
// queryUrl += "?lang=$language";
|
||||
// }
|
||||
// }
|
||||
|
||||
// var response = await EasyDartModule.dio.get(queryUrl);
|
||||
// var responseData =
|
||||
// response.data is String ? jsonDecode(response.data) : response.data;
|
||||
// ApiResponse res =
|
||||
// ApiResponse.fromJson(responseData, (object) => object);
|
||||
// if (res.code != HttpStatusCodes.ok) return res;
|
||||
|
||||
// if (response.data['data'] != null && response.data['data'] is List) {
|
||||
// List<dynamic> responseList = response.data['data'];
|
||||
|
||||
// // 构建 mac -> 设备的映射
|
||||
// Map<String, BleDeviceData> deviceMap = {
|
||||
// for (var d in model.devicelist!)
|
||||
// if (d.mac != null) d.mac!.toLowerCase(): d,
|
||||
// };
|
||||
|
||||
// // 用于记录已经设置过主从关系的 mac,避免重复
|
||||
// Set<String> processedMacs = {};
|
||||
|
||||
// for (var item in responseList) {
|
||||
// String mac = item['mac'].toLowerCase();
|
||||
// String? bindMac = item['bindMac']?.toLowerCase();
|
||||
// bool? bind = item['bind'];
|
||||
|
||||
// if (!deviceMap.containsKey(mac)) continue;
|
||||
|
||||
// BleDeviceData currentDevice = deviceMap[mac]!;
|
||||
// currentDevice.bind = bind;
|
||||
|
||||
// if (bindMac != null && deviceMap.containsKey(bindMac)) {
|
||||
// final isMutualBind = responseList.any((e) =>
|
||||
// e['mac']?.toString().toLowerCase() == bindMac &&
|
||||
// e['bindMac']?.toString().toLowerCase() == mac);
|
||||
|
||||
// if (isMutualBind) {
|
||||
// if (processedMacs.contains(mac) ||
|
||||
// processedMacs.contains(bindMac)) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// final masterMac = (mac.compareTo(bindMac) < 0) ? mac : bindMac;
|
||||
// final slaveMac = (mac.compareTo(bindMac) < 0) ? bindMac : mac;
|
||||
|
||||
// if (deviceMap.containsKey(masterMac) &&
|
||||
// deviceMap.containsKey(slaveMac)) {
|
||||
// deviceMap[masterMac]!.slave = deviceMap[slaveMac];
|
||||
// processedMacs.add(masterMac);
|
||||
// processedMacs.add(slaveMac);
|
||||
// }
|
||||
// } else {
|
||||
// if (!processedMacs.contains(mac)) {
|
||||
// BleDeviceData masterDevice = deviceMap[bindMac]!;
|
||||
// masterDevice.slave = currentDevice;
|
||||
// processedMacs.add(mac);
|
||||
// processedMacs.add(bindMac);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 获取所有被作为 slave 的 mac,用于排除掉
|
||||
// final Set<String> allSlaveMacs = {
|
||||
// for (var d in deviceMap.values)
|
||||
// if (d.slave?.mac != null) d.slave!.mac!.toLowerCase()
|
||||
// };
|
||||
|
||||
// // 构造最终列表,只保留主设备和未被作为 slave 的独立设备
|
||||
// final List<BleDeviceData> finalList = deviceMap.values.where((d) {
|
||||
// final mac = d.mac?.toLowerCase();
|
||||
// if (mac == null) return false;
|
||||
// if (d.slave != null) return true; // 主设备
|
||||
// return !allSlaveMacs.contains(mac); // 不是别人 slave 的独立设备
|
||||
// }).toList();
|
||||
|
||||
// model.betDevicelist = finalList;
|
||||
// } else {
|
||||
// model.betDevicelist = [];
|
||||
// }
|
||||
|
||||
// updateAll();
|
||||
// return res;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("获取设备状态异常: $e");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
// return ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
// }
|
||||
|
||||
// return ApiResponse(code: -1, msg: "未知错误".tr);
|
||||
// }
|
||||
|
||||
Future<ApiResponse> updateDeviceStatus() async {
|
||||
try {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
@@ -334,8 +213,8 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
}
|
||||
} catch (e) {
|
||||
print("获取设备状态异常: $e");
|
||||
EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
return ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user