更新传感器升级

This commit is contained in:
wyf
2025-09-02 14:03:00 +08:00
parent 8761e8bf1a
commit aad3a00ac3
9 changed files with 456 additions and 36 deletions

View File

@@ -72,6 +72,9 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
RxMap connect_wifi = {}.obs;
RxString? cid = "".obs;
RxBool isScanning = false.obs;
Map<String, Map> localUpgradeMac = {}; //mac 进度
void startStatusPolling() {
updateDeviceStatus().then((res) {
if (res.code == HttpStatusCodes.ok) {
@@ -141,9 +144,9 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
}
String? language = "";
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
if (language != null && language.isNotEmpty) {
if (queryUrl.contains("?")) {
queryUrl += "&lang=$language";
@@ -372,8 +375,8 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
);
}
loadMattressTimeData(String mac,{int time = 3}) async {
String serviceAddress = ServiceConstant.service_address;
loadMattressTimeData(String mac, {int time = 3}) async {
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.user_setting;
String type = "sleep_new_time_${mac}";

View File

@@ -63,14 +63,6 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
mhtBlueToothController.startStatusPolling();
mhtBlueToothController.search.value = "";
mhtBlueToothController.currentDeviceMac?.value = "";
// BluetoothHelper.listenBluetoothState((isOn) {
// if (!isOn && !_isDialogShowing) {
// _isDialogShowing = true;
// _showBluetoothNotEnabledDialog().then((_) {
// _isDialogShowing = false;
// });
// }
// });
BluetoothHelper.listenBluetoothState((isOn) {
mhtBlueToothController.model.bluetooth = isOn;
mhtBlueToothController.updateAll();

View File

@@ -12,6 +12,7 @@ class BlueToothDataModel {
String? macBID;
DateTime lastSeen; // 最后可见时间
String? deviceID; // 设备ID
int? version; // ✅ 新增版本号,可为空
BlueToothDataModel({
this.name = '',
@@ -22,7 +23,8 @@ class BlueToothDataModel {
this.macA = '',
this.macB = '',
required this.lastSeen,
this.deviceID, // ✅ 加入构造函数参数
this.deviceID,
this.version, // ✅ 构造函数参数
});
factory BlueToothDataModel.fromScanResult(
@@ -31,7 +33,8 @@ class BlueToothDataModel {
bool bind = false,
String name = '',
String mac = '',
String? deviceID, // ✅ 工厂方法接收 deviceID
String? deviceID,
int? version, // ✅ 工厂方法参数
}) {
String finalName =
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
@@ -45,7 +48,8 @@ class BlueToothDataModel {
macA: '',
macB: '',
lastSeen: DateTime.now(),
deviceID: deviceID, // ✅ 赋值
deviceID: deviceID,
version: version, // ✅ 赋值
);
}
}