Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -41,7 +41,7 @@ class PeopleInfoController extends GetControllerEx<PeopleInfoModel> {
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
await getPeoples(Get.arguments['mac']); // 控制器创建时立即执行
|
||||
// await getPeoples(Get.arguments['mac']); // 控制器创建时立即执行
|
||||
}
|
||||
|
||||
getPeoples(String mac) async {
|
||||
|
||||
@@ -60,7 +60,7 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
|
||||
RxDouble textHalfWidth = 0.0.obs;
|
||||
List device_bind_status = [];
|
||||
int device_bind_flag = 0;//0。未初始化 1.已初始化
|
||||
int device_bind_flag = 0; //0。未初始化 1.已初始化
|
||||
|
||||
Future<ApiResponse> uploadImg() async {
|
||||
EasyDartModule.logger.info("请求上传图片");
|
||||
@@ -133,6 +133,10 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
apiResponse.msg = "昵称为空".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
if (user.tmpNickName!.length >= 9) {
|
||||
apiResponse.msg = "最长字符为8个字".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_info;
|
||||
|
||||
@@ -189,6 +189,7 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
return res;
|
||||
} else {
|
||||
model.deviceDataStatus = [];
|
||||
return ApiResponse(code:1, msg: "".tr);
|
||||
}
|
||||
} catch (e) {
|
||||
print("获取设备状态异常: $e");
|
||||
@@ -218,10 +219,10 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
"macA": bleDevice.macA,
|
||||
if (bleDevice.macB != null && bleDevice.macB!.isNotEmpty)
|
||||
"macB": bleDevice.macB,
|
||||
if (bleDevice.name!=null && bleDevice.name!.isNotEmpty)
|
||||
'param':{
|
||||
'name':bleDevice.name,
|
||||
},
|
||||
if (bleDevice.name != null && bleDevice.name!.isNotEmpty)
|
||||
'param': {
|
||||
'name': bleDevice.name,
|
||||
},
|
||||
};
|
||||
|
||||
var response =
|
||||
@@ -237,8 +238,8 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
// personController.currentPersonId.value = res.data['id'];
|
||||
//todo 绑定成功需要返回传感器id
|
||||
currentDeviceMac.value = "";
|
||||
if(res.data!=null){
|
||||
if(currentFullDevice!=null){
|
||||
if (res.data != null) {
|
||||
if (currentFullDevice != null) {
|
||||
currentFullDevice!.macAID = res.data['macA'];
|
||||
currentFullDevice!.macBID = res.data['macB'];
|
||||
}
|
||||
|
||||
@@ -112,97 +112,105 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
||||
}
|
||||
|
||||
void _startScanning() async {
|
||||
if (!mounted || isScanning || !mhtBlueToothController.shouldScan.value)
|
||||
return;
|
||||
try {
|
||||
if (!mounted || isScanning || !mhtBlueToothController.shouldScan.value)
|
||||
return;
|
||||
|
||||
_scanSubscription?.cancel();
|
||||
var bluetoothState = await FlutterBluePlus.isOn;
|
||||
mhtBlueToothController.model.bluetooth = bluetoothState;
|
||||
mhtBlueToothController.updateAll();
|
||||
|
||||
if (!bluetoothState && !_isDialogShowing) {
|
||||
_isDialogShowing = true;
|
||||
mhtBlueToothController.model.blueRawData = [];
|
||||
mhtBlueToothController.model.deviceDataStatus = [];
|
||||
_scanSubscription?.cancel();
|
||||
var bluetoothState = await FlutterBluePlus.isOn;
|
||||
mhtBlueToothController.model.bluetooth = bluetoothState;
|
||||
mhtBlueToothController.updateAll();
|
||||
await _showBluetoothNotEnabledDialog();
|
||||
_isDialogShowing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isScanning) {
|
||||
setState(() {
|
||||
isScanning = true;
|
||||
});
|
||||
|
||||
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
||||
|
||||
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
if (!mounted) return;
|
||||
|
||||
final signalThreshold = mhtBlueToothController.model.singal!;
|
||||
final searchKey =
|
||||
mhtBlueToothController.search.value.trim().toLowerCase();
|
||||
|
||||
final filteredResults = results.where((r) {
|
||||
final localName = r.advertisementData.localName;
|
||||
final isTarget = r.rssi > signalThreshold &&
|
||||
isTargetDevice(
|
||||
localName, widget.deviceType['reg'].cast<String>());
|
||||
if (!isTarget) return false;
|
||||
final name = r.advertisementData.advName.toLowerCase();
|
||||
String macAddress = r.device.remoteId.str;
|
||||
final mac = macAddress.replaceAll(':', '');
|
||||
final search = searchKey.trim().replaceAll(':', '').toLowerCase();
|
||||
|
||||
if (search.isNotEmpty &&
|
||||
!name.contains(search) &&
|
||||
!mac.replaceAll(':', '').toLowerCase().contains(search)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}).map((r) {
|
||||
return BlueToothDataModel.fromScanResult(
|
||||
r, widget.deviceType['type']?.toInt(),
|
||||
bind: false,
|
||||
name: r.advertisementData.localName,
|
||||
mac: r.device.remoteId.str.replaceAll(':', ''));
|
||||
}).toList();
|
||||
|
||||
final currentDevices = mhtBlueToothController.model.blueRawData ?? [];
|
||||
final newDevices = <BlueToothDataModel>[];
|
||||
|
||||
for (var newDevice in filteredResults) {
|
||||
// 检查设备是否已存在
|
||||
final existingIndex =
|
||||
currentDevices.indexWhere((d) => d.mac == newDevice.mac);
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
// 更新已有设备信息(如信号强度)
|
||||
currentDevices[existingIndex] = newDevice;
|
||||
} else {
|
||||
// 添加新设备
|
||||
newDevices.add(newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
mhtBlueToothController.model.blueRawData = [
|
||||
...currentDevices,
|
||||
...newDevices
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
await Future.delayed(Duration(seconds: 10));
|
||||
await FlutterBluePlus.stopScan();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
if (!bluetoothState && !_isDialogShowing) {
|
||||
_isDialogShowing = true;
|
||||
mhtBlueToothController.model.blueRawData = [];
|
||||
mhtBlueToothController.model.deviceDataStatus = [];
|
||||
mhtBlueToothController.updateAll();
|
||||
await _showBluetoothNotEnabledDialog();
|
||||
_isDialogShowing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isScanning) {
|
||||
setState(() {
|
||||
isScanning = true;
|
||||
});
|
||||
|
||||
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
||||
|
||||
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
if (!mounted) return;
|
||||
|
||||
final signalThreshold = mhtBlueToothController.model.singal!;
|
||||
final searchKey =
|
||||
mhtBlueToothController.search.value.trim().toLowerCase();
|
||||
|
||||
final filteredResults = results.where((r) {
|
||||
final localName = r.advertisementData.localName;
|
||||
final isTarget = r.rssi > signalThreshold &&
|
||||
isTargetDevice(
|
||||
localName, widget.deviceType['reg'].cast<String>());
|
||||
if (!isTarget) return false;
|
||||
final name = r.advertisementData.advName.toLowerCase();
|
||||
String macAddress = r.device.remoteId.str;
|
||||
final mac = macAddress.replaceAll(':', '');
|
||||
final search = searchKey.trim().replaceAll(':', '').toLowerCase();
|
||||
|
||||
if (search.isNotEmpty &&
|
||||
!name.contains(search) &&
|
||||
!mac.replaceAll(':', '').toLowerCase().contains(search)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}).map((r) {
|
||||
return BlueToothDataModel.fromScanResult(
|
||||
r, widget.deviceType['type']?.toInt(),
|
||||
bind: false,
|
||||
name: r.advertisementData.localName,
|
||||
mac: r.device.remoteId.str.replaceAll(':', ''));
|
||||
}).toList();
|
||||
|
||||
final currentDevices = mhtBlueToothController.model.blueRawData ?? [];
|
||||
final newDevices = <BlueToothDataModel>[];
|
||||
|
||||
for (var newDevice in filteredResults) {
|
||||
// 检查设备是否已存在
|
||||
final existingIndex =
|
||||
currentDevices.indexWhere((d) => d.mac == newDevice.mac);
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
// 更新已有设备信息(如信号强度)
|
||||
currentDevices[existingIndex] = newDevice;
|
||||
} else {
|
||||
// 添加新设备
|
||||
newDevices.add(newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
mhtBlueToothController.model.blueRawData = [
|
||||
...currentDevices,
|
||||
...newDevices
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
await Future.delayed(Duration(seconds: 10));
|
||||
await FlutterBluePlus.stopScan();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
ef.log("$e");
|
||||
} finally {
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/home/home_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/mh_controller/people_info_controller.dart';
|
||||
import 'package:vbvs_app/controller/person/person_controller.dart';
|
||||
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
@@ -33,6 +34,7 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
PeopleInfoController controller = Get.put(PeopleInfoController());
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
getPersonData();
|
||||
return LayoutBuilder(
|
||||
builder: (context, boxConstraints) => GestureDetector(
|
||||
onTap: () {
|
||||
@@ -831,4 +833,9 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getPersonData() async {
|
||||
PeopleInfoController peopleInfoController = Get.find();
|
||||
await peopleInfoController.getPeoples(Get.arguments['mac']); // 控制器创建时立即执行
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user