更新
This commit is contained in:
@@ -10,11 +10,15 @@ import 'SleepdateWidget.dart';
|
||||
class SleepCalendarWidget extends StatefulWidget {
|
||||
final int? timestamp;
|
||||
final ValueChanged<DateTime>? onDateSelected;
|
||||
final int? type; // 新增参数,默认日历类型为日
|
||||
final Color highlightColor; // ✅ 新增
|
||||
|
||||
const SleepCalendarWidget({
|
||||
super.key,
|
||||
this.timestamp,
|
||||
this.onDateSelected,
|
||||
this.type = 1,
|
||||
this.highlightColor = Colors.black, // ✅ 默认值
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -55,172 +59,233 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(minHeight: 90.rpx),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF313541),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20.rpx),
|
||||
topRight: Radius.circular(20.rpx),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(65.rpx, 0.rpx, 65.rpx, 0.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.grey,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
8.rpx, 8.rpx, 8.rpx, 8.rpx),
|
||||
onTap: () => calendarController.previousMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_back_ios_new,
|
||||
color: const Color(0xFF6D6F73),
|
||||
size: 24.rpx,
|
||||
),
|
||||
),
|
||||
Obx(() => Text(
|
||||
'${calendarController.displayedMonth.value.year}年${calendarController.displayedMonth.value.month}月',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
)),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.grey,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
8.rpx, 8.rpx, 8.rpx, 8.rpx),
|
||||
onTap: () => calendarController.nextMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: const Color(0xFF6D6F73),
|
||||
size: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(minHeight: 720.rpx),
|
||||
decoration: const BoxDecoration(color: Color(0xFF242835)),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
65.rpx, 13.rpx, 65.rpx, 38.rpx),
|
||||
child: Obx(() {
|
||||
final daysInMonth = calendarController.getDaysInMonth();
|
||||
final calendarRows =
|
||||
calendarController.getCalendarRows(daysInMonth);
|
||||
final selectedDate = calendarController.selectedDate.value;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
// Weekdays Header
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 90.rpx),
|
||||
child: Row(
|
||||
children: [
|
||||
for (var day in ["一", "二", "三", "四", "五", "六", "日"])
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
day,
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FFFFFF"),
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Calendar days
|
||||
Column(
|
||||
children: calendarRows.map((week) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: week.map((date) {
|
||||
if (date.year == 0) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(0.rpx),
|
||||
child: SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
}
|
||||
final isSelected = selectedDate != null &&
|
||||
date.year == selectedDate.year &&
|
||||
date.month == selectedDate.month &&
|
||||
date.day == selectedDate.day;
|
||||
return Expanded(
|
||||
child: SleepdateWidget(
|
||||
date: date,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
calendarController.selectDate(date);
|
||||
if (widget.onDateSelected != null) {
|
||||
widget.onDateSelected!(date);
|
||||
}
|
||||
print(date);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
SizedBox(height: 55.rpx),
|
||||
Wrap(
|
||||
spacing: 20.rpx,
|
||||
runSpacing: 20.rpx,
|
||||
children: showLabel.map<Widget>((item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 20.rpx,
|
||||
height: 20.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: item["color"],
|
||||
borderRadius: BorderRadius.circular(10.rpx),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
_buildHeader(),
|
||||
_buildCalendarBody(showLabel),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(minHeight: 90.rpx),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF313541),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20.rpx),
|
||||
topRight: Radius.circular(20.rpx),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 65.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.grey,
|
||||
padding: EdgeInsets.all(8.rpx),
|
||||
onTap: () => calendarController.previousMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_back_ios_new,
|
||||
color: const Color(0xFF6D6F73),
|
||||
size: 24.rpx,
|
||||
),
|
||||
),
|
||||
Obx(() => Text(
|
||||
'${calendarController.displayedMonth.value.year}年${calendarController.displayedMonth.value.month}月',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
)),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.grey,
|
||||
padding: EdgeInsets.all(8.rpx),
|
||||
onTap: () => calendarController.nextMonth(),
|
||||
child: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: const Color(0xFF6D6F73),
|
||||
size: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCalendarBody(List<Map<String, dynamic>> showLabel) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(minHeight: 720.rpx),
|
||||
decoration: const BoxDecoration(color: Color(0xFF242835)),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(65.rpx, 13.rpx, 65.rpx, 38.rpx),
|
||||
child: Obx(() {
|
||||
final daysInMonth = calendarController.getDaysInMonth();
|
||||
final calendarRows = calendarController.getCalendarRows(daysInMonth);
|
||||
final selectedDate = calendarController.selectedDate.value;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
// 仅当为日历模式显示周标题
|
||||
_buildWeekdayHeader(),
|
||||
// 日历日期格子,支持日和周的高亮逻辑
|
||||
|
||||
_buildCalendarGrid(calendarRows, selectedDate),
|
||||
// TODO: 你可以扩展 month 类型的展示
|
||||
SizedBox(height: 55.rpx),
|
||||
_buildLegend(showLabel),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWeekdayHeader() {
|
||||
return Container(
|
||||
constraints: BoxConstraints(minHeight: 90.rpx),
|
||||
child: Row(
|
||||
children: ["一", "二", "三", "四", "五", "六", "日"].map((day) {
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
day,
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FFFFFF"),
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCalendarGrid(
|
||||
List<List<DateTime>> calendarRows, DateTime? selectedDate) {
|
||||
final isMonthSelected = widget.type == 3;
|
||||
|
||||
Widget content = Column(
|
||||
children: calendarRows.map((week) {
|
||||
final isWeekSelected = widget.type == 2 &&
|
||||
selectedDate != null &&
|
||||
week.any((d) =>
|
||||
d.year == selectedDate.year &&
|
||||
d.month == selectedDate.month &&
|
||||
d.day == selectedDate.day);
|
||||
|
||||
final row = Row(
|
||||
children: week.map((date) {
|
||||
if (date.year == 0) {
|
||||
return const Expanded(child: SizedBox.shrink());
|
||||
}
|
||||
|
||||
final isSelected = widget.type == 1 &&
|
||||
selectedDate != null &&
|
||||
date.year == selectedDate.year &&
|
||||
date.month == selectedDate.month &&
|
||||
date.day == selectedDate.day;
|
||||
|
||||
return Expanded(
|
||||
child: SleepdateWidget(
|
||||
highlightColor: widget.highlightColor, // ✅ 传入高亮颜色
|
||||
date: date,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
calendarController.selectDate(date);
|
||||
widget.onDateSelected?.call(date);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
|
||||
if (isWeekSelected) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.highlightColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConstants().button_container_radius),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: 6.rpx),
|
||||
margin: EdgeInsets.symmetric(vertical: 6.rpx),
|
||||
child: row,
|
||||
);
|
||||
} else {
|
||||
return row;
|
||||
}
|
||||
}).toList(),
|
||||
);
|
||||
|
||||
// 如果是月份模式,包一层黑色背景容器
|
||||
if (isMonthSelected && selectedDate != null) {
|
||||
final displayedMonth = calendarController.displayedMonth.value;
|
||||
|
||||
final isSameMonth = displayedMonth.year == selectedDate.year &&
|
||||
displayedMonth.month == selectedDate.month;
|
||||
|
||||
if (isSameMonth) {
|
||||
// ✅ 当前显示的月 == 当前选中的月 → 加高亮外框
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.highlightColor, // 背景淡色
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConstants().normal_container_radius),
|
||||
// border: Border.all(
|
||||
// color: widget.highlightColor,
|
||||
// width: 2.rpx,
|
||||
// ),
|
||||
),
|
||||
// padding: EdgeInsets.symmetric(vertical: 0.rpx, horizontal: 0.rpx),
|
||||
// margin: EdgeInsets.symmetric(vertical: 0.rpx),
|
||||
child: content,
|
||||
);
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildLegend(List<Map<String, dynamic>> showLabel) {
|
||||
return Wrap(
|
||||
spacing: 20.rpx,
|
||||
runSpacing: 20.rpx,
|
||||
children: showLabel.map((item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 20.rpx,
|
||||
height: 20.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: item["color"],
|
||||
borderRadius: BorderRadius.circular(10.rpx),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ class SleepdateWidget extends StatelessWidget {
|
||||
final DateTime date;
|
||||
final bool isSelected;
|
||||
final VoidCallback onTap;
|
||||
final Color highlightColor; // 新增
|
||||
|
||||
const SleepdateWidget({
|
||||
super.key,
|
||||
super.key,
|
||||
required this.date,
|
||||
required this.isSelected,
|
||||
required this.onTap,
|
||||
this.highlightColor = Colors.black, // 默认值黑色
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -25,8 +27,8 @@ class SleepdateWidget extends StatelessWidget {
|
||||
width: 90.rpx,
|
||||
height: 90.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30.rpx),
|
||||
color: isSelected ? Colors.black : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(30.rpx),
|
||||
color: isSelected ? highlightColor : Colors.transparent, // 使用传入的颜色
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(10.rpx, 10.rpx, 10.rpx, 10.rpx),
|
||||
@@ -35,15 +37,13 @@ class SleepdateWidget extends StatelessWidget {
|
||||
color: Color(0xFFDC1C1C),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Text(
|
||||
'${date.day}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${date.day}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
47
lib/component/tool/ToggleColorContainer.dart
Normal file
47
lib/component/tool/ToggleColorContainer.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ToggleColorContainer extends StatelessWidget {
|
||||
final Color initialColor;
|
||||
final Color toggledColor;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final Widget child;
|
||||
final double borderRadius;
|
||||
final VoidCallback onToggle;
|
||||
final bool toggled; // 新增,外部传入是否高亮
|
||||
|
||||
const ToggleColorContainer({
|
||||
Key? key,
|
||||
required this.initialColor,
|
||||
required this.toggledColor,
|
||||
required this.padding,
|
||||
required this.child,
|
||||
required this.onToggle,
|
||||
required this.toggled,
|
||||
this.borderRadius = 0,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color currentColor = toggled ? toggledColor : initialColor;
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: currentColor,
|
||||
borderRadius: BorderRadius.circular(borderRadius),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(borderRadius),
|
||||
onTap: onToggle,
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
//蓝牙指令
|
||||
|
||||
// wifi列表指令
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||||
import 'package:easydevice/src/app/thapp.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
|
||||
// wifi列表指令
|
||||
getWifiList(THapp tHapp) async {
|
||||
try {
|
||||
print("wscan scan");
|
||||
edm.EasyDartModule.logger.info("发送请求网络列表指令");
|
||||
DailyLogUtils.writeLog("发送请求网络列表指令");
|
||||
List data = [];
|
||||
var wifilist = await tHapp.send("wscan scan", true, (log) {
|
||||
print("[bles]${log.log}");
|
||||
print("[aaaaaa]${log.log}");
|
||||
if (log.log.contains("SCAN RESULT OVER!")) {
|
||||
final wifiList = <Map<String, dynamic>>[];
|
||||
final items = log.log.split('[wifi]: SCAN RESULT ITEM:');
|
||||
@@ -39,7 +40,7 @@ getWifiList(THapp tHapp) async {
|
||||
}
|
||||
|
||||
return false;
|
||||
}, 10);
|
||||
}, 2);
|
||||
|
||||
return wifilist;
|
||||
} catch (e) {
|
||||
@@ -93,7 +94,7 @@ Future<bool> sendWifiSetting(wifiItem, String password, THapp tHapp) async {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, 10);
|
||||
}, 1);
|
||||
|
||||
if (!success) {
|
||||
edm.EasyDartModule.logger.error("WiFi配置超时或失败");
|
||||
@@ -107,13 +108,71 @@ Future<bool> sendWifiSetting(wifiItem, String password, THapp tHapp) async {
|
||||
}
|
||||
}
|
||||
|
||||
// getDeviceWifiStatus(THapp tHapp, int times) async {
|
||||
// edm.EasyDartModule.logger.info("发送请求设备已配置网络状态指令");
|
||||
// DailyLogUtils.writeLog("发送请求设备已配置网络状态指令");
|
||||
// try {
|
||||
// var result = await tHapp.send("at+system info", true, (ss) {
|
||||
// var log = ss.log;
|
||||
|
||||
// // 匹配设备状态
|
||||
// final statusMatch = RegExp(r'Status=([^\s]+)').firstMatch(log);
|
||||
// final status = statusMatch?.group(1);
|
||||
// if (status != null) {
|
||||
// print('提取到的 status: $status');
|
||||
|
||||
// // 如果设备连接状态是 "connect",继续检测
|
||||
// if (status.contains('connect')) {
|
||||
// ss.result = true;
|
||||
// ss.over = true;
|
||||
|
||||
// // 匹配 Wi-Fi 连接信息
|
||||
// final wifiInfoMatch = RegExp(
|
||||
// r'WIFI CONNECTED INFO:SSID=([^\s]+),RSSI=([-0-9]+),AUTH=([0-9]+),CH=([0-9]+),BSSID=([A-F0-9]+)')
|
||||
// .firstMatch(log);
|
||||
// if (wifiInfoMatch != null) {
|
||||
// final ssid = wifiInfoMatch.group(1);
|
||||
// final rssi = wifiInfoMatch.group(2);
|
||||
// final auth = wifiInfoMatch.group(3);
|
||||
// final ch = wifiInfoMatch.group(4);
|
||||
// final bssid = wifiInfoMatch.group(5);
|
||||
|
||||
// // 打印并返回 Wi-Fi 信息
|
||||
// print(
|
||||
// 'Wi-Fi 信息: SSID=$ssid, RSSI=$rssi, AUTH=$auth, CH=$ch, BSSID=$bssid');
|
||||
|
||||
// // 停止监听并返回信息
|
||||
// ss.result = {
|
||||
// 'ssid': ssid,
|
||||
// 'rssi': rssi,
|
||||
// 'auth': auth,
|
||||
// 'ch': ch,
|
||||
// 'bssid': bssid,
|
||||
// };
|
||||
// ss.over = true;
|
||||
// return ss.result;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 未找到状态或Wi-Fi信息时,返回 false
|
||||
// return false;
|
||||
// }, times);
|
||||
|
||||
// return result;
|
||||
// } catch (e) {
|
||||
// print(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
getDeviceWifiStatus(THapp tHapp, int times) async {
|
||||
edm.EasyDartModule.logger.info("发送请求设备已配置网络状态指令");
|
||||
DailyLogUtils.writeLog("发送请求设备已配置网络状态指令");
|
||||
print("at+system info");
|
||||
|
||||
try {
|
||||
var result = await tHapp.send("at+system info", true, (ss) {
|
||||
var log = ss.log;
|
||||
|
||||
// 匹配设备状态
|
||||
final statusMatch = RegExp(r'Status=([^\s]+)').firstMatch(log);
|
||||
final status = statusMatch?.group(1);
|
||||
@@ -122,9 +181,6 @@ getDeviceWifiStatus(THapp tHapp, int times) async {
|
||||
|
||||
// 如果设备连接状态是 "connect",继续检测
|
||||
if (status.contains('connect')) {
|
||||
ss.result = true;
|
||||
ss.over = true;
|
||||
|
||||
// 匹配 Wi-Fi 连接信息
|
||||
final wifiInfoMatch = RegExp(
|
||||
r'WIFI CONNECTED INFO:SSID=([^\s]+),RSSI=([-0-9]+),AUTH=([0-9]+),CH=([0-9]+),BSSID=([A-F0-9]+)')
|
||||
@@ -149,12 +205,12 @@ getDeviceWifiStatus(THapp tHapp, int times) async {
|
||||
'bssid': bssid,
|
||||
};
|
||||
ss.over = true;
|
||||
return ss.result;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 未找到状态或Wi-Fi信息时,返回 false
|
||||
// 继续监听
|
||||
return false;
|
||||
}, times);
|
||||
|
||||
@@ -163,3 +219,37 @@ getDeviceWifiStatus(THapp tHapp, int times) async {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getDeviceNetVersion(THapp tHapp, int times) async {
|
||||
edm.EasyDartModule.logger.info("发送请求设备的网络信息");
|
||||
DailyLogUtils.writeLog("发送请求设备的网络信息");
|
||||
print("ls /root/mnt");
|
||||
|
||||
String netType = "unknown";
|
||||
|
||||
try {
|
||||
var result = await tHapp.send("ls /root/mnt", true, (ss) {
|
||||
var log = ss.log;
|
||||
print("[获取]$log");
|
||||
|
||||
if (log.contains("wifi.json") || log.contains("a76xx.json")) {
|
||||
if (log.contains("wifi.json")) {
|
||||
netType = "wifi";
|
||||
} else if (log.contains("a76xx.json")) {
|
||||
netType = "4g";
|
||||
}
|
||||
ss.over = true;
|
||||
ss.result = netType;
|
||||
// 继续监听
|
||||
return true;
|
||||
}
|
||||
ss.over = false;
|
||||
return false;
|
||||
}, times, 15);
|
||||
|
||||
return netType;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return netType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user