更新
This commit is contained in:
@@ -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