Commit 78f9907c authored by waterword's avatar waterword

feat(factory): 优化 WiFi 连接功能

- 添加加密模式检测和处理
- 优化 WiFi 扫描和连接流程
- 增加系统信息更新功能
- 调整工厂测试列表页面布局
- 移除冗余代码和注释
parent a3d3dfb0
File added
...@@ -323,6 +323,7 @@ ...@@ -323,6 +323,7 @@
title_TEXT: "WIFI", title_TEXT: "WIFI",
initWifissid: "Midea_WifiBT", initWifissid: "Midea_WifiBT",
initWifipwd: "", initWifipwd: "",
initencryptedMode:"",
Reminder_TEXT: "请配置SSID为Midea_WifiBT,密码为空的WIFI路由器,且确保路由器能连上外网", Reminder_TEXT: "请配置SSID为Midea_WifiBT,密码为空的WIFI路由器,且确保路由器能连上外网",
wifiInfo_TEXT: "Midea_WifiBT", wifiInfo_TEXT: "Midea_WifiBT",
wifiInfoWarn_TEXT: "Midea_WifiBT信号强度需要大于-38dB", wifiInfoWarn_TEXT: "Midea_WifiBT信号强度需要大于-38dB",
...@@ -1143,8 +1144,8 @@ ...@@ -1143,8 +1144,8 @@
InterValTime: function () { InterValTime: function () {
console.log("=========================InterValTime===================="); console.log("=========================InterValTime====================");
wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd); wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd,this.initencryptedMode);
wifiEventJS.enableWLANSwitch();
this.$setY("id_hide", 0) this.$setY("id_hide", 0)
...@@ -1194,8 +1195,8 @@ ...@@ -1194,8 +1195,8 @@
this.$setOpacity("id_hide", 0.5) this.$setOpacity("id_hide", 0.5)
document.setAttribute('id_enableWLANPageList', 'list-set-edge-flash', false); document.setAttribute('id_enableWLANPageList', 'list-set-edge-flash', false);
wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd); wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd,this.initencryptedMode);
wifiEventJS.enableWLANSwitch(); // wifiEventJS.enableWLANSwitch();
this.testTimer = this.$setTimeout(this.InterValTime, 5000, [], this); this.testTimer = this.$setTimeout(this.InterValTime, 5000, [], this);
if (this.firstLoadInit == 1) { if (this.firstLoadInit == 1) {
...@@ -1288,6 +1289,8 @@ ...@@ -1288,6 +1289,8 @@
}); });
}, },
touchedscanWifiList: function (node, topNode, x, y) { touchedscanWifiList: function (node, topNode, x, y) {
console.log("================touchedscanWifiList===============");
wifiEventJS.enableWLANSwitch();
factoryDivPageJump.movePage("id_enableWLANChooseOnDiv"); factoryDivPageJump.movePage("id_enableWLANChooseOnDiv");
}, },
//touchedStartScanWifiButton: function (node, topNode, x, y) { //touchedStartScanWifiButton: function (node, topNode, x, y) {
...@@ -1317,7 +1320,7 @@ ...@@ -1317,7 +1320,7 @@
console.log("touchedStartScanWifiButton"); console.log("touchedStartScanWifiButton");
console.log("===================================================="); console.log("====================================================");
this.hideShowConnectbutton(0); this.hideShowConnectbutton(0);
wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd); wifiEventJS.connect_wifi(this.initWifissid, this.initWifipwd,this.initencryptedMode);
setTimeout(() => { setTimeout(() => {
this.hideShowConnectbutton(1); this.hideShowConnectbutton(1);
}, 10000); }, 10000);
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
// var systemCtrl = require("systemCtrl.js"); // var systemCtrl = require("systemCtrl.js");
var systemCtrl = require("systemCtrl.js"); var systemCtrl = require("systemCtrl.js");
var yesJumpPage = require("factoryYesJumpPage.js"); var yesJumpPage = require("factoryYesJumpPage.js");
var onestart = 1;
// var _userdata = require("userdata.js"); // var _userdata = require("userdata.js");
// var userData = _userdata.userData; // var userData = _userdata.userData;
export default { export default {
...@@ -142,15 +144,15 @@ ...@@ -142,15 +144,15 @@
en: 1, en: 1,
index: 0, index: 0,
}, },
{ //{
id: "id_factoryTestTp", // id: "id_factoryTestTp",
name: "tp", // name: "tp",
startup: "factoryTestTp", // startup: "factoryTestTp",
top: 370, // top: 370,
left: 350, //left: 350,
en: 1, // en: 1,
index: 0, // index: 0,
}, // },
], ],
}, },
...@@ -229,12 +231,18 @@ ...@@ -229,12 +231,18 @@
onShow: function () { onShow: function () {
console.log(this.$uri + "===========onShow============="); console.log(this.$uri + "===========onShow=============");
if(userData.factoryFlag != 1){ if (userData.factoryFlag != 1) {
userData.factoryFlag = 1; userData.factoryFlag = 1;
} }
console.log("wifiEventJS.enableWLANScanValue()================================================1");
var process = require("@system.process") if (onestart) {
if (process.platform == "win32") { var wifiEventJS = require("factory_testWifi.js");
wifiEventJS.enableWLANScanValue();
console.log("wifiEventJS.enableWLANScanValue()================================================2");
onestart = 0;
}
var process = require("@system.process")
if (process.platform == "win32") {
globalThat.$FontPath = "./../re860a-v1.0/GothamMedium.ttf"; globalThat.$FontPath = "./../re860a-v1.0/GothamMedium.ttf";
} else { } else {
globalThat.$FontPath = "./../RE860A/GothamMedium.ttf"; globalThat.$FontPath = "./../RE860A/GothamMedium.ttf";
......
...@@ -177,6 +177,7 @@ function startSystemInfoTimer(obj) { ...@@ -177,6 +177,7 @@ function startSystemInfoTimer(obj) {
if (systemInfoTimer != null) { if (systemInfoTimer != null) {
clearInterval(systemInfoTimer); clearInterval(systemInfoTimer);
} }
updateSystemInfo();
systemInfoTimer = setInterval(() => { systemInfoTimer = setInterval(() => {
updateSystemInfo(); updateSystemInfo();
}, 5000); }, 5000);
......
This diff is collapsed.
# WiFi连接脚本 #!/bin/sh
# 用法: ./connect_wifi.sh <SSID> <PSK>
if [ $# -ne 2 ]; then echo "==================connect wifi ================"
echo "用法: $0 <SSID> <PSK>" set -e
exit 1
fi
SSID=$1 SSID=$1
PSK=$2 PSK=$2
# 终止现有的udhcpc进程 if [ -z "$SSID" ]; then
killall -9 udhcpc echo "Usage: $0 <SSID> [PSK]"
exit 1
fi
echo "ssid :$SSID pwd :$PSK"
# 配置WiFi网络 killall hostapd dnsmasq udhcpc wpa_supplicant 2>/dev/null || true
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 ssid '\"'$SSID'\"' sleep 1
usleep 10000 # 10ms缓冲
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 psk '\"'$PSK'\"' wifi_down 2>/dev/null || true
usleep 10000 # 10ms缓冲 wifi_up 2>/dev/null || true
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 save_config for i in $(seq 10); do
usleep 10000 # 10ms缓冲 [ -d /sys/class/net/wlan0 ] && break
echo "wait wlan0 ... $i"
sleep 0.5
done
[ -d /sys/class/net/wlan0 ] || { echo "wlan0 not found"; exit 1; }
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 reconfigure
usleep 200000 # 200ms缓冲设置和执行
# 重新启用网络连接 if [ -n "$PSK" ]; then
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 disable_network 0 cat > /tmp/wpa_supplicant.conf <<EOF
usleep 10000 # 10ms缓冲 ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="$SSID"
psk="$PSK"
key_mgmt=WPA-PSK
scan_ssid=1
}
EOF
else
cat > /tmp/wpa_supplicant.conf <<EOF
ctrl_interface=/var/run/wpa_supplicant
update_config=1
network={
ssid="$SSID"
key_mgmt=NONE
}
EOF
fi
wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 enable_network 0
usleep 500000 # 500ms缓冲联网状态
# 启动DHCP客户端
udhcpc -b -i wlan0 -t 1 -A 1 -R -H test
echo "WiFi连接命令已执行"
wpa_supplicant -Dnl80211,wext -iwlan0 -c /tmp/wpa_supplicant.conf -B
sleep 3
if wpa_cli -iwlan0 status | grep -q "wpa_state=COMPLETED"; then
udhcpc -i wlan0 -n -q -t 5 -T 5
echo "[DONE] IP ok"
else
echo "[FAIL]"
exit 1
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment