|
|
|
@ -1,4 +1,5 @@ |
|
|
|
import 'package:classic_bluetooth/classic_bluetooth.dart'; |
|
|
|
import 'package:voitrans/data/models/appconfig_model.dart'; |
|
|
|
import '/routes/app_routes.dart'; |
|
|
|
import 'package:logger/web.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
@ -12,6 +13,7 @@ import 'package:dio/dio.dart'; |
|
|
|
import 'package:path_provider/path_provider.dart'; |
|
|
|
import 'package:ota/ota.dart'; |
|
|
|
import '../../../data/services/ble_manager.dart'; |
|
|
|
import '../../../data/models/appconfig.dart'; |
|
|
|
|
|
|
|
class OtaUpgradeController extends GetxController { |
|
|
|
static const int NOT_STARTED = -1; // 未开始 |
|
|
|
@ -193,24 +195,26 @@ class OtaUpgradeController extends GetxController { |
|
|
|
_address = connectedDevices.first.address; |
|
|
|
} |
|
|
|
|
|
|
|
// API请求 |
|
|
|
final response = await Api.getproduct({ |
|
|
|
"id": deviceInfo.firmwareProductId, |
|
|
|
}); |
|
|
|
DBProduct? product = AppConfig.getproduct("DeapSound"); |
|
|
|
|
|
|
|
// 处理API响应 |
|
|
|
if (response['product'] == null) { |
|
|
|
throw const FormatException('API 响应格式错误'); |
|
|
|
} |
|
|
|
// // API请求 |
|
|
|
// final response = await Api.getproduct({ |
|
|
|
// "id": deviceInfo.firmwareProductId, |
|
|
|
// }); |
|
|
|
|
|
|
|
// // 处理API响应 |
|
|
|
// if (response['product'] == null) { |
|
|
|
// throw const FormatException('API 响应格式错误'); |
|
|
|
// } |
|
|
|
|
|
|
|
final resp = OtaConfigResp.fromJson(response); |
|
|
|
Logger().d('getequipmentinfo,resp.systemversion: ${resp.systemversion}'); |
|
|
|
latestVersion.value = resp.systemversion!; |
|
|
|
updatedescription.value = resp.updatedescription!; |
|
|
|
updatepackageaddress = resp.updatepackageaddress!; |
|
|
|
// final resp = OtaConfigResp.fromJson(response); |
|
|
|
// Logger().d('getequipmentinfo,resp.systemversion: ${resp.systemversion}'); |
|
|
|
// latestVersion.value = resp.systemversion!; |
|
|
|
// updatedescription.value = resp.updatedescription!; |
|
|
|
updatepackageaddress = product!.updatepackageaddress!; |
|
|
|
|
|
|
|
// 版本检查 |
|
|
|
bool isUpdate = _isNewVersionAvailable(resp.systemversion!); |
|
|
|
bool isUpdate = _isNewVersionAvailable(product!.version!); |
|
|
|
|
|
|
|
if (isUpdate) { |
|
|
|
await _bleManager.setEnterOta(true); |
|
|
|
|