更新绑定时候选择房间和设置房间名称
This commit is contained in:
@@ -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, // ✅ 赋值
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user