更新绑定时候选择房间和设置房间名称

This commit is contained in:
wyf
2025-07-19 17:43:22 +08:00
parent 1fe904af00
commit 32bad1834d
5 changed files with 307 additions and 147 deletions

View File

@@ -241,6 +241,7 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
if (currentFullDevice != null) {
currentFullDevice!.macAID = res.data['macA'];
currentFullDevice!.macBID = res.data['macB'];
currentFullDevice!.deviceID = res.data['id'];
}
}
return res;

View File

@@ -195,7 +195,12 @@ class _MHTPeopleInfoPageState extends State<MHTPeopleInfoPage> {
TopSlideNotification.show(context, text: "保存成功");
MHTHomeController mhtHomeController = Get.find();
mhtHomeController.getPersonList();
Get.offNamed("/bindDeviceSuccess");
// Get.offNamed("/bindDeviceSuccess");
Map data = {};
final device = bluetoothController.currentFullDevice;
data['_id'] = device!.deviceID;
data['isNextStep'] = true;
Get.toNamed("/editBedPage", arguments: data);
},
colors: const [
Color(0xFFFCFCFC),

View File

@@ -10,7 +10,8 @@ class BlueToothDataModel {
int type;
String? macAID;
String? macBID;
DateTime lastSeen; // 添加的最后可见时间字段
DateTime lastSeen; // 最后可见时间
String? deviceID; // 设备ID
BlueToothDataModel({
this.name = '',
@@ -20,12 +21,18 @@ class BlueToothDataModel {
required this.type,
this.macA = '',
this.macB = '',
required this.lastSeen, // 添加到构造函数参数
required this.lastSeen,
this.deviceID, // ✅ 加入构造函数参数
});
factory BlueToothDataModel.fromScanResult(ScanResult result, int type,
{bool bind = false, String name = '', String mac = ''}) {
// 如果外部没有传入 name则取 localName
factory BlueToothDataModel.fromScanResult(
ScanResult result,
int type, {
bool bind = false,
String name = '',
String mac = '',
String? deviceID, // ✅ 工厂方法接收 deviceID
}) {
String finalName =
name.isNotEmpty ? name : (result.advertisementData.localName ?? '');
@@ -35,9 +42,10 @@ class BlueToothDataModel {
mac: mac,
scanResult: result,
type: type,
macA: '', // 保持原有默认值
macB: '', // 保持原有默认值
lastSeen: DateTime.now(), // 设置为当前时间
macA: '',
macB: '',
lastSeen: DateTime.now(),
deviceID: deviceID, // ✅ 赋值
);
}
}
}