Commit 6ceaf359 authored by lyong's avatar lyong

系统信息

parent 353aaeea
<html>
<div class="screen" id="id_screen">
<!-- <div class="trueActiveDiv" id="id_gifIconDiv" style="top:0; color: black; background-color: black;"> -->
<!-- <image class="gifIcon" id="id_gifIcon" :src="gifIconSrc" style="color: black; background-color: black;"></image> -->
<!-- </div> -->
<div id="systemId1" style="left:20;top: 10;width: 440;height: 366;">
<div style="left:0;top: 0;width: 440;height: 55; background-color: #99D0F7;">
<text class="fontsize40" id="crtsystemId1_title_TEXT" style="left:0;top: 0;width: 460;height: 55;text-align: center; background-color: transparent;color: black;">{{
crtsystemId1_title_TEXT }}</text>
</div>
<text class="fontsize24" id="systemId1_TextHeader1" style="top: 60;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId1_TextHeader1}}</text>
<div style="left:0;top: 75;width: 200;height: 366;">
<text class="fontsize24" id="systemId1_TextHeader2" style=" top: 45;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId1_TextHeader2}}</text>
<text class="fontsize24" id="systemId1_TextHeader3" style="top: 90;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId1_TextHeader3}}</text>
<text class="fontsize24" id="systemId1_TextHeader4" style="top: 135;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId1_TextHeader4}}</text>
<text class="fontsize24" id="systemId1_TextHeader5" style="top: 180;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId1_TextHeader5}}</text>
</div>
<text class="fontsize24" id="systemId1_TextValue1" style="top: 85;color: rgb(0, 0, 0);text-align: center;width: 460;height:45;">{{crtsystemId1_TextValue1}}</text>
<div style="left:150;top: 75;width: 240;height: 366;">
<text class="fontsize24" id="systemId1_TextValue2" style=" top: 45;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId1_TextValue2}}</text>
<text class="fontsize24" id="systemId1_TextValue3" style="top: 90;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId1_TextValue3}}</text>
<text class="fontsize24" id="systemId1_TextValue4" style="top: 135;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId1_TextValue4}}</text>
<text class="fontsize24" id="systemId1_TextValue5" style="top: 180;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId1_TextValue5}}</text>
</div>
<text class="fontsize24" id="systemId1_TextTips" style="top: 300;color: rgb(0, 0, 0);text-align: center;width: 440;height:80;">{{crtsystemId1_crtTextTips}}</text>
</div>
<div id="systemId2" style="left:20;top: -480;width: 440;height: 366;">
<div style="left:0;top: 0;width: 440;height: 55; background-color: #99D0F7;">
<text class="fontsize40" id="crtsystemId2_title_TEXT" style="left:0;top: 0;width: 460;height: 55;text-align: center; background-color: transparent;color: black;">{{
crtsystemId2_title_TEXT }}</text>
</div>
<div style="left:0;top: 75;width: 200;height: 366;">
<text class="fontsize24" id="systemId2_TextHeader1" style="top: 0;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId2_TextHeader1}}</text>
<!-- <text class="fontsize24" id="systemId2_TextHeader2" style=" top: 45;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId2_TextHeader2}}</text> -->
<text class="fontsize24" id="systemId2_TextHeader3" style="top: 45;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId2_TextHeader3}}</text>
<text class="fontsize24" id="systemId2_TextHeader4" style="top: 90;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId2_TextHeader4}}</text>
<text class="fontsize24" id="systemId2_TextHeader5" style="top: 135;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId2_TextHeader5}}</text>
</div>
<div style="left:150;top: 75;width: 240;height: 366;">
<text class="fontsize24" id="systemId2_TextValue1" style="top: 0;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId2_TextValue1}}</text>
<!-- <text class="fontsize24" id="systemId2_TextValue2" style=" top: 45;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId2_TextValue2}}</text> -->
<text class="fontsize24" id="systemId2_TextValue3" style="top: 45;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId2_TextValue3}}</text>
<text class="fontsize24" id="systemId2_TextValue4" style="top: 90;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId2_TextValue4}}</text>
<text class="fontsize24" id="systemId2_TextValue5" style="top: 135;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId2_TextValue5}}</text>
</div>
<text class="fontsize24" id="systemId2_TextTips" style="top: 300;color: rgb(0, 0, 0);text-align: center;width: 440;height:80;">{{crtsystemId2_crtTextTips}}</text>
</div>
<div id="systemId3" style="left:20;top: -480;width: 440;height: 366;">
<div style="left:0;top: 0;width: 440;height: 55; background-color: #99D0F7;">
<text class="fontsize40" id="crtsystemId3_title_TEXT" style="left:0;top: 0;width: 460;height: 55;text-align: center; background-color: transparent;color: black;">{{
crtsystemId3_title_TEXT }}</text>
</div>
<div style="left:0;top: 75;width: 200;height: 366;">
<text class="fontsize24" id="systemId3_TextHeader1" style="top: 0;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId3_TextHeader1}}</text>
<text class="fontsize24" id="systemId3_TextHeader2" style=" top: 45;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId3_TextHeader2}}</text>
<text class="fontsize24" id="systemId3_TextHeader3" style="top: 90;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId3_TextHeader3}}</text>
<text class="fontsize24" id="systemId3_TextHeader4" style="top: 135;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId3_TextHeader4}}</text>
<!-- <text class="fontsize24" id="systemId3_TextHeader5" style="top: 180;color: rgb(0, 0, 0);text-align: left;width: 200;">{{crtsystemId3_TextHeader5}}</text> -->
</div>
<div style="left:150;top: 75;width: 240;height: 366;">
<text class="fontsize24" id="systemId3_TextValue1" style="top: 0;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId3_TextValue1}}</text>
<text class="fontsize24" id="systemId3_TextValue2" style=" top: 45;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId3_TextValue2}}</text>
<text class="fontsize24" id="systemId3_TextValue3" style="top: 90;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId3_TextValue3}}</text>
<text class="fontsize24" id="systemId3_TextValue4" style="top: 135;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId3_TextValue4}}</text>
<!-- <text class="fontsize24" id="systemId3_TextValue5" style="top: 180;color: rgb(0, 0, 0);text-align: center;width: 240;height:45;">{{crtsystemId3_TextValue5}}</text> -->
</div>
<text class="fontsize24" id="systemId3_TextTips" style="top: 300;color: rgb(0, 0, 0);text-align: center;width: 440;height:80;">{{crtsystemId3_crtTextTips}}</text>
</div>
<div style="left:5;top: 366;width: 480;height: 96; background-color: transparent;">
<div style="left:0 ; width: 150;height: 96;background-color: #858282;">
<text class="testReturn" id="id_back" onpress="touchedScreen" onclick="touchedBackButton" style="color: #000000; top: 15;width: 150;">back</text>
</div>
<div id="id_Back" style=" left:160 ;top: 0; width: 150;height: 96;background-color: #FF9700;">
<text class="testReturn" onpress="touchedScreen" onclick="touchedBackPageButton" style="color: #000000;top: 15;left: 0; width: 150;">上一页</text>
</div>
<div id="id_Next" style=" left:320 ;top: 0; width: 150;height: 96;background-color: #FF9700;">
<text class="testReturn" onpress="touchedScreen" onclick="touchedNextPageButton" style="color: #000000;top: 15;left: 0;width: 150; ">下一页</text>
</div>
<div id="id_hide" style=" left:-480 ;top: 0; width: 150;height: 96;background-color: #FF9700;">
</div>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var systemCtrl = require("systemCtrl.js");
var factory_testSystemInfo = require("factory_testSystemInfo.js");
export default {
data: {
crtsystemId1_title_TEXT: "系统信息(1)",
crtsystemId1_TextHeader1: "SN码:",
crtsystemId1_TextHeader2: "固件版本号:",
crtsystemId1_TextHeader3: "硬件版本号:",
crtsystemId1_TextHeader4: "DSP固件版本:",
crtsystemId1_TextHeader5: "DSP算法版本:",
crtsystemId1_TextValue1: "NG",
crtsystemId1_TextValue2: "NG",
crtsystemId1_TextValue3: "NG",
crtsystemId1_TextValue4: "NG",
crtsystemId1_TextValue5: "NG",
crtsystemId2_title_TEXT: "系统信息(2)",
crtsystemId2_TextHeader1: "WiFi MAC:",
crtsystemId2_TextHeader2: "蓝牙MAC:",
crtsystemId2_TextHeader3: "语音license:",
crtsystemId2_TextHeader4: "CPU温度:",
crtsystemId2_TextHeader5: "存储空间:",
crtsystemId2_TextValue1: "NG",
crtsystemId2_TextValue2: "NG",
crtsystemId2_TextValue3: "NG",
crtsystemId2_TextValue4: "NG",
crtsystemId2_TextValue5: "NG",
crtsystemId3_title_TEXT: "系统信息(3)",
crtsystemId3_TextHeader1: "产测版本:",
crtsystemId3_TextHeader2: "屏模组信息:",
crtsystemId3_TextHeader3: "CPU频率:",
crtsystemId3_TextHeader4: "IP地址:",
crtsystemId3_TextHeader5: "IP地址:",
crtsystemId3_TextValue1: "NG",
crtsystemId3_TextValue2: "NG",
crtsystemId3_TextValue3: "NG",
crtsystemId3_TextValue4: "NG",
crtsystemId3_TextValue5: "NG",
crtsystemId1_crtTextTips: "绿/黄色代表通过,红色代表不通过(黄色表示系统做过0TA升级)",
crtsystemId2_crtTextTips: "绿/黄色代表通过,红色代表不通过(黄色表示系统做过0TA升级)",
crtsystemId3_crtTextTips: "该页信息不作判定",
pagecnt: 1
},
onInit() {
},
onShow: function () {
for(var i = 1; i <= 3; i++){
for(var j = 1; j <= 5; j++){
this.$setOpacity("systemId" + i + "_TextHeader" + j, 0.5)
}
this.$setOpacity("systemId" + i + "_TextTips", 0.5)
}
this.$setOpacity("id_hide", 0.5)
this.pageHide();
factory_testSystemInfo.startSystemInfoTimer(this);
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
clearTimer: function () {
factory_testSystemInfo.stopSystemInfoTimer();
// this.$clearTimeout(this.testTimer);
},
touchedBackPageButton: function (node, topNode, x, y) {
switch (this.pagecnt) {
case 2:
this.movePage("systemId2", "systemId1");
this.pagecnt = 1;
break;
case 3:
this.movePage("systemId3", "systemId2");
this.pagecnt = 2;
break;
default:
break;
}
this.pageHide();
},
touchedNextPageButton: function (node, topNode, x, y) {
switch (this.pagecnt) {
case 1:
this.movePage("systemId1", "systemId2");
this.pagecnt = 2;
break;
case 2:
this.movePage("systemId2", "systemId3");
this.pagecnt = 3;
break;
default:
break;
}
this.pageHide();
},
touchedNGButton: function (node, topNode, x, y) {
globalThis.factoryTest.systemCheck = 2;
router.push({
path: "factory_testList",
});
},
touchedBackButton: function (node, topNode, x, y) {
this.movePage("systemId"+this.pagecnt, "systemId1");
this.pagecnt = 1;
router.push({
path: "factory_testList",
});
},
hideNextPageButton: function () {
this.$show("id_hide");
this.$setX("id_hide", 320); // hide
},
hideBackPageButton: function () {
this.$show("id_hide");
this.$setX("id_hide", 160); // hide
},
pageHide: function () {
switch (this.pagecnt) {
case 1:
this.hideBackPageButton();
break;
case 3:
this.hideNextPageButton();
break;
default:
this.$hide("id_hide");
this.$setX("id_hide", -480);
break;
}
},
movePage: function (oldPage, newPage) {
console.log(oldPage + "==========to==========" + newPage);
this.$hide(oldPage); // 跳转页面之前立即关掉toast
this.$setY(oldPage, -480); // hide
this.$show(newPage)
this.$setY(newPage, 10); // show
},
};
</script>
<style>
.screen {
top: 0;
left: 0;
width: 480;
height: 480;
background-color: #A8A8A8;
/* color: black; */
}
.fontsize20 {
font-size: 20;
text-align: center;
text-overflow: ellipsis;
color: #ffffff;
background-color: transparent;
}
.fontsize22Left {
left: 28;
width: 240;
height: 40;
text-align: left;
text-overflow: ellipsis;
font-size: 22;
color: #FFFFFF;
background-color: transparent;
}
.fontsize40 {
text-align: center;
text-overflow: ellipsis;
font-size: 40;
color: #ffffff;
background-color: transparent;
}
.fontsize24 {
height: 35;
text-align: center;
text-overflow: ellipsis;
font-size: 24;
color: #ffffff;
background-color: transparent;
}
#id_yes {
bottom: 20px;
left: 20px;
}
#id_ng {
bottom: 20px;
right: 20px;
}
#id_back {
bottom: 20px;
right: 20px;
}
#id_scanWifiList {
bottom: 20px;
right: 20px;
}
#id_startscanWifi {
bottom: 20px;
right: 20px;
}
.testReturn {
position: absolute;
width: 100;
height: 96;
text-align: center;
text-overflow: ellipsis;
font-size: 44;
}
.oneRow {
top: 15px;
}
</style>
\ No newline at end of file
var _userdata = require("userdata.js");
var userData = _userdata.userData;
const fs = require("@system.fs");
var systemCtrl = require("systemCtrl.js");
var that;
var systemInfoTimer = null;
var systemInfo = {};
function getSystemInfo() {
return systemInfo;
}
// 统一设置颜色
const textValueKeys = [
"crtsystemId1_TextValue1",
"crtsystemId1_TextValue2",
"crtsystemId1_TextValue3",
// "crtsystemId1_TextValue4",
// "crtsystemId1_TextValue5",
"crtsystemId2_TextValue1",
// "crtsystemId2_TextValue2",
"crtsystemId2_TextValue3",
"crtsystemId2_TextValue4",
"crtsystemId2_TextValue5",
// "crtsystemId3_TextValue1",
// "crtsystemId3_TextValue2",
// "crtsystemId3_TextValue3",
// "crtsystemId3_TextValue4",
// "crtsystemId3_TextValue5"
];
function setTextColorByValue(that, fullKey, value) {
const color = (value === "NG") ? "#ff0000" : "#00ff00";
const key = fullKey.replace(/^crt/, ""); // 去掉前缀 "crt"
that.$setTextColor(key, color);
}
// 获取系统信息
function updateSystemInfo() {
// var total = getTotalStorageInfo();
// total.totalSizeMB
// total.totalAvailableMB
systemInfo.softwareVersion = userData.softwareVersion;
systemInfo.hardwareVersion = userData.hardwareVersion;
systemInfo.factorywareVersion = userData.factorywareVersion;
systemInfo.cpuTemperature = getCPUTemperature();
systemInfo.cpuFrequency = getCPUFrequency();
systemInfo.storageInfo = getTotalStorageInfo();
systemInfo.wifiMac = getWifiInfo("address");
systemInfo.sn = userData.aboutSNValue || "NG";
systemInfo.tpVersion = "V5A"; // 示例值
systemInfo.screenVendor = getScreenVendor(); // 需根据实际实现
systemInfo.wifiModel = "AP62212"; // 示例值
systemInfo.licenseRegistered = (checkLicense() == 1 ? "Pass" : "NG"); // 需根据实际实现
systemInfo.wifiIp = getWifiInfo("ip_address"); //前提wifi要连接
// that.crtsystemId1_TextHeader1: "SN码:",
// that.crtsystemId1_TextHeader2: "固件版本号:",
// that.crtsystemId1_TextHeader3: "硬件版本号:",
// that.crtsystemId1_TextHeader4: "DSP固件版本:",
// that.crtsystemId1_TextHeader5: "DSP算法版本:",
that.crtsystemId1_TextValue1 = systemInfo.sn;
that.crtsystemId1_TextValue2 = systemInfo.softwareVersion;
that.crtsystemId1_TextValue3 = systemInfo.hardwareVersion;
// that.crtsystemId1_TextValue4: "NG",
// that.crtsystemId1_TextValue5: "NG",
// that.crtsystemId2_TextHeader1: "WiFi MAC:",
// that.crtsystemId2_TextHeader2: "蓝牙MAC:",
// that.crtsystemId2_TextHeader3: "语音license:",
// that.crtsystemId2_TextHeader4: "CPU温度:",
// that.crtsystemId2_TextHeader5: "存储空间:",
that.crtsystemId2_TextValue1 = systemInfo.wifiMac;
// that.crtsystemId2_TextValue2: "NG",
that.crtsystemId2_TextValue3 = systemInfo.licenseRegistered;
that.crtsystemId2_TextValue4 = (systemInfo.cpuTemperature != "NG") ? systemInfo.cpuTemperature + "" : systemInfo.cpuTemperature;
that.crtsystemId2_TextValue5 =(systemInfo.storageInfo.totalAvailableMB != "NG" && systemInfo.storageInfo.totalSizeMB != "NG") ? systemInfo.storageInfo.totalAvailableMB + "MB" + "/" + systemInfo.storageInfo.totalSizeMB + "MB" : "NG";
// that.crtsystemId3_TextHeader1: "产测版本:",
// that.crtsystemId3_TextHeader2: "屏模组信息:",
// that.crtsystemId3_TextHeader3: "CPU频率:",
// that.crtsystemId3_TextHeader4: "IP地址:",
// that.crtsystemId3_TextHeader5: "IP地址:",
that.crtsystemId3_TextValue1 = systemInfo.factorywareVersion;
that.crtsystemId3_TextValue2 = systemInfo.screenVendor;
that.crtsystemId3_TextValue3 = (systemInfo.cpuFrequency != "NG") ? systemInfo.cpuFrequency +"MHz" : systemInfo.cpuFrequency;
that.crtsystemId3_TextValue4 = systemInfo.wifiIp;
// that.crtsystemId3_TextValue5: "NG",
textValueKeys.forEach(key => {
const value = that[key];
if (value !== undefined) {
setTextColorByValue(that, key, value);
}
});
console.log(`
系统信息已更新:
固件版本: ${systemInfo.softwareVersion}
硬件版本: ${systemInfo.hardwareVersion}
产测版本: ${systemInfo.factorywareVersion}
CPU温度: ${systemInfo.cpuTemperature}
CPU频率: ${systemInfo.cpuFrequency} MHz
存储总容量: ${systemInfo.storageInfo.totalSizeMB} MB
存储剩余空间: ${systemInfo.storageInfo.totalAvailableMB} MB
WiFi MAC地址: ${systemInfo.wifiMac}
SN序列号: ${systemInfo.sn}
TP固件版本: ${systemInfo.tpVersion}
屏厂家名: ${systemInfo.screenVendor}
WiFi型号: ${systemInfo.wifiModel}
License注册状态: ${systemInfo.licenseRegistered}
`);
}
// 启动定时器
function startSystemInfoTimer(obj) {
that = obj;
if (systemInfoTimer != null) {
clearInterval(systemInfoTimer);
}
systemInfoTimer = setInterval(() => {
updateSystemInfo();
}, 500);
console.log("系统信息定时器已启动(500ms)");
}
// 停止定时器
function stopSystemInfoTimer() {
if (systemInfoTimer) {
clearInterval(systemInfoTimer);
systemInfoTimer = null;
console.log("系统信息定时器已停止");
} else {
console.log("定时器未启动");
}
}
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 + "="
systemCtrl.executeSystemCommand("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 "NG";
}
function getTotalStorageInfo() {
// 执行 df 命令获取所有挂载点的存储信息
systemCtrl.executeSystemCommand("df -h > /tmp/storage_status.txt");
const storageContent = fs.read("/tmp/storage_status.txt", "r");
let totalSizeMB = 0;
let totalAvailableMB = 0;
// 定义需要统计的真实 Flash 挂载点
const validMountPoints = [
"/",
"/dev",
// "/tmp",
"/mnt/userdataA",
"/mnt/userdataB",
"/mnt/advconfigA",
"/mnt/advconfigB",
"/mnt/app",
"/etc/resolv.conf",
"/tmp/private",
"/mnt/UDISK",
"/mnt/extsd"
];
if (storageContent) {
const lines = storageContent.split('\n');
for (let i = 1; i < lines.length; i++) { // 跳过表头
const line = lines[i].trim();
if (line === "") continue;
const parts = line.split(/\s+/);
if (parts.length < 6) continue;
const mountPoint = parts[5];
// 只统计真实 Flash 挂载点
if (!validMountPoints.includes(mountPoint)) continue;
const size = parts[1];
const available = parts[3];
// 转换为 MB 并累加
totalSizeMB += convertToMB(size);
totalAvailableMB += convertToMB(available);
}
// console.log(`总容量: ${totalSizeMB.toFixed(2)} MB`);
// console.log(`总剩余空间: ${totalAvailableMB.toFixed(2)} MB`);
return {
totalSizeMB: totalSizeMB.toFixed(2),
totalAvailableMB: totalAvailableMB.toFixed(2)
};
} else {
// console.log("无法读取存储信息");
return {
totalSizeMB: "NG",
totalAvailableMB: "NG"
};
}
}
// 辅助函数:将 df 命令的输出单位转换为 MB
function convertToMB(value) {
const unit = value.slice(-1); // 获取单位(如 G、M、K)
const number = parseFloat(value.slice(0, -1)); // 获取数字部分
switch (unit) {
case 'G':
return number * 1024;
case 'M':
return number;
case 'K':
return number / 1024;
default:
return 0;
}
}
function getCPUTemperature() {
systemCtrl.executeSystemCommand("cat /sys/class/thermal/thermal_zone0/temp > /tmp/cpu_temp.txt");
const tempStr = fs.read("/tmp/cpu_temp.txt", "r");
if (tempStr) {
const tempC = parseInt(tempStr.trim()) / 1000;
// console.log(`CPU温度: ${tempC.toFixed(2)} ℃`);
return tempC.toFixed(2);
} else {
// console.log("无法读取CPU温度");
return "NG";
}
}
function getCPUFrequency() {
systemCtrl.executeSystemCommand("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq > /tmp/cpu_freq.txt");
const freqStr = fs.read("/tmp/cpu_freq.txt", "r");
if (freqStr) {
const freqMHz = parseInt(freqStr.trim()) / 1000;
// console.log(`CPU频率: ${freqMHz.toFixed(0)} MHz`);
return freqMHz.toFixed(0);
} else {
// console.log("无法读取CPU频率");
return "NG";
}
}
function getScreenVendor() {
// 示例:读取某个 I2C 设备寄存器或配置文件
// 这里仅返回示例值
return "未知屏厂家";
}
// 检查 License 是否注册(示例函数,需根据实际授权机制实现)
function checkLicense() {
const fs = require("@system.fs")
var filenm = "operation_license"
var partFilePath = "../../../../../mnt/extsd/msdkFiles/" + filenm
if (fs.exists(partFilePath)) {
console.log("the " + filenm + " is exists.")
return 1;
// return "已注册!";
}
return 0;
// return "未注册"; // 或 "已注册"
}
module.exports = {
getTotalStorageInfo: getTotalStorageInfo,
getWifiInfo: getWifiInfo,
getCPUTemperature: getCPUTemperature,
getCPUFrequency: getCPUFrequency,
startSystemInfoTimer: startSystemInfoTimer,
stopSystemInfoTimer: stopSystemInfoTimer,
getSystemInfo: getSystemInfo,
}
\ No newline at end of file
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