Commit 88b34e27 authored by lyong's avatar lyong

fix:自动化测试增加获取Mac

parent d487a615
......@@ -124,7 +124,11 @@ function doTempHum(fd) {
console.log("tempHum: " + tempHum);
send(fd, tempHum);
}
function doGetMac(fd) { send(fd, '+ab:cd:ef:12:34:56'); }
function doGetMac(fd) {
var mac = "+" + autoUtil.getWifiInfo("address");
console.log("!!get mac: " + mac);
send(fd, mac);
}
function doGetSn(fd) {
var sn = "+" + autoUtil.getSn();
console.log('get sn: ' + sn);
......
......@@ -471,6 +471,31 @@ function initautoFactorySetting() {
var soundLevelText = "tinymix set 16 7"
system(soundLevelText);
}
function getWifiInfo(options) {
// wpa_state=SCANNING
// p2p_device_address=c2:f5:35:81:41:8e
// address=c0:f5:35:81:41:8e
// uuid=e1a83a1d-97b6-52eb-93f8-d323a8c9badf
var switchOption = options + "="
system("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 status > /tmp/wifi_status.txt");
const statusContent = fs.read("/tmp/wifi_status.txt", "r");
if (statusContent) {
const statusLines = statusContent.split('\n');
for (let i = 0; i < statusLines.length; i++) {
const line = statusLines[i].trim();
if (line.startsWith(switchOption)) {
const state = line.split('=')[1];
// if (state == "COMPLETED") {
// isConnected = true;
// break;
// }
return state;
}
}
}
return "FAil";
}
function system(cmd) {
systemCtrl.executeSystemCommand(cmd)
......@@ -504,5 +529,6 @@ module.exports = {
getRtcTimer: getRtcTimer,
setSsid: setSsid,
getssid: getssid,
initautoFactorySetting: initautoFactorySetting
initautoFactorySetting: initautoFactorySetting,
getWifiInfo: getWifiInfo
}
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