Commit d9f0ef4a authored by waterword's avatar waterword

init

parent 2455b2b9
Pipeline #787 failed with stages
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
""
]
}
],
"version": 4
}
\ No newline at end of file
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "d:/work/temp/re832_final/quicknode/tests/RE832test",
"program": "d:/work/temp/re832_final/quicknode/tests/RE832test/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
\ No newline at end of file
// globalThis.cslog = console.log
// console.log = function () {
// }
// console.trace = function () {
// }
function initEventLister() {
var EventEmitter = require('@system.events');
globalThis.eventEmitter = new EventEmitter();
}
function onCreate(uri) {
globalThis.Simu = {
"En": 0,
}
globalThis.test = {
"En": 0,
}
var process = require("@system.process")
if (process.platform == "win32") {
console.log("its win32.")
globalThis.Simu.En = 1
}
globalThis.DEV = {
"tpLog": 1,
}
initEventLister();
gc();
console.log(showMemInfo());
var evue = require("router.js");
var router = evue.router;
var times = [];
var dom = require("dom.js"); //要放在router后面,router会创建document
if (startUrl() == undefined) {
times.push(clock());
gc();
console.log(showMemInfo());
router.push({ 'path': uri });
times.push(clock());
console.log(times)
gc();
console.log(showMemInfo());
} else {
times.push(clock());
var uriObj = JSON.parse(globalThat.$uri);
console.log(uriObj);
router.push(uriObj);
times.push(clock());
console.log(times)
gc();
console.log(showMemInfo());
}
}
// function onKeyEvent(code) {
// var router = require("@system.router");
// var keypad = require("keypadCode.js")
// keypad.triggerByCode(code)
// console.log("++++ CodeNum:" + code)
// return
// if (code == 62) {
// router.pageDebug(!router.debugOn);
// }
// }
function onDestroy() {
// 应用退出时会被触发
var router = require("@system.router");
router.quit();
}
function onGestureEvent(dir, x, y) {
var router = require("@system.router");
var indexObj = router.currentPage.$indexObj;
if (indexObj.hasOwnProperty('onGestureEvent')) {
indexObj.onGestureEvent(dir, x, y);
}
}
function onMoveEvent(globalX, globalY, topObj, x, y) {
if (this.currentPage) {
var indexObj = this.currentPage.$indexObj;
if (indexObj && (indexObj.hasOwnProperty('onmousemove') ||
indexObj.hasOwnProperty('touchmove'))) {
if (indexObj.$onmousemove == undefined) {
if (indexObj.hasOwnProperty('onmousemove')) {
indexObj.$onmousemove = indexObj.onmousemove;
} else if (indexObj.hasOwnProperty('touchmove')) {
indexObj.$onmousemove = indexObj.touchmove;
}
}
if (typeof indexObj.$onmousemove == "function") {
var node = __getElementByObj(indexObj, topObj)
if (node) {
if (indexObj.$onmousemove.length == 1) {
var e = router.toH5Event(node, node, x, y);
indexObj.$onmousemove(e);
return;
}
}
indexObj.$onmousemove(globalX, globalY, topObj, x, y);
}
}
}
}
EvueApp({
// "font": "MideaType-Regular.ttf",
"font": "SimHei_GB2312_80_t.ttf",
// "font": "Metropolis-Medium.ttf",
'onCreate': onCreate,
'onDestroy': onDestroy,
'onMoveEvent': onMoveEvent,
'onGestureEvent': onGestureEvent,
'paths': ["../RD190/","../../enode_modules/","./../RE860A/logicJS/","./../RE860A/common/","./../RE860A/common/","./../re860a-v1.0/logicJS/","./../re860a-v1.0/common/","./factoryTest_plugin/", "./factoryTest_plugin/ref/", "./factoryTestItem/"],
'uri': 'factory_testList',
// 'uri': 'testLongTimeList',
'minFreeJSHeapSize': 200
});
File added
file_path="/tmp/product.json"
timeout=10
start_time=$(date +%s)
while [ $(($(date +%s) - start_time)) -lt $timeout ]; do
if [ -f "$file_path" ]; then
killall -9 main.sh
killall -9 watch
killall -9 boot_app
killall -9 pile
killall -9 quicknode
/usr/app/quicknode/tests/867factory_test/run.sh &
exit 0
fi
sleep 1
done
echo "no file exit product test"
exit 1
\ No newline at end of file
<html>
<div class="screen" onclick="touchedScreen">
<div id="id_color"></div>
<!-- <text id="reminderText">123456789123456789123456789</text> -->
<image style="left:0;top:0" id="id_testPng" :src="gifIconSrc">{{gifIconSrc}}</image>
<!-- <text class="class_msg" id="id_yes" onclick="touchedOk">yes</text>
<text class="class_msg" id="id_ng" onclick="touchedNg">no</text> -->
<text class="testReturn" id="id_yes" onpress="touchedScreen" onclick="touchedYesButton"
style="top: 300;left:364;color: #000000;background-color: #FF9700;">PASS</text>
<text class="testReturn" id="id_ng" onpress="touchedScreen" onclick="touchedNGButton"
style="top: 300;left:14 ;color: #F44236;background-color: #858282;">NG</text>
<text class="testReturn" id="id_back" onpress="touchedScreen" onclick="touchedBackButton"
style="top: 300;left:189;color: #000000;background-color: #858282;">back</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
export default {
data: {
colorBash: [
{
"val": 0xffffff,//纯白
"text": "纯白:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "纯红:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "纯绿:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "纯蓝:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "纯黑:#000000",//纯黑
},
],
colorBashPng: [
{
"val": "./images/factory/factoryGradientColor.png",
"text": "渐变:png1",
},
{
"val": "./images/factory/factoryWhileToBlack.png",
"text": "渐变:png2",//纯黑
},
],
imgCnt: 0,
pngCnt: 0,
gifIconSrc: "",
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.$hide("id_testPng")
this.$hide("id_yes")
this.$hide("id_ng")
this.$hide("id_back")
this.timerSet()
this.imgCnt = 0
this.pngCnt = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer()
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer()
},
/*************** timer ***************/
timerSet: function () {
// this.timerColor = this.$setInterval(this.normalTimerOut, 1000, [], this);
},
normalTimerOut: function () {
},
clearTimer: function () {
},
/*************** connect ***************/
/*************** event ***************/
shortDelay: function () {
this.$setX("id_ng", 800);
this.$setY("id_ng", 340);
console.log("=====show id_ng successful!")
this.$clearTimeout(this.shortDelayId);
},
touchedScreen: function (node, topNode, x, y) {
if (this.imgCnt < this.colorBash.length) {
this.checkFlagBash(this.imgCnt)
this.imgCnt++
} else {
if (this.pngCnt < this.colorBashPng.length) {
this.checkFlagBash2(this.pngCnt)
this.pngCnt++
if (this.pngCnt == this.colorBashPng.length) {
console.log("=====show id_yes successful!")
this.$show("id_yes")
this.$show("id_ng")
this.$show("id_back")
}
}
}
},
touchedYesButton: function (node, topNode, x, y) {
globalThis.factoryTest.color = 1
router.push({
path: "factory_testList"
});
},
touchedNGButton: function (node, topNode, x, y) {
globalThis.factoryTest.color = 2
router.push({
path: "factory_testList"
});
},
touchedBackButton: function (node, topNode, x, y) {
router.push({
path: "factory_testList"
});
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
console.log("tempType = " + typeof temp)
console.log("tempValue = " + temp)
this.$setBackgroundColor("id_color", temp)
},
checkFlagBash2: function (val) {
var temp = this.colorBashPng[val].val
console.log("tempValue = " + temp)
this.gifIconSrc = temp;
this.$show("id_testPng")
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 1280;
height: 1280;
background-color: gray;
}
/*********************************/
#id_color {
width: 1280;
height: 1280;
background-color: black;
}
#reminderText {
top: 40;
width: 500;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: left;
/* text-overflow: ellipsis; */
font-size: 60;
color: white;
background-color: transparent;
}
.class_msg {
top: 240;
width: 200;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
#id_yes {
bottom: 20px;
left: 20px;
}
#id_ng {
bottom: 20px;
right: 20px;
}
#id_back {
bottom: 20px;
right: 20px;
}
.testReturn {
position: absolute;
width: 96;
height: 64;
text-align: center;
text-overflow: ellipsis;
font-size: 44;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onpress="touchedScreen" onrelease="releasedScreen" onclick="touchedReturn">
<template for="appItem" key="app" index="index">
<div class="testBlock" id="app.id"></div>
</template>
<div id="id_pointDiv" style="top:0;left:0;width: 480;height: 480;background-color: transparent;"></div>
<text class="testReturn" id="id_yes" onpress="touchedScreen" onclick="touchedYesButton"
style="top: -480;left:256 ;color: #000000;background-color: #FF9700;">PASS</text>
<text class="testReturn" id="id_ng" onpress="touchedScreen" onclick="touchedNGButton"
style="top: 256;left:32 ;color: #F44236;background-color: #858282;">NG</text>
<text class="testReturn" id="id_back" onpress="touchedScreen" onclick="touchedBackButton"
style="top: 384;left:128 ;color: #000000;background-color: #858282;">back</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var point_div = undefined;
var point_div_list = undefined;
export default {
data: {
flagBash: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
flagBashStd: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
appItem: [
{ id: "id_block0_0" }, { id: "id_block0_1" }, { id: "id_block0_2" }, { id: "id_block0_3" }, { id: "id_block0_4" },
{ id: "id_block0_5" }, { id: "id_block0_6" }, { id: "id_block0_7" }, { id: "id_block0_8" }, { id: "id_block0_9" },
{ id: "id_block0_10" }, { id: "id_block0_11" }, { id: "id_block0_12" }, { id: "id_block0_13" }, { id: "id_block0_14" },
{ id: "id_block1_0" }, { id: "id_block1_1" }, { id: "id_block1_2" }, { id: "id_block1_3" }, { id: "id_block1_4" },
{ id: "id_block1_5" }, { id: "id_block1_6" }, { id: "id_block1_7" }, { id: "id_block1_8" }, { id: "id_block1_9" },
{ id: "id_block1_10" }, { id: "id_block1_11" }, { id: "id_block1_12" }, { id: "id_block1_13" }, { id: "id_block1_14" },
{ id: "id_block2_0" }, { id: "id_block2_1" }, { id: "id_block2_2" }, { id: "id_block2_3" }, { id: "id_block2_4" },
{ id: "id_block2_5" }, { id: "id_block2_6" }, { id: "id_block2_7" }, { id: "id_block2_8" }, { id: "id_block2_9" },
{ id: "id_block2_10" }, { id: "id_block2_11" }, { id: "id_block2_12" }, { id: "id_block2_13" }, { id: "id_block2_14" },
{ id: "id_block3_0" }, { id: "id_block3_1" }, { id: "id_block3_2" }, { id: "id_block3_3" }, { id: "id_block3_4" },
{ id: "id_block3_5" }, { id: "id_block3_6" }, { id: "id_block3_7" }, { id: "id_block3_8" }, { id: "id_block3_9" },
{ id: "id_block3_10" }, { id: "id_block3_11" }, { id: "id_block3_12" }, { id: "id_block3_13" }, { id: "id_block3_14" },
{ id: "id_block4_0" }, { id: "id_block4_1" }, { id: "id_block4_2" }, { id: "id_block4_3" }, { id: "id_block4_4" },
{ id: "id_block4_5" }, { id: "id_block4_6" }, { id: "id_block4_7" }, { id: "id_block4_8" }, { id: "id_block4_9" },
{ id: "id_block4_10" }, { id: "id_block4_11" }, { id: "id_block4_12" }, { id: "id_block4_13" }, { id: "id_block4_14" },
{ id: "id_block5_0" }, { id: "id_block5_1" }, { id: "id_block5_2" }, { id: "id_block5_3" }, { id: "id_block5_4" },
{ id: "id_block5_5" }, { id: "id_block5_6" }, { id: "id_block5_7" }, { id: "id_block5_8" }, { id: "id_block5_9" },
{ id: "id_block5_10" }, { id: "id_block5_11" }, { id: "id_block5_12" }, { id: "id_block5_13" }, { id: "id_block5_14" },
{ id: "id_block6_0" }, { id: "id_block6_1" }, { id: "id_block6_2" }, { id: "id_block6_3" }, { id: "id_block6_4" },
{ id: "id_block6_5" }, { id: "id_block6_6" }, { id: "id_block6_7" }, { id: "id_block6_8" }, { id: "id_block6_9" },
{ id: "id_block6_10" }, { id: "id_block6_11" }, { id: "id_block6_12" }, { id: "id_block6_13" }, { id: "id_block6_14" },
{ id: "id_block7_0" }, { id: "id_block7_1" }, { id: "id_block7_2" }, { id: "id_block7_3" }, { id: "id_block7_4" },
{ id: "id_block7_5" }, { id: "id_block7_6" }, { id: "id_block7_7" }, { id: "id_block7_8" }, { id: "id_block7_9" },
{ id: "id_block7_10" }, { id: "id_block7_11" }, { id: "id_block7_12" }, { id: "id_block7_13" }, { id: "id_block7_14" },
{ id: "id_block8_0" }, { id: "id_block8_1" }, { id: "id_block8_2" }, { id: "id_block8_3" }, { id: "id_block8_4" },
{ id: "id_block8_5" }, { id: "id_block8_6" }, { id: "id_block8_7" }, { id: "id_block8_8" }, { id: "id_block8_9" },
{ id: "id_block8_10" }, { id: "id_block8_11" }, { id: "id_block8_12" }, { id: "id_block8_13" }, { id: "id_block8_14" },
{ id: "id_block9_0" }, { id: "id_block9_1" }, { id: "id_block9_2" }, { id: "id_block9_3" }, { id: "id_block9_4" },
{ id: "id_block9_5" }, { id: "id_block9_6" }, { id: "id_block9_7" }, { id: "id_block9_8" }, { id: "id_block9_9" },
{ id: "id_block9_10" }, { id: "id_block9_11" }, { id: "id_block9_12" }, { id: "id_block9_13" }, { id: "id_block9_14" },
{ id: "id_block10_0" }, { id: "id_block10_1" }, { id: "id_block10_2" }, { id: "id_block10_3" }, { id: "id_block10_4" },
{ id: "id_block10_5" }, { id: "id_block10_6" }, { id: "id_block10_7" }, { id: "id_block10_8" }, { id: "id_block10_9" },
{ id: "id_block10_10" }, { id: "id_block10_11" }, { id: "id_block10_12" }, { id: "id_block10_13" }, { id: "id_block10_14" },
{ id: "id_block11_0" }, { id: "id_block11_1" }, { id: "id_block11_2" }, { id: "id_block11_3" }, { id: "id_block11_4" },
{ id: "id_block11_5" }, { id: "id_block11_6" }, { id: "id_block11_7" }, { id: "id_block11_8" }, { id: "id_block11_9" },
{ id: "id_block11_10" }, { id: "id_block11_11" }, { id: "id_block11_12" }, { id: "id_block11_13" }, { id: "id_block11_14" },
{ id: "id_block12_0" }, { id: "id_block12_1" }, { id: "id_block12_2" }, { id: "id_block12_3" }, { id: "id_block12_4" },
{ id: "id_block12_5" }, { id: "id_block12_6" }, { id: "id_block12_7" }, { id: "id_block12_8" }, { id: "id_block12_9" },
{ id: "id_block12_10" }, { id: "id_block12_11" }, { id: "id_block12_12" }, { id: "id_block12_13" }, { id: "id_block12_14" },
{ id: "id_block13_0" }, { id: "id_block13_1" }, { id: "id_block13_2" }, { id: "id_block13_3" }, { id: "id_block13_4" },
{ id: "id_block13_5" }, { id: "id_block13_6" }, { id: "id_block13_7" }, { id: "id_block13_8" }, { id: "id_block13_9" },
{ id: "id_block13_10" }, { id: "id_block13_11" }, { id: "id_block13_12" }, { id: "id_block13_13" }, { id: "id_block13_14" },
{ id: "id_block14_0" }, { id: "id_block14_1" }, { id: "id_block14_2" }, { id: "id_block14_3" }, { id: "id_block14_4" },
{ id: "id_block14_5" }, { id: "id_block14_6" }, { id: "id_block14_7" }, { id: "id_block14_8" }, { id: "id_block14_9" },
{ id: "id_block14_10" }, { id: "id_block14_11" }, { id: "id_block14_12" }, { id: "id_block14_13" }, { id: "id_block14_14" }
],
},
resetArrays: function (flagBash, flagBashStd) {
flagBash = Array.from({ length: 15 }, () => Array(15).fill(0));
flagBashStd = Array.from({ length: 15 }, () => Array(15).fill(0));
},
notRender: function () {
for (x = 0; x < 15; x++) {
for (y = 0; y < 15; y++) {
var relId = "id_block" + x + "_" + y;
console.log("relId :" + relId);
this.$setBackgroundColor(relId, 0xFFFFFF)
}
}
},
dataInit: function () {
if (globalThis.factoryTest.touch == 0) {
this.$setY("id_yes", -480);
// this.resetArrays();
// if (point_div_list) {
// point_div.removeChild(point_div_list)
// }
// this.notRender();
// this.$setY("id_ng", -480);
// this.$setY("id_back", -480);
}
},
// var dom = require("dom.js"); app.js引入
pointInit: function () {
var getPointTopDiv = document.getElementById('id_pointDiv');
console.log("getPointTopDiv:" + getPointTopDiv);
if (!getPointTopDiv)
return
if (!point_div) {
point_div = document.createElement('div', {
top: 0,
left: 0,
width: 480,
height: 480,
}, getPointTopDiv)
}
if (point_div_list) {
//point_div.removeChild(point_div_list)
return;
}
point_div_list = document.createElement('div', {
top: 0,
left: 0,
width: 480,
height: 480,
}, point_div)
},
drawPointEvent: function (x, y) {
document.createElement('div', {
top: y,
left: x,
width: 4,
height: 4,
"background-color": "#ff0000",
}, point_div_list)
},
onInit: function () {
},
onShow: function () {
console.log(this.$uri + "===========onShow=============");
this.timerSet();
this.dataInit();
this.pointInit();
// this.$enableMouseMoveEvent(true);
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.testTimer = this.$setTimeout(this.resetDivPos, 10, [], this);
},
clearTimer: function () {
this.$clearTimeout(this.testTimer);
},
initDiv: function (x, y) {
var relId = "id_block" + x + "_" + y;
console.log("relId :" + relId);
this.$setPos(relId, x * 32, y * 32);
// if (this.flagBashStd[x][y] == 1) {
// this.$setBackgroundColor(relId, 0x000000);
// }
},
chanelDiv: function (x, y) {
var relId = "id_block" + x + "_" + y;
console.log("relId :" + relId);
this.$setPos(relId, -480, -480);
this.$setBackgroundColor(relId, 0x000000)
this.flagBashStd[x][y] = 1;
this.flagBash[x][y] = 1;
},
resetDivPos: function () {
var x = 0;
var y = 0;
var divheight = 32;
var divwidth = 32;
var xmax = 480 / divwidth;
var ymax = 480 / divheight;
console.log("xmax :" + xmax + "ymax :" + ymax);
for (x = 0; x < xmax; x++) {
for (y = 0; y < ymax; y++) {
if (x == 0 || y == 0 || x == 14 || y == 14 ||
x == ymax - 1 - y || x == ymax - 1 - x ||
y == xmax - 1 - y || y == x) {
this.initDiv(x, y)
}
else {
this.chanelDiv(x, y)
}
// var relId = "id_block" + x +"_"+ y;
// console.log("relId :" + relId);
// this.$setPos(relId, x * 32, y * 32);
// if (this.flagBashStd[x][y] == 1) {
// this.$setBackgroundColor(relId, 0x000000);
// }
}
}
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
figCoor: function (x, y) {
var divwidth = 32;
var divheight = 32;
var gridX = Math.floor(x / divwidth);
var gridY = Math.floor(y / divheight);
// 确保 gridX 和 gridY 在 0-14 的范围内
gridX = Math.max(0, Math.min(gridX, 14));
gridY = Math.max(0, Math.min(gridY, 14));
console.log("gridX: " + gridX + " gridY: " + gridY);
this.flagBash[gridX][gridY] = 1;
if (this.flagBashStd[gridX][gridY] == 1) {
return undefined;
}
var coor = gridX + "_" + gridY;
console.log(coor);
return coor;
},
// refDivColor: function (coor) {
// var relId = "id_block" + coor
// console.log("relId :" + relId);
// this.$setBackgroundColor(relId, 0x00ff00);
// // this.$setPos(relId, gridX * 32, gridY * 32); // 确保位置正确
// },
refDivColor: function (coor) {
var relId = "id_block" + coor;
console.log("refDivColor - relId: " + relId);
if (document.getElementById(relId)) {
console.log("Element found: " + relId);
this.$setBackgroundColor(relId, 0x00ff00);
} else {
console.log("Element not found: " + relId);
}
},
onmousemove: function (gx, gy, topNode, x, y) {
console.log("onmousemove--->gx:" + gx + " gy:" + gy);
if (gx > 480 || gy > 480)
return;
this.drawPointEvent(gx, gy)
var coor = this.figCoor(gx, gy);
if (coor == undefined) return;
this.refDivColor(coor);
},
/*************** work ***************/
// onmousemove: function (gx, gy, topNode, x, y) {
// var coor = this.figCoor(gx, gy);
// if (coor == undefined) return;
// this.refDivColor(coor);
// // if ((this.sliderData.y - y > 10) || (y - this.sliderData.y > 10)) {
// // this.sliderTrigger = 1
// // }
// },
touchedScreen: function (node, topNode, x, y) {
console.log("X:" + x + " Y:" + y);
this.$enableMouseMoveEvent(true);
},
releasedScreen: function (node, topNode, x, y) {
this.$enableMouseMoveEvent(false);
},
touchedReturn: function (node, topNode, x, y) {
this.checkFlagBash();
},
checkFlagBash: function () {
var x = 0;
var y = 0;
for (x = 0; x < 15; x++) {
for (y = 0; y < 15; y++) {
if (this.flagBash[x][y] == 0) return;
}
}
this.finishCondition();
},
finishCondition: function () {
this.$setY("id_yes", 384);
// this.$setY("id_ng", 256);
// this.$setY("id_back", 384);
},
touchedYesButton: function (node, topNode, x, y) {
globalThis.factoryTest.touch = 1;
router.push({
path: "factory_testList",
});
},
touchedNGButton: function (node, topNode, x, y) {
globalThis.factoryTest.touch = 2;
router.push({
path: "factory_testList",
});
},
touchedBackButton: function (node, topNode, x, y) {
router.push({
path: "factory_testList",
});
},
};
</script>
<style>
.screen {
width: 480px;
height: 480px;
top: 0px;
left: 0px;
background-color: #A4A4AC;
position: relative;
}
.testBlock {
position: absolute;
width: 32px;
height: 32px;
background-color: #ffffff;
border-width: 1px;
border-color: black;
}
.testBlock:hover {
background-color: #6FAF58;
}
.testReturn {
position: absolute;
width: 96;
height: 64;
text-align: center;
text-overflow: ellipsis;
font-size: 44;
}
#id_yes {
bottom: 20px;
left: 20px;
}
#id_ng {
bottom: 20px;
right: 20px;
}
#id_back {
bottom: 20px;
right: 20px;
}
.fullScreen {
top: 0;
left: 0;
width: 480;
height: 480;
background-color: transparent;
}
.point {
width: 2;
height: 2;
background-color: #ff0000;
}
.infoText {
width: 480;
height: 30;
top: 150;
text-align: center;
font-size: 13;
background-color: transparent;
color: greenyellow;
}
</style>
\ No newline at end of file
<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="wifiHmoe" class="screen">
<div style="left:10;top: 10;width: 460;height: 55; background-color: #99D0F7;">
<text class="fontsize40" id="title_TEXT"
style="left:0;top: 0;width: 460;height: 55;text-align: center; background-color: transparent;color: black;">{{
title_TEXT }}</text>
</div>
<div style="left:10;top: 65;width: 460;height: 55; background-color: transparent;">
<text class="fontsize20" id="Reminder_TEXT"
style="left:0;top: 0;width: 460;height: 55;text-align: center; background-color: transparent;color: black;">{{
Reminder_TEXT }}</text>
</div>
<div style="left:10;top: 130;width: 460;height: 55; background-color: #99D0F7;">
<text class="fontsize24" id="wifiInfo_TEXT"
style="left:0;top: 10;width: 460;height: 55;text-align: center; background-color: transparent;color: #357E43">{{
wifiInfo_TEXT }}</text>
</div>
<div style="left:10;top: 195;width: 460;height: 55; background-color: transparent">
<text class="fontsize24" id="wifiInfoWarn_TEXT"
style="left:0;top: 10;width: 460;height: 55;text-align: center; background-color: transparent;color: #E2E64D">{{
wifiInfoWarn_TEXT }}</text>
</div>
<div style="left:10;top: 260;width: 480;height: 96; background-color: transparent;">
<text class="fontsize24" id="wifiInfoState_TEXT"
style="left: 0;top: 36;width: 350;height: 40;text-align: center; background-color: transparent;color: #ffffff">{{
wifiInfoState_TEXT }}</text>
<div style="top:0; left:360 ; width: 100;height: 96;background-color: #FF9700;">
<text class="testReturn" id="id_startscanWifi" onpress="touchedScreen"
onclick="touchedStartScanWifiButton" style="top: 0;color: #000000;">开始扫描</text>
</div>
</div>
<div style="left:10;top: 366;width: 460;height: 96; background-color: transparent;">
<div style="left:10 ; width: 100;height: 96;background-color: #858282;">
<text class="testReturn" id="id_back" onpress="touchedScreen" onclick="touchedBackButton"
style="color: #000000; top: 15;">back</text>
</div>
<div style="left:130 ; width: 100;height: 96;background-color: #858282;">
<text class="testReturn" id="id_ng" onpress="touchedScreen" onclick="touchedNGButton"
style="color: #F44236;top: 15;">NG</text>
</div>
<div style="left:360 ; width: 100;height: 96;background-color: #FF9700;">
<text class="testReturn" id="id_yes" onpress="touchedScreen" onclick="touchedYesButton"
style="color: #000000;top: 15;left: 0; ">PASS</text>
</div>
<div style="left:250 ; width: 100;height: 96;background-color: #858282;">
<text class="testReturn" id="id_scanWifiList" onpress="touchedScreen" onclick="touchedscanWifiList"
style="color: #000000;">WIFI列表</text>
</div>
</div>
</div>
<div id="id_enableWLANChooseOnDiv" class="screen" style="top: -480;">
<div style="left:10;top: 10;width: 460;height: 35; background-color: transparent;">
<text class="fontsize24" id="title_TEXT"
style="left:0;top: 0;width: 460;height: 35;text-align: center; background-color: transparent;color: black;">{{
title_TEXT }}</text>
</div>
<list id="id_enableWLANPageList" direction="vertical" style="top:55;left:30;height:300;width: 420;">
<list-item id="id_enableWLANListItemTemplate" style="top:0;height:1100;width: 420;">
<div style="top:0;width: 420;background-color: #000000;height:1100;"
id="id_enableWLANListItemSearchDiv"></div>
</list-item>
</list>
<div style="left:10;top: 366;width: 460;height: 96; background-color: transparent;">
<div style="left:60 ; width: 150;height: 96;background-color: #858282;">
<text class="testReturn" id="id_backWifiList" onpress="touchedScreen" onclick="touchedDetailsBackButton"
style="top: 25; color: #000000; width: 150;font-size: 34;">back</text>
</div>
<div style="top:0; left:250; width: 150;height: 96;background-color: #FF9700;">
<text class="testReturn" id="id_startscanWifi_List" onpress="touchedScreen"
onclick="touchedStartScanWifiDetailsButton"
style="top: 25;color: #000000; width: 150;font-size: 34;">开始扫描</text>
</div>
</div>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
// var common = require("common");
var wifiEventJS = require("factory_testWifi.js");
var initWifissid = "Midea_WifiBT";
var initWifipwd = "";
var initWifisig = undefined;
export default {
data: {
title_TEXT: "WIFI",
Reminder_TEXT: "请配置SSID为Midea_WifiBT,密码为空的WIFI路由器,且确保路由器能连上外网",
wifiInfo_TEXT: "Midea_WifiBT",
wifiInfoWarn_TEXT: "Midea_WifiBT信号强度需要大于-38dB",
wifiInfoState_TEXT: "",
exit_TEXT: "退出",
},
onInit() {
},
InterValTime: function () {
wifiEventJS.connect_wifi(initWifissid, initWifipwd);
wifiEventJS.enableWLANSwitch();
var wifiInfo = wifiEventJS.getWifiInfo(initWifissid);
if (wifiInfo) {
this.Reminder_TEXT = "请配置SSID为" + wifiInfo.ssid + "密码为" + initWifipwd + "的WIFI路由器,且确保路由器能连上外网";
this.wifiInfo_TEXT = initWifissid + "当前信号强度:" + wifiInfo.signalLevel;
this.wifiInfoWarn_TEXT = initWifissid + "信号强度需要大于-38dB";
var connectStatus = wifiInfo.isConnected;
this.wifiInfoState_TEXT = connectStatus ? "WIFI测试成功" : "WIFI测试失败"
this.$setTextColor("wifiInfoState_TEXT", connectStatus ? "#ff0000" : "#000000");
console.log("SSID: " + wifiInfo.ssid);
console.log("Signal Level: " + wifiInfo.signalLevel + " dBm");
console.log("Is Encrypted: " + (wifiInfo.isEncrypted ? "Yes" : "No"));
console.log("Is Connected: " + (wifiInfo.isConnected ? "WIFI测试成功" : "WIFI测试失败"));
} else {
console.log("No WiFi information available.");
}
},
onShow: function () {
document.setAttribute('id_enableWLANPageList', 'list-set-edge-flash', false);
wifiEventJS.connect_wifi(initWifissid, initWifipwd);
wifiEventJS.enableWLANSwitch();
this.testTimer = this.$setTimeout(this.InterValTime, 5000, [], this);
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
clearTimer: function () {
this.$clearTimeout(this.testTimer);
},
touchedYesButton: function (node, topNode, x, y) {
globalThis.factoryTest.touch = 1;
router.push({
path: "factory_testList",
});
},
touchedNGButton: function (node, topNode, x, y) {
globalThis.factoryTest.touch = 2;
router.push({
path: "factory_testList",
});
},
touchedBackButton: function (node, topNode, x, y) {
router.push({
path: "factory_testList",
});
},
touchedscanWifiList: function (node, topNode, x, y) {
this.movePage("wifiHmoe", "id_enableWLANChooseOnDiv");
},
touchedStartScanWifiButton: function (node, topNode, x, y) {
// router.push({
// path: "factory_testList",
// });
//this.movePage("wifiHmoe", "id_enableWLANChooseOnDiv");
wifiEventJS.enableWLANSwitch();
},
touchedStartScanWifiDetailsButton: function (node, topNode, x, y) {
console.log("========touchedStartScanWifiDetailsButton=======");
wifiEventJS.enableWLANSwitch();
},
touchedDetailsBackButton: function (node, topNode, x, y) {
console.log("========touchedDetailsBackButton=======");
this.movePage("id_enableWLANChooseOnDiv", "wifiHmoe");
},
movePage: function (oldPage, newPage) {
console.log(oldPage + "==========to==========" + newPage);
this.$hide(oldPage); // 跳转页面之前立即关掉toast
this.$setY(oldPage, -480); // hide
this.$show(newPage)
this.$setY(newPage, 0); // 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;
}
.fontsize40 {
text-align: center;
text-overflow: ellipsis;
font-size: 40;
color: #ffffff;
background-color: transparent;
}
.fontsize24 {
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
<html>
<div class="screen" onclick="touchedBg">
<template for="appItem" key="app" index="index">
<div class="chooseBlock" id="app.id" :url="app.startup" :ena="app.en" :top="app.top" :left="app.left" onclick="touchedBlock">
<text class="testName" :url="app.startup" :ena="app.en">{{
app.name
}}</text>
<!-- <text class="testInfo" :url="app.startup" :ena="app.en">{{
app.info
}}</text> -->
</div>
</template>
<text class="verSNTitle">{{ crtSNTitle }}</text>
<text class="verSNValue">{{ crtSNValue }}</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var file = require("file.js");
var bglight = require("factory_bglight.js");
var systemCtrl = require("systemCtrl.js");
// var _userdata = require("userdata.js");
// var userData = _userdata.userData;
export default {
data: {
index: 0,
crtSNTitle: "SN: ",
crtSNValue: "",
appItem: [
// {
// id: "id_testColor", // id
// name: "显示屏", //show text
// info: "click to change", //废除
// startup: "testColor", //对应跳转实现函数
// top: 10,
// left: 20,
// en: 1, //
// },
{
id: "id_factoryTestColor",
name: "显示屏",
startup: "factoryTestColor",
top: 10,
left: 20,
en: 1,
},
{
id: "id_factoryTestTouch",
name: "触摸屏",
startup: "factoryTestTouch",
top: 10,
left: 130,
en: 1,
},
{
id: "id_factoryTestWifi",
name: "WIFI",
startup: "factoryTestWifi",
top: 10,
left: 240,
en: 1,
},
{
id: "id_factoryTestSound",
name: "声音",
startup: "factoryTestSound",
top: 10,
left: 350,
en: 1,
},
{
id: "id_factoryTestBle",
name: "蓝牙",
startup: "factoryTestBle",
top: 100,
left: 20,
en: 1,
},
{
id: "id_factoryTestUartComm",
name: "无极性通信",
startup: "factoryTestUartComm",
top: 100,
left: 130,
en: 1,
},
{
id: "id_factoryTestBright",
name: "亮度调节",
startup: "factoryTestBright",
top: 100,
left: 240,
en: 1,
},
{
id: "id_factoryTestLicenseAuthor",
name: "license授权",
startup: "factoryTestLicenseAuthor",
top: 100,
left: 350,
en: 0,
},
{
id: "id_factoryTestsystemCheck",
name: "系统检测",
startup: "factoryTestsystemCheck",
top: 370,
left: 20,
en: 1,
},
{
id: "id_factoryTestClearAll",
name: "一键清除",
startup: "factoryTestClearAll",
top: 370,
left: 130,
en: 1,
},
{
id: "id_factoryTestPCBA",
name: "PCBA",
startup: "factoryTestPCBA",
top: 370,
left: 240,
en: 1,
},
{
id: "id_factoryTestStart",
name: "开始测试",
startup: "factoryTestStart",
top: 370,
left: 350,
en: 1,
},
],
},
/*************** struct ***************/
onInit: function () {
this.onlyOnceFlag = 0;
if (globalThis.factoryTest == undefined) {
var obj = {
color: 0,
touch: 0,
wifi: 0,
sound: 0,
ble: 0,
uartComm: 0,
bright: 0,
licenseAuthor: 0,
systemCheck: 0,
clearAll: 0,
pcba: 0,
start: 0,
};
globalThis.factoryTest = obj;
}
this.initializeFactoryTestProperties();
},
initializeFactoryTestProperties: function () {
const properties = [
"color", "touch", "wifi", "sound", "ble",
"uartComm", "bright", "licenseAuthor",
"systemCheck", "clearAll", "pcba", "start"
];
properties.forEach(prop => {
if (globalThis.factoryTest[prop] === undefined) {
globalThis.factoryTest[prop] = 0;
}
});
},
snShow: function () {
// var sysVersion = libwifi.getSysVersion("get");
var sysVersion = "The code has been annotated"
// var appVersion = userData.softwareVersion;
var appVersion = "The code has been annotated"
console.log("sysVersion=" + sysVersion);
console.log("appVersion=" + appVersion);
this.crtSNValue = sysVersion + "-" + appVersion;
},
onShow: function () {
console.log(this.$uri + "===========onShow=============");
this.snShow();
this.timerSet();
if (this.onlyOnceFlag == 0) {
var obj = file.read("product_res.json", "json");
if (obj == undefined) {
console.log("product_res.json is not exist,creat it!");
file.create("product_res.json");
this.saveValue();
return;
}
console.log("product_res.json is exist,continue!");
this.restoreFactoryTestValues(obj);
this.onlyOnceFlag = 1;
}
console.log("save data to product_res.json!");
this.saveValue();
},
restoreFactoryTestValues: function (obj) {
const properties = [
"color", "touch", "wifi", "sound", "ble",
"uartComm", "bright", "licenseAuthor",
"systemCheck", "clearAll", "pcba", "start"
];
properties.forEach(prop => {
if (obj[prop] !== undefined) {
globalThis.factoryTest[prop] = obj[prop];
}
});
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.normalTimerOutId = this.$setTimeout(
this.normalTimerOut,
100,
[],
this
);
},
normalTimerOut: function () {
this.testStatus();
},
clearTimer: function () {
this.$clearTimeout(this.normalTimerOutId);
},
/*************** work ***************/
touchedBlock: function (node, topnode, x, y) {
console.log("X:" + x + " Y:" + y);
var url = this.$eval(topnode, ":url");
console.log("===============url:" + url + "===============");
if (url == undefined) return;
var en = parseInt(this.$eval(topnode, ":ena"));
if (en != 1) {
return;
}
router.push({
path: url,
});
},
blockColorChange: function (relId, val) {
const colors = [0x9E9E9E, 0x4CB050, 0xF44236];
this.$setBackgroundColor(relId, colors[Math.min(val, 2)]);
},
testStatus: function () {
const testMappings = [
{ index: 0, property: "color" },
{ index: 1, property: "touch" },
{ index: 2, property: "wifi" },
{ index: 3, property: "sound" },
{ index: 4, property: "ble" },
{ index: 5, property: "uartComm" },
{ index: 6, property: "bright" },
{ index: 9, property: "systemCheck" },
{ index: 10, property: "clearAll" },
{ index: 11, property: "pcba" },
{ index: 12, property: "start" },
];
testMappings.forEach(mapping => {
const appItem = this.appItem[mapping.index];
if (appItem) {
this.blockColorChange(appItem.id, globalThis.factoryTest[mapping.property]);
}
});
},
touchedBg: function (node, topnode, x, y) {
if (this.index == 0) {
this.index = 1;
}
this.index++;
if (this.index > 6) {
this.index = 1;
}
this.beepTimerOutId = this.$setTimeout(this.beepTimerOut, 500, [], this);
},
saveValue: function () {
const saveObj = {
color: globalThis.factoryTest.color,
touch: globalThis.factoryTest.touch,
wifi: globalThis.factoryTest.wifi,
sound: globalThis.factoryTest.sound,
ble: globalThis.factoryTest.ble,
uartComm: globalThis.factoryTest.uartComm,
bright: globalThis.factoryTest.bright,
licenseAuthor: globalThis.factoryTest.licenseAuthor,
systemCheck: globalThis.factoryTest.systemCheck,
clearAll: globalThis.factoryTest.clearAll,
pcba: globalThis.factoryTest.pcba,
start: globalThis.factoryTest.start,
};
console.log(saveObj);
file.write("product_res.json", saveObj);
// libwifi.syncSave("save");
},
beepTimerOut: function () {
// rd190_factory.pwm(0);
this.$clearTimeout(this.beepTimerOutId);
},
};
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 480;
height: 480;
background-color: #CCCCCC;
}
/*********************************/
.chooseBlock {
width: 100;
height: 80;
background-color: #9E9E9E;
/* border-radius: 5;
border-color: transparent; */
/* border-width: 2; */
}
.testName {
top: 25;
left: 0;
width: 100;
height: 80;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 24;
}
.testInfo {
top: 120;
left: 0;
width: 172;
height: 110;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 30;
}
.verSNTitle {
left: 20;
top: 455;
width: 480;
height: 20;
text-align: left;
text-overflow: ellipsis;
font-size: 16;
color: red;
background: transparent;
}
.verSNValue {
left: 50;
top: 455;
width: 480;
height: 20;
text-align: left;
text-overflow: ellipsis;
font-size: 16;
color: black;
background: transparent;
}
</style>
\ No newline at end of file
<html>
<!--屏幕只有一个id-->
<div class="fullScreen" id="root">
<div class="point" id="point1"></div>
<div class="point" id="point2"></div>
<div class="point" id="point3"></div>
<div class="point" id="point4"></div>
<div class="point" id="point5"></div>
<div class="point" id="point6"></div>
<div class="point" id="point7"></div>
<div class="point" id="point8"></div>
<div class="point" id="point9"></div>
<div class="point" id="point10"></div>
<div class="point" id="point11"></div>
<div class="point" id="point12"></div>
<div class="point" id="point13"></div>
<div class="point" id="point14"></div>
<div class="point" id="point15"></div>
<div class="point" id="point16"></div>
<div class="point" id="point17"></div>
<div class="point" id="point18"></div>
<div class="point" id="point19"></div>
<div class="point" id="point20"></div>
<div class="point" id="point21"></div>
<div class="point" id="point22"></div>
<div class="point" id="point23"></div>
<div class="point" id="point24"></div>
<div class="point" id="point25"></div>
<div class="point" id="point26"></div>
<div class="point" id="point27"></div>
<div class="point" id="point28"></div>
<div class="point" id="point29"></div>
<div class="point" id="point30"></div>
<text class="infoText" id="infoText">{{ crtTestInfoText }}</text>
</div>
</html>
<script>
var router = require("@system.router");
export default {
data: {
crtTestInfoText: "",
},
onInit: function () {
console.log(this.$uri + "===========onInit=============");
},
onShow: function () {
console.log(this.$uri + "===========onShow=============");
console.log(showMemInfo());
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
console.log(showMemInfo());
},
onReady: function () {
console.log(this.$uri + "===========onReady=============");
this.$enableMouseMoveEvent(true);
this.pointIndex = 1;
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
},
refPointGroup: function (x, y) {
var no = this.pointIndex;
var id = "point" + no;
this.$setPos(id, x, y);
no++;
if (no > 30) {
no = 1;
}
this.pointIndex = no;
},
onmousemove: function (gx, gy, topNode, x, y) {
console.log("onmousemove:x-" + x + " y-" + y);
this.refPointGroup(x + 0, y);
this.crtTestInfoText = "x:" + x + " y:" + y;
},
};
</script>
<style>
.fullScreen {
left: 0;
width: 720;
height: 1280;
background-color: black;
}
.point {
width: 2;
height: 2;
background-color: red;
}
.infoText {
width: 720;
height: 30;
top: 770;
text-align: center;
font-size: 13;
background-color: transparent;
color: greenyellow;
}
</style>
\ No newline at end of file
ctrl_interface=/tmp
update_config=1
network={
ssid="re867a_test"
psk="12345678"
vht=1
}
network={
ssid="re867a_test"
psk="12345678"
vht=1
}
{"color":0,"touch":0,"wifi":0,"tcard":0,"serial":0,"serialNG":0,"rtcTimes":0,"beepLT":0,"encoder":0,"rtc":0,"bgLight":0,"ble":0,"iccid":0,"imei":0}
\ No newline at end of file
<html>
<div class="screen">
<text class="functionBlock" id="id_ok" onclick="touchedOK">yes</text>
<text class="functionBlock" id="id_ng" onclick="touchedNG">no</text>
<text class="functionBlock" id="id_reset">2.731KHz 50%</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
index: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.index = 0
this.timerSet();
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
rd190_factory.pwmInit()
this.timerBeep = this.$setInterval(this.normalTimerOut, 1000, [], this);
},
normalTimerOut: function () {
this.index++
if (this.index % 2 == 0) {
rd190_factory.pwm(1)
} else {
rd190_factory.pwm(0)
}
},
clearTimer: function () {
this.$clearInterval(this.timerBeep);
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedOK: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
globalThis.factoryTest.beep = 1
this.returnResult()
},
touchedNG: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
globalThis.factoryTest.beep = 2
this.returnResult()
},
touchedReset: function (node, topnode, x, y) {
this.index = 0
},
returnResult: function () {
rd190_factory.pwm(0)
router.push({
path: "factory_testList"
});
}
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
.chooseBlock {
width: 240;
height: 160;
border-radius: 5;
border-width: 2;
border-color: white;
background-color: gainsboro;
}
.cbName {
top: 65;
width: 240;
height: 50;
color: black;
text-align: center;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
#id_cb1 {
left: 20;
top: 20;
}
#id_cb2 {
left: 280;
top: 20;
}
#id_cb3 {
left: 540;
top: 20;
}
#id_cb4 {
left: 20;
top: 200;
}
#id_cb5 {
left: 280;
top: 200;
}
#id_cb6 {
left: 540;
top: 200;
}
.functionBlock {
width: 320;
height: 100;
color: red;
border-radius: 5;
border-width: 2;
border-color: black;
background-color: gainsboro;
text-align: center;
text-overflow: ellipsis;
font-size: 45;
}
#id_ok {
left: 40;
top: 300;
}
#id_ng {
left: 440;
top: 300;
}
#id_reset {
left: 240;
top: 80;
}
</style>
\ No newline at end of file
<html>
<div class="screen">
<text id="id_time">{{textTimer}}</text>
<text class="functionBlock" id="id_ok" onclick="touchedOK">yes</text>
<text class="functionBlock" id="id_ng" onclick="touchedNG">no</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
// var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
index: 0,
textTimer: "00:00:00",
crtSec: 0,
crtMinu: 0,
crtHour: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.index = 0
this.timerSet();
this.crtSec = 0
this.crtMinu = 0
this.crtHour = 0
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.timerBeep = this.$setInterval(this.normalTimerOut, 1000, [], this);
// rd190_factory.pwmInit()
},
refTime: function () {
if (this.crtSec >= 60) {
this.crtMinu++
this.crtSec = 0
}
if (this.crtMinu >= 60) {
this.crtHour++
this.crtMinu = 0
}
var depText = ""
var tempText = ""
if (this.crtHour < 10) {
depText = "0" + this.crtHour
} else {
depText = "" + this.crtHour
}
tempText = "" + depText + ":"
if (this.crtMinu < 10) {
depText = "0" + this.crtMinu
} else {
depText = "" + this.crtMinu
}
tempText += depText + ":"
if (this.crtSec < 10) {
depText = "0" + this.crtSec
} else {
depText = "" + this.crtSec
}
tempText += depText
this.textTimer = tempText
},
normalTimerOut: function () {
this.crtSec++
this.refTime()
if (this.index <= 5) {
this.index++
} else {
this.index = 1
}
// rd190_factory.pwm(this.index)
if (this.crtHour >= 96) {
globalThis.factoryTest.beepLT = 1
// rd190_factory.pwm(0)
router.push({
path: "testLongTimeList"
});
}
},
clearTimer: function () {
this.$clearInterval(this.timerBeep);
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedOK: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
globalThis.factoryTest.beepLT = 1
this.returnResult()
},
touchedNG: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
globalThis.factoryTest.beepLT = 2
this.returnResult()
},
returnResult: function () {
// rd190_factory.pwm(0)
router.push({
path: "factory_testList"
});
}
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
.chooseBlock {
width: 240;
height: 160;
border-radius: 5;
border-width: 2;
border-color: white;
background-color: gainsboro;
}
.cbName {
top: 65;
width: 240;
height: 50;
color: black;
text-align: center;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
#id_cb1 {
left: 20;
top: 20;
}
#id_cb2 {
left: 280;
top: 20;
}
#id_cb3 {
left: 540;
top: 20;
}
#id_cb4 {
left: 20;
top: 200;
}
#id_cb5 {
left: 280;
top: 200;
}
#id_cb6 {
left: 540;
top: 200;
}
.functionBlock {
width: 320;
height: 100;
color: red;
border-radius: 5;
border-width: 2;
border-color: black;
background-color: gainsboro;
text-align: center;
text-overflow: ellipsis;
font-size: 35;
}
#id_ok {
left: 40;
top: 380;
}
#id_ng {
left: 440;
top: 380;
}
#id_reset {
left: 240;
top: 200;
}
#id_time {
top: 100;
width: 800;
height: 100;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: black;
background-color: transparent;
}
</style>
<html>
<div class="screen" onclick="touchedScreen">
<div id="id_color"></div>
<!-- <text id="reminderText">123456789123456789123456789</text> -->
<text class="class_Bginfo">{{crtBgLight}}</text>
<text class="class_msg" id="id_add" onclick="touchedAdd"></text>
<text class="class_msg" id="id_sub" onclick="touchedSub"></text>
<text class="class_msg" id="id_ok" onclick="touchedOk">yes</text>
<text class="class_msg" id="id_ng" onclick="touchedNg">no</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var bglight = require("factory_bglight.js");
export default {
data: {
colorBash: [
{
"val": 0xffffff,//纯白
"text": "纯白:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "纯红:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "纯绿:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "纯蓝:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "纯黑:#000000",//纯黑
},
],
imgCnt: 0,
crtBgLight: "亮度:100%",
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
this.lightLevel = 20
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
// this.$hide("id_ok")
// this.$hide("id_ng")
this.timerSet()
this.imgCnt = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
// bglight.changeBgLight(255)
this.clearTimer()
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer()
},
/*************** timer ***************/
timerSet: function () {
// this.timerColor = this.$setInterval(this.normalTimerOut, 1000, [], this);
},
normalTimerOut: function () {
},
clearTimer: function () {
},
/*************** connect ***************/
/*************** event ***************/
shortDelay: function () {
this.$setX("id_ng", 800);
this.$setY("id_ng", 340);
console.log("=====show id_ng successful!")
this.$clearTimeout(this.shortDelayId);
},
touchedScreen: function (node, topNode, x, y) {
if (this.imgCnt < this.colorBash.length) {
this.checkFlagBash(this.imgCnt)
this.imgCnt++
} else {
// this.$foreground("id_ok")
this.$show("id_ok")
console.log("=====show id_ok successful!")
// this.$foreground("id_ng")
this.$show("id_ng")
// this.shortDelayId = this.$setTimeout(this.shortDelay, 3000, [], this);
// this.$clearInterval(this.timerColor);
}
},
touchedAdd: function (node, topNode, x, y) {
if (this.lightLevel < 20) {
this.lightLevel++
}
else {
this.lightLevel = 20
}
var temp = 0;
temp = this.lightLevel * 5
this.crtBgLight = "亮度:" + temp + "%"
var tempLight = Math.floor(255 * (temp / 100))
// bglight.changeBgLight(tempLight)
},
touchedSub: function (node, topNode, x, y) {
if (this.lightLevel > 0) {
this.lightLevel--
}
else {
this.lightLevel = 0
}
var temp = 0;
temp = this.lightLevel * 5
this.crtBgLight = "亮度:" + temp + "%"
var tempLight = Math.floor(255 * (temp / 100))
// bglight.changeBgLight(tempLight)
},
touchedOk: function (node, topNode, x, y) {
globalThis.factoryTest.bgLight = 1
router.push({
path: "factory_testList"
});
},
touchedNg: function (node, topNode, x, y) {
globalThis.factoryTest.bgLight = 2
router.push({
path: "factory_testList"
});
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
console.log("tempType = " + typeof temp)
console.log("tempValue = " + temp)
this.$setBackgroundColor("id_color", temp)
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
#id_color {
width: 800;
height: 480;
background-color: black;
}
#reminderText {
top: 40;
width: 500;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: left;
/* text-overflow: ellipsis; */
font-size: 60;
color: white;
background-color: transparent;
}
.class_Bginfo {
top: 80;
left: 150;
width: 500;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
.class_msg {
top: 220;
width: 200;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
#id_add {
left: 100;
}
#id_sub {
left: 500;
}
#id_ok {
top: 360;
left: 100;
}
#id_ng {
top: 360;
left: 500;
}
</style>
\ No newline at end of file
<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>
<text class="fontsize60" id="title_TEXT"
style="left:50;top: 155;width: 305;height: 1280;text-align: center; background-color: transparent;color: white;">{{
title_TEXT }}</text>
<text class="fontsize60" id="title2_TEXT"
style="left:50;top: 300;width: 305;height: 1280;text-align: center; background-color: transparent;color: white;">{{
title2_TEXT }}</text>
<text class="fontsize60" id="qos_TEXT"
style="left:200;top: 155;width: 305;height: 1280;text-align: center; background-color: transparent;color: white;">{{
qos_TEXT }}</text>
<text class="fontsize60" id="signal_TEXT"
style="left:200;top: 300;width: 305;height: 1280;text-align: center; background-color: transparent;color: white;">{{
signal_TEXT }}</text>
<div id="exit" style="width: 300;height: 80;left:200;top:700;background-color: blue; border-radius: 10px;"
onclick="exit">
<text class="fontsize60" id="exit_TEXT"
style="left:0;top: 0;width: 300;height: 80;text-align: center; background-color: transparent;color: white;">{{
exit_TEXT }}</text>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var macGetId = null;
var qosGetId = null;
// var pageInterval = null;
export default {
data: {
title_TEXT: "QOS:",
title2_TEXT: "MAC:",
qos_TEXT: "NC",
signal_TEXT: "NC",
exit_TEXT: "退出",
},
onInit() {
},
onShow: function () {
if (macGetId != null) {
clearInterval(macGetId);
macGetId = null;
}
macGetId = setInterval(() => {
}, 200);
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
qosGetId = setInterval(() => {
}, 200);
},
exit: function (node, topNode, x, y) {
this.exitEvent();
},
exitEvent: function () {
if (macGetId != null) {
clearTimeout(macGetId);
macGetId = null;
}
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
router.push({
path: 'factory_testList'
})
},
};
</script>
<style>
.screen {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.trueActiveDiv {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.gifIcon {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.fontsize60 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: #ffffff;
background-color: transparent;
}
</style>
\ No newline at end of file
<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>
<!-- <text class="fontsize60" id="title_TEXT"
style="left:50;top: 155;width: 800;height: 1280;text-align: left; background-color: transparent;color: white;">{{
title_TEXT }}</text>
<text class="fontsize60" id="title2_TEXT"
style="left:50;top: 300;width: 305;height: 1280;text-align: left; background-color: transparent;color: white;">{{
title2_TEXT }}</text> -->
<text class="fontsize120" id="title_TEXT"
style="left:0;top: 10;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title_TEXT }}</text>
<text class="fontsize60" id="mac_TEXT"
style="left:0;top: 400;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
mac_TEXT }}</text>
<!-- <text class="fontsize60" id="mac_TEXT"
style="left:200;top: 300;width: 305;height: 1280;text-align: left; background-color: transparent;color: white;">{{
mac_TEXT }}</text> -->
<div id="exit" style="width: 300;height: 80;left:200;top:1100;background-color: blue; border-radius: 10px;"
onclick="exit">
<text class="fontsize60" id="exit_TEXT"
style="left:0;top: 0;width: 300;height: 80;text-align: center; background-color: transparent;color: white;">{{
exit_TEXT }}</text>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var lib = require("factory_bleInfo.js");
var macGetId = null;
var qosGetId = null;
// var pageInterval = null;
export default {
data: {
title_TEXT: "MAC:",
// title2_TEXT: "MAC:",
qos_TEXT: "NC",
mac_TEXT: "NC",
exit_TEXT: "退出",
},
onInit() {
},
onShow: function () {
var qosValue;
var macValue;
this.checkCnt = 0;
// lib.start();
if (macGetId != null) {
clearInterval(macGetId);
macGetId = null;
}
macGetId = setInterval(() => {
macValue = lib.read("mac");
this.mac_TEXT = macValue;
this.checkCnt++
if (this.checkCnt > 10) {
if (this.mac_TEXT == undefined) {
globalThis.factoryTest.ble = 2
} else {
globalThis.factoryTest.ble = 1
}
this.exitEvent()
}
}, 200);
},
exit: function (node, topNode, x, y) {
this.exitEvent();
},
exitEvent: function () {
if (macGetId != null) {
clearTimeout(macGetId);
macGetId = null;
}
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
// lib.close();
router.push({
path: 'factory_testList'
})
},
};
</script>
<style>
.screen {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.trueActiveDiv {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.gifIcon {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.fontsize120 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 120px;
color: #ffffff;
background-color: transparent;
}
.fontsize60 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 60px;
color: #ffffff;
background-color: transparent;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onlongpress="touchedResetRecord">
<template for="appItem" key="app" index="index">
<div class="chooseBlock" id="app.id" :url="app.startup" :top="app.top" :left="app.left" onclick="touchedBlock">
<text class="testName" :url="app.startup">{{app.name}}</text>
<text class="testInfo" :url="app.startup">{{app.info}}</text>
</div>
</template>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var file = require("file.js");
// var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
index: 0,
onlyOnceFlag: 0,
appItem: [
{
"id": "id_testEncoder",
"name": "喇叭测试",
"info": "hold press to return",
"startup": "testEncoder",
"top": 0,
"left": 0,
},
{
"id": "id_testTCard",
"name": "T卡检测",
"info": "scan TCard",
"startup": "testTCard",
"top": 0,
"left": 262,
},
{
"id": "id_testBglight",
"name": "背光测试",
"info": "Change the backlight",
"startup": "testBgLight",
"top": 240,
"left": 0,
},
],
},
/*************** struct ***************/
onInit: function () {
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.timerSet();
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.normalTimerOutId = this.$setTimeout(this.normalTimerOut, 100, [], this);
},
normalTimerOut: function () {
// rd190_factory.pwmInit()
this.testStatus()
},
clearTimer: function () {
this.$clearTimeout(this.normalTimerOutId);
this.$clearTimeout(this.tempTimerOutId);
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedBlock: function (node, topnode, x, y) {
console.log("X:" + x + " Y:" + y);
var url = this.$eval(topnode, ":url");
console.log("url:" + url);
if (url == undefined)
return;
if (url == "testTCard")
return;
router.push({
path: url
});
},
blockColorChange: function (relId, val) {
console.log(relId + ":" + val)
if (val == 1) {
this.$setBackgroundColor(relId, 0x00ff00)
}
else if (val == 2) {
this.$setBackgroundColor(relId, 0xff0000)
} else {
this.$setBackgroundColor(relId, 0xDCDCDC)
}
},
testStatus: function () {
this.blockColorChange(this.appItem[0].id, globalThis.factoryTest.encoder)
this.blockColorChange(this.appItem[1].id, globalThis.factoryTest.tcard)
this.blockColorChange(this.appItem[2].id, globalThis.factoryTest.bgLight)
},
tempSave: function () {
router.push({
path: "factory_testList"
});
},
touchedResetRecord: function (node, topNode, x, y) {
if (x > 600) {
console.log("will reset record.")
globalThis.factoryTest.color = 0
globalThis.factoryTest.touch = 0
globalThis.factoryTest.wifi = 0
globalThis.factoryTest.tcard = 0
globalThis.factoryTest.bgLight = 0
globalThis.factoryTest.serial = 0
globalThis.factoryTest.serialNG = 0
globalThis.factoryTest.beepLT = 0
globalThis.factoryTest.encoder = 0
globalThis.factoryTest.rtc = 0
var obj = {
"color": 0,
"touch": 0,
"wifi": 0,
"tcard": 0,
"serial": 0,
"serialNG": 0,
"rtcTimes": globalThis.factoryTest.rtcTimes,
"beepLT": 0,
"encoder": 0,
"rtc": 0,
"bgLight": 0,
}
console.log(obj)
file.write("product_res.json", obj)
this.tempTimerOutId = this.$setTimeout(this.tempSave, 100, [], this);
}
}
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: white;
}
/*********************************/
.chooseBlock {
width: 260;
height: 235;
background-color: gainsboro;
border-radius: 5;
border-color: black;
border-width: 2;
}
.testName {
top: 50;
left: 0;
width: 260;
height: 45;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
}
.testInfo {
top: 140;
left: 0;
width: 260;
height: 80;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 30;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onlongpress="touchedTime">
<div id="id_color"></div>
<text id="id_time">{{textTimer}}</text>
<text class="class_msg" id="id_ok" onclick="touchedOk">yes</text>
<text class="class_msg" id="id_ng" onclick="touchedNg">no</text>
</div>
</html>
<script>
var router = require("@system.router");
// var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
textTimer: "有声音吗?",
crtSec: 0,
imgCnt: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
// rd190_factory.rmmodEncoder()
// rd190_factory.soundInit()
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
// this.$hide("id_ok")
// this.$hide("id_ng")
this.timerSet()
// this.imgCnt = 0
// this.crtSec = 0
// this.checkFlagBash(this.imgCnt)
// this.imgCnt++
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer()
// rd190_factory.insmodEncoder()
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer()
// rd190_factory.insmodEncoder()
},
/*************** timer ***************/
timerSet: function () {
this.normalTimerOutId = this.$setInterval(this.normalTimerOut, 1000, [], this);
},
refTime: function () {
this.textTimer = "now light index:" + this.imgCnt
},
normalTimerOut: function () {
// if (this.imgCnt < 7) {
// } else {
// this.imgCnt = 0
// }
// this.checkFlagBash(this.imgCnt)
// this.imgCnt++
// this.crtSec++
// this.refTime()
// rd190_factory.soundOn()
this.$clearTimeout(this.normalTimerOutId);
},
clearTimer: function () {
this.$clearTimeout(this.normalTimerOutId);
},
/*************** connect ***************/
/*************** event ***************/
touchedOk: function (node, topNode, x, y) {
globalThis.factoryTest.encoder = 1
router.push({
path: "factory_testList"
});
},
touchedNg: function (node, topNode, x, y) {
globalThis.factoryTest.encoder = 2
router.push({
path: "factory_testList"
});
},
touchedTime: function (node, topNode, x, y) {
this.$show("id_ok")
this.$show("id_ng")
this.$clearInterval(this.timerColor);
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
checkFlagBash: function (val) {
var tempArray = [0, 0, 0, 0, 0, 0, 0]
tempArray[val] = 1
for (var cnt = 0; cnt < tempArray.length; cnt++) {
// rd190_factory.gpio(cnt + 1, tempArray[cnt])
}
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
#id_color {
width: 800;
height: 480;
background-color: black;
}
.class_msg {
top: 240;
width: 200;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
#id_ok {
left: 100;
}
#id_ng {
left: 500;
}
#id_time {
top: 100;
width: 800;
height: 100;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: white;
background-color: transparent;
}
</style>
\ No newline at end of file
<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>
<text class="fontsize60" id="title_TEXT" style="left:0;top: 10;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title_TEXT }}</text>
<text class="fontsize60" id="title2_TEXT" style="left:0;top: 640;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title2_TEXT }}</text>
<text class="fontsize40" id="data_TEXT" style="left:0;top: 80;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
data_TEXT }}</text>
<text class="fontsize40" id="iccid_TEXT" style="left:0;top: 710;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
iccid_TEXT }}</text>
<div id="exit" style="width: 300;height: 80;left:200;top:1180;background-color: blue; border-radius: 10px;" onclick="exit">
<text class="fontsize60" id="exit_TEXT" style="width: 300;height: 80;text-align: center; background-color: transparent;color: white;">{{
exit_TEXT }}</text>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var lib = require("factory_esim.js");
var Get1Id = null;
var Get2Id = null;
// var pageInterval = null;
export default {
data: {
title_TEXT: "E-SIM信息",
title2_TEXT: "ICCID",
iccid_TEXT: "NC",
data_TEXT: "NC",
exit_TEXT: "退出",
},
onInit() {
},
onShow: function () {
var qosValue;
var macValue;
this.checkCnt = 0;
var signal = lib.read("signal");
var imei = lib.read("imei");
this.data_TEXT = "signal :" + signal + "imei :" + imei;
this.iccid_TEXT = lib.read("iccid");
// lib.start();
if (Get1Id != null) {
clearInterval(Get1Id);
Get1Id = null;
}
Get1Id = setInterval(() => {
var signal = lib.read("signal");
var imei = lib.read("imei");
this.data_TEXT = "signal :" + signal + "imei :" + imei;
}, 2000);
if (Get2Id != null) {
clearInterval(Get2Id);
Get2Id = null
}
Get2Id = setInterval(() => {
this.iccid_TEXT = lib.read("iccid");
// this.iccid_TEXT = lib.read("iccid");
this.checkCnt++
if(this.checkCnt>2){
if(this.iccid_TEXT==undefined){
globalThis.factoryTest.esim = 2
}else{
globalThis.factoryTest.esim = 1
}
this.exitEvent();
}
}, 2000);
},
exit: function (node, topNode, x, y) {
this.exitEvent();
},
exitEvent: function () {
if (Get1Id != null) {
clearTimeout(Get1Id);
Get1Id = null;
}
if (Get2Id != null) {
clearInterval(Get2Id);
Get2Id = null
}
// lib.close();
router.push({
path: 'factory_testList'
})
},
};
</script>
<style>
.screen {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.trueActiveDiv {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.gifIcon {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.fontsize60 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: #ffffff;
background-color: transparent;
}
.fontsize40 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
color: #ffffff;
background-color: transparent;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onlongpress="touchedTime" onclick="activeScreen">
<div id="id_color"></div>
<text id="id_time">{{textTimer}}</text>
<text class="class_msg" id="id_exit" onclick="touchedExit">退出</text>
<text class="class_msg" id="id_cancel" onclick="touchedCancel">继续</text>
<text id="id_reminder">{{text_reminder}}</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var file = require("file.js");
var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
textTimer: "00:00:00",
crtSec: 0,
crtMinu: 0,
crtHour: 0,
colorBash: [
{
"val": 0xffffff,//纯白
"text": "white:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "red:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "green:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "blue:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "black:#000000",//纯黑
},
],
imgCnt: 0,
index: 0,
text_reminder: "This screen has been clicked!",
},
/*************** struct ***************/
onInit: function () {
// rd190_factory.pwmInit()
// rd190_factory.soundInit()
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.timerSet();
this.$hide("id_reminder")
this.$hide("id_exit")
this.$hide("id_cancel")
this.imgCnt = 0
this.crtSec = 0
this.crtMinu = 0
this.crtHour = 0
this.index = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
this.text_reminder = "This screen has been clicked!"
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.timerBeepId = this.$setInterval(this.timerBeep, 1000, [], this);
// this.timerScreenId = this.$setInterval(this.timerScreen, 1000, [], this);
},
refTime: function () {
if (this.crtSec >= 60) {
this.crtMinu++
this.crtSec = 0
}
if (this.crtMinu >= 60) {
this.crtHour++
this.crtMinu = 0
}
var depText = ""
var tempText = ""
if (this.crtHour < 10) {
depText = "0" + this.crtHour
} else {
depText = "" + this.crtHour
}
tempText = "" + depText + ":"
if (this.crtMinu < 10) {
depText = "0" + this.crtMinu
} else {
depText = "" + this.crtMinu
}
tempText += depText + ":"
if (this.crtSec < 10) {
depText = "0" + this.crtSec
} else {
depText = "" + this.crtSec
}
tempText += depText
this.textTimer = tempText
},
timerBeep: function () {
this.crtSec++
this.index++
this.refTime()
if (this.index % 2 == 0) {
rd190_factory.pwm(0)
} else {
rd190_factory.pwm(1)
}
if (this.crtSec % 20 == 0) {
rd190_factory.soundOn()
}
if (this.crtHour >= 96) {
globalThis.factoryTest.beepLT = 1
rd190_factory.pwm(0)
this.text_reminder = "The test time reached 96 hours!"
this.$show("id_reminder")
// router.push({
// path: "testLongTimeList"
// });
}
if (this.imgCnt < this.colorBash.length) {
} else {
this.imgCnt = 0
}
this.checkFlagBash(this.imgCnt)
this.imgCnt++
},
// timerScreen: function () {
// },
clearTimer: function () {
this.$clearInterval(this.timerBeepId);
// this.$clearInterval(this.timerScreenId);
this.$clearTimeout(this.showThrSecondId)
},
/*************** connect ***************/
/*************** event ***************/
activeScreen: function (node, topnode, x, y) {
this.$show("id_reminder")
this.showThrSecondId = this.$setTimeout(this.showOneSecond, 3000, [], this)
},
showOneSecond: function () {
this.$hide("id_reminder")
this.$clearTimeout(this.showThrSecondId)
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedExit: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
// globalThis.factoryTest.beepLT = 1
this.returnResult()
},
touchedCancel: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
// globalThis.factoryTest.beepLT = 2
this.timerSet();
this.$hide("id_exit")
this.$hide("id_cancel")
},
touchedTime: function (node, topNode, x, y) {
this.$show("id_exit")
this.$show("id_cancel")
rd190_factory.pwm(0)
// this.$clearInterval(this.timerScreenId);
this.$clearInterval(this.timerBeepId);
},
returnResult: function () {
rd190_factory.pwm(0)
router.push({
path: "factory_testList"
});
},
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
this.$setBackgroundColor("id_color", temp)
val++
if (val < this.colorBash.length) {
} else {
val = 0
}
temp = this.colorBash[val].val
this.$setTextColor("id_time", temp)
},
touchedBlock: function (node, topnode, x, y) {
console.log("X:" + x + " Y:" + y);
var url = this.$eval(topnode, ":url");
console.log("url:" + url);
if (url == undefined)
return;
if (url == "testTCard")
return;
router.push({
path: url
});
},
blockColorChange: function (relId, val) {
console.log(relId + ":" + val)
if (val == 1) {
this.$setBackgroundColor(relId, "#00ff00")
}
else if (val == 2) {
this.$setBackgroundColor(relId, "#ff0000")
} else {
this.$setBackgroundColor(relId, "#DCDCDC")
}
},
testStatus: function () {
this.blockColorChange(this.appItem[0].id, globalThis.factoryTest.beepLT)
this.blockColorChange(this.appItem[1].id, globalThis.factoryTest.beepLT)
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: white;
}
/*********************************/
#id_color {
width: 800;
height: 480;
background-color: black;
}
#id_time {
top: 100;
width: 800;
height: 100;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: black;
background-color: transparent;
}
.class_msg {
top: 360;
width: 300;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 56;
color: black;
background-color: gainsboro;
}
#id_exit {
left: 50;
}
#id_cancel {
left: 450;
}
#id_reminder {
top: 216;
left: 0;
width: 800;
height: 52;
font-size: 45;
text-align: center;
color: #f76832;
}
.chooseBlock {
width: 260;
height: 235;
background-color: gainsboro;
border-radius: 5;
border-color: black;
border-width: 2;
}
.testName {
top: 50;
left: 0;
width: 260;
height: 45;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
}
.testInfo {
top: 140;
left: 0;
width: 260;
height: 80;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 30;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onlongpress="touchedTime" onclick="activeScreen">
<div id="id_color"></div>
<text id="id_time">{{textTimer}}</text>
<text class="class_msg" id="id_exit" onclick="touchedExit">退出</text>
<text class="class_msg" id="id_cancel" onclick="touchedCancel">继续</text>
<text id="id_reminder">{{text_reminder}}</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var file = require("file.js");
// var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
textTimer: "00:00:00",
crtSec: 0,
crtMinu: 0,
crtHour: 0,
colorBash: [
{
"val": 0xffffff,//纯白
"text": "white:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "red:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "green:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "blue:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "black:#000000",//纯黑
},
],
imgCnt: 0,
index: 0,
text_reminder: "This screen has been clicked!",
},
/*************** struct ***************/
onInit: function () {
// rd190_factory.pwmInit()
// rd190_factory.soundInit()
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.timerSet();
this.$hide("id_reminder")
this.$hide("id_exit")
this.$hide("id_cancel")
this.imgCnt = 0
this.crtSec = 0
this.crtMinu = 0
this.crtHour = 0
this.index = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
this.text_reminder = "This screen has been clicked!"
globalThis.factoryTest.beepLT = 0
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.timerBeepId = this.$setInterval(this.timerBeep, 1000, [], this);
// this.timerScreenId = this.$setInterval(this.timerScreen, 1000, [], this);
},
refTime: function () {
if (this.crtSec >= 60) {
this.crtMinu++
this.crtSec = 0
}
if (this.crtMinu >= 60) {
this.crtHour++
this.crtMinu = 0
}
var depText = ""
var tempText = ""
if (this.crtHour < 10) {
depText = "0" + this.crtHour
} else {
depText = "" + this.crtHour
}
tempText = "" + depText + ":"
if (this.crtMinu < 10) {
depText = "0" + this.crtMinu
} else {
depText = "" + this.crtMinu
}
tempText += depText + ":"
if (this.crtSec < 10) {
depText = "0" + this.crtSec
} else {
depText = "" + this.crtSec
}
tempText += depText
this.textTimer = tempText
},
timerBeep: function () {
this.crtSec++
this.index++
this.refTime()
if (this.index % 2 == 0) {
// rd190_factory.pwm(0)
} else {
// rd190_factory.pwm(1)
}
if (this.crtSec % 20 == 0) {
// rd190_factory.soundOn()
}
if (this.crtHour >= 96) {
globalThis.factoryTest.beepLT = 1
// rd190_factory.pwm(0)
this.text_reminder = "Test time reached 96 hours!"
this.$show("id_reminder")
// router.push({
// path: "testLongTimeList"
// });
}
if (this.imgCnt < this.colorBash.length) {
} else {
this.imgCnt = 0
}
this.checkFlagBash(this.imgCnt)
this.imgCnt++
},
// timerScreen: function () {
// },
clearTimer: function () {
this.$clearInterval(this.timerBeepId);
// this.$clearInterval(this.timerScreenId);
this.$clearTimeout(this.showThrSecondId)
},
/*************** connect ***************/
/*************** event ***************/
activeScreen: function (node, topnode, x, y) {
this.$show("id_reminder")
this.showThrSecondId = this.$setTimeout(this.showOneSecond, 3000, [], this)
},
showOneSecond: function () {
this.$hide("id_reminder")
this.$clearTimeout(this.showThrSecondId)
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedExit: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
// globalThis.factoryTest.beepLT = 1
this.returnResult()
},
touchedCancel: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
// globalThis.factoryTest.beepLT = 2
this.timerSet();
this.$hide("id_exit")
this.$hide("id_cancel")
},
touchedTime: function (node, topNode, x, y) {
this.$show("id_exit")
this.$show("id_cancel")
// rd190_factory.pwm(0)
// this.$clearInterval(this.timerScreenId);
this.$clearInterval(this.timerBeepId);
},
returnResult: function () {
// rd190_factory.pwm(0)
router.push({
path: "factory_testList"
});
},
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
this.$setBackgroundColor("id_color", temp)
val++
if (val < this.colorBash.length) {
} else {
val = 0
}
temp = this.colorBash[val].val
this.$setTextColor("id_time", temp)
},
touchedBlock: function (node, topnode, x, y) {
console.log("X:" + x + " Y:" + y);
var url = this.$eval(topnode, ":url");
console.log("url:" + url);
if (url == undefined)
return;
if (url == "testTCard")
return;
router.push({
path: url
});
},
blockColorChange: function (relId, val) {
console.log(relId + ":" + val)
if (val == 1) {
this.$setBackgroundColor(relId, "#00ff00")
}
else if (val == 2) {
this.$setBackgroundColor(relId, "#ff0000")
} else {
this.$setBackgroundColor(relId, "#DCDCDC")
}
},
testStatus: function () {
this.blockColorChange(this.appItem[0].id, globalThis.factoryTest.beepLT)
this.blockColorChange(this.appItem[1].id, globalThis.factoryTest.beepLT)
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 1280;
height: 1280;
background-color: white;
}
/*********************************/
#id_color {
width: 1280;
height: 1280;
background-color: black;
}
#id_time {
top: 100;
width: 800;
height: 100;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: black;
background-color: transparent;
}
.class_msg {
top: 360;
width: 300;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 56;
color: black;
background-color: gainsboro;
}
#id_exit {
left: 50;
}
#id_cancel {
left: 450;
}
#id_reminder {
top: 216;
left: 0;
width: 800;
height: 52;
font-size: 45;
text-align: center;
color: #f76832;
}
.chooseBlock {
width: 260;
height: 235;
background-color: gainsboro;
border-radius: 5;
border-color: black;
border-width: 2;
}
.testName {
top: 50;
left: 0;
width: 260;
height: 45;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
}
.testInfo {
top: 140;
left: 0;
width: 260;
height: 80;
color: black;
text-align: center;
text-overflow: ellipsis;
font-size: 30;
}
</style>
\ No newline at end of file
<!--结构描述-->
<html>
<!--背景块区域 样式container 点击事件 bgclick-->
<div class="screen">
<text id="date">{{crtDate}}</text>
<text class="class_msg" id="id_ok">自检</text>
<text class="class_msg" id="id_ng">勿触</text>
</div>
</html>
<!--功能描述-->
<script>
//接口声明 使用路由功能模块
var router = require("@system.router");
var librtc = require("factory_rtc.js");
var file = require("file.js");
var libtime = require("factory_time.js");
//写入内容与操作
export default {
//数据写入 变量pagetitle 类型字符串 内容“页0”
data: {
crtDate: "检测RTC是否存在",
// crtDate: "08/14 周一 15:10:00",
},
dateClick: function (node, topnode, x, y) {
if (this.beepEn == 0) {
this.beepEn = 1;
// var dateObj = libtime.getCurrentTime();
// console.log("============dataObj=" + dateObj);
// console.log("dateObjType = " + typeof dateObj)
// this.crtDate = dateObj['tempstr1'] + dateObj['tempstr2']
this.crtDate = this.new_tiemr();
// console.log("============crtDate=" + this.crtDate);
} else {
this.beepEn = 0;
this.crtDate = "";
}
},
timerset: function () {
this.refreshTimeId = this.$setInterval(this.refreshTime, 1000, [], this);
this.Timedexitid = this.$setInterval(this.autotest, 1000, [], this);
},
onShow: function () {
console.log(this.$uri + "===========onShow=============");
// this.timerset();
this.beepEn = 1;
var ret = (librtc.getrtc("getRTC"))
console.log('ret===' + ret)
if (ret == 1) {
this.okShortDelayId = this.$setTimeout(this.okShortDelay, 1000, [], this);
} else {
this.ngShortDelayId = this.$setTimeout(this.ngShortDelay, 1000, [], this);
}
// var dateObj = libtime.getCurrentTime()
// console.log("dataObj=" + dateObj)
if (globalThis.factoryTest.rtcTimes == 100) {
librtc.ctrl("set", {
year: 2023,
month: 8,
day: 14,
hour: 15,
minute: 10,
second: 0,
});
globalThis.factoryTest.rtcTimes = 1;
// this.saveValue();
}
},
clearTimer: function () {
if (this.refreshTimeId) {
this.$clearInterval(this.refreshTimeId);
}
if (this.Timedexitid) {
this.$clearInterval(this.Timedexitid);
}
this.$clearTimeout(this.okShortDelayId);
this.$clearTimeout(this.ngShortDelayId);
this.autotestnum = 1;
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
okShortDelay: function () {
this.touchedOk("", "", "", "");
this.$clearTimeout(this.okShortDelayId);
},
ngShortDelay: function () {
this.touchedNg("", "", "", "");
this.$clearTimeout(this.ngShortDelayId);
},
refreshTime: function () {
this.crtDate = this.new_tiemr();
},
new_tiemr: function () {
var weekName = new Array(
"周日",
"周一",
"周二",
"周三",
"周四",
"周五",
"周六"
);
var newdata = new Date();
var years = newdata.getFullYear();
var year = String(years).substring(2, 4);
var month = newdata.getMonth() + 1;
var data1 = newdata.getDate();
var day = newdata.getDay(); //0-6
var houurs = newdata.getUTCHours();
var minutes = newdata.getMinutes();
var seconds = newdata.getSeconds();
let dataobj =
this.addZero(month) +
"/" +
this.addZero(data1) +
" " +
weekName[day] +
" " +
this.addZero(houurs) +
":" +
this.addZero(minutes) +
":" +
this.addZero(seconds);
return dataobj;
},
addZero: function (params) {
return params < 10 ? "0" + params : params;
},
autotest: function () {
if (this.autotestnum) {
this.autotestnum += 1;
} else this.autotestnum = 1;
if (this.autotestnum > 3) {
this.tests_timer();
}
},
tests_timer: function () {
console.log('this.crtDate===' + this.crtDate)
let ndata = this.crtDate.split(" ");
if (ndata[0] == "01/01") {
this.touchedNg("", "", "", "");
} else {
this.touchedOk("", "", "", "");
}
},
saveValue: function () {
var color = globalThis.factoryTest.color;
var touch = globalThis.factoryTest.touch;
var wifi = globalThis.factoryTest.wifi;
var tcard = globalThis.factoryTest.tcard;
var serial = globalThis.factoryTest.serial;
var serialNG = globalThis.factoryTest.serialNG;
var rtcTimes = globalThis.factoryTest.rtcTimes;
var beepLT = globalThis.factoryTest.beepLT;
var encoder = globalThis.factoryTest.encoder;
var rtc = globalThis.factoryTest.rtc;
var bgLight = globalThis.factoryTest.bgLight;
var obj = {
color: color,
touch: touch,
wifi: wifi,
tcard: tcard,
serial: serial,
serialNG: serialNG,
rtcTimes: rtcTimes,
beepLT: beepLT,
encoder: encoder,
rtc: rtc,
// "bgLight": bgLight,
};
console.log(obj);
file.write("product_res.json", obj);
},
touchedOk: function (node, topNode, x, y) {
globalThis.factoryTest.rtc = 1;
router.push({
path: "factory_testList",
});
},
touchedNg: function (node, topNode, x, y) {
globalThis.factoryTest.rtc = 2;
router.push({
path: "factory_testList",
});
},
};
</script>
<!--样式描述-->
<style>
/*背景块的样式*/
.screen {
width: 1280;
height: 1280;
background-color: black;
}
#date {
left: 40;
top: 50;
width: 600;
height: 60;
font-size: 55;
color: white;
text-align: center;
/* text-overflow: ellipsis; */
}
.class_msg {
top: 240;
width: 250;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 50;
color: red;
background-color: gainsboro;
}
#id_ok {
left: 75;
}
#id_ng {
left: 475;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onlongpress="touchedTime">
<div id="id_color"></div>
<text id="id_time">{{textTimer}}</text>
<text class="class_msg" id="id_ok" onclick="touchedOk">yes</text>
<text class="class_msg" id="id_ng" onclick="touchedNg">no</text>
</div>
</html>
<script>
var router = require("@system.router");
export default {
data: {
textTimer: "00:00:00",
crtSec: 0,
crtMinu: 0,
crtHour: 0,
colorBash: [
{
"val": 0xffffff,//纯白
"text": "white:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "red:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "green:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "blue:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "black:#000000",//纯黑
},
],
imgCnt: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.$hide("id_ok")
this.$hide("id_ng")
this.timerSet()
this.imgCnt = 0
this.crtSec = 0
this.crtMinu = 0
this.crtHour = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer()
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer()
},
/*************** timer ***************/
timerSet: function () {
this.timerColor = this.$setInterval(this.normalTimerOut, 1000, [], this);
},
refTime: function () {
if (this.crtSec >= 60) {
this.crtMinu++
this.crtSec = 0
}
if (this.crtMinu >= 60) {
this.crtHour++
this.crtMinu = 0
}
var depText = ""
var tempText = ""
if (this.crtHour < 10) {
depText = "0" + this.crtHour
} else {
depText = "" + this.crtHour
}
tempText = "" + depText + ":"
if (this.crtMinu < 10) {
depText = "0" + this.crtMinu
} else {
depText = "" + this.crtMinu
}
tempText += depText + ":"
if (this.crtSec < 10) {
depText = "0" + this.crtSec
} else {
depText = "" + this.crtSec
}
tempText += depText
this.textTimer = tempText
},
normalTimerOut: function () {
if (this.imgCnt < this.colorBash.length) {
} else {
this.imgCnt = 0
}
this.checkFlagBash(this.imgCnt)
this.imgCnt++
this.crtSec++
this.refTime()
},
clearTimer: function () {
},
/*************** connect ***************/
/*************** event ***************/
touchedOk: function (node, topNode, x, y) {
globalThis.factoryTest.screen = 1
router.push({
path: "factory_testList"
});
},
touchedNg: function (node, topNode, x, y) {
globalThis.factoryTest.screen = 2
router.push({
path: "factory_testList"
});
},
touchedTime: function (node, topNode, x, y) {
this.$show("id_ok")
this.$show("id_ng")
this.$clearInterval(this.timerColor);
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
this.$setBackgroundColor("id_color", temp)
val++
if (val < this.colorBash.length) {
} else {
val = 0
}
temp = this.colorBash[val].val
this.$setTextColor("id_time", temp)
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
#id_color {
width: 800;
height: 480;
background-color: black;
}
.class_msg {
top: 240;
width: 200;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
#id_ok {
left: 100;
}
#id_ng {
left: 500;
}
#id_time {
top: 100;
width: 800;
height: 100;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: black;
background-color: transparent;
}
</style>
<html>
<div class="screen" onclick="touchedScreen">
<text class="testLog">{{ testLogs }}</text>
<text class="testPct">{{ testPcts }}</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var process = require("@system.process");
var uart = require("uart.js");
var dpkt = require("dpkt.js");
function HeaderPacket() {
this.__hdr__ = [
["header", "H", 0x5aa5],
["data", "H", 0xffff],
];
this.__byteorder__ = ">";
}
export default {
data: {
testPct: 0,
testPcts: "",
testLogs: "",
testCnt: 0,
testData: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onReady: function () {
this.normalTimerOutId = this.$setTimeout(
this.normalTimerOut,
100,
[],
this
);
},
onShow: function () {
this.testPct = 0;
this.testCnt = 0;
console.log(this.$uri + "===========onShow=============");
this.timerSet();
globalThis.getUartData = this.getUartData;
// if (globalThis.uart1 != undefined) {
// globalThis.uart1.on("data", globalThis.getUartData, this);
// }
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.normalIntervalId = this.$setInterval(
this.normalInterval,
300,
[],
this
);
},
clearTimer: function () {
this.$clearInterval(this.normalIntervalId);
// this.$clearInterval(this.timer1);
this.$clearTimeout(this.normalTimerOutId);
// uart.close({
// path: "/dev/ttyS0",
// baudRate: 115200,
// dataBits: 8,
// stopbits: 1,
// parity: 0,
// mode: 'text' // mode="text/json/bin"
// })
},
normalInterval: function () {
console.log("------user uart send.----------------");
if (this.testCnt > 5) {
var tempVal = this.testPct;
if (tempVal >= 2) {
globalThis.factoryTest.serial = 1;
} else {
globalThis.factoryTest.serial = 2;
}
router.push({
path: "factory_testList",
});
}
var _person = new HeaderPacket();
var packet = dpkt.Packet(_person);
this.testData = Math.floor(Math.random() * 65535);
var obj = {
header: 0x5aa5,
data: this.testData,
};
var res = packet.pack(obj);
res.print();
try {
globalThis.uart1.write(res);
} catch (e) {
console.log("!!!ERROR:" + e)
}
this.testLogs =
"the times:" +
this.testCnt +
"\ndata:" +
this.testData +
"\nstatus:sent.";
this.testCnt++;
},
normalTimerOut: function () {
console.log("in timerout");
this.setUart();
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedScreen: function (node, topnode, x, y) {
router.push({
path: "factory_testList",
});
},
getUartDataBuf: function (data, length, prop) {
console.log("length:" + length);
data.print();
globalThis.getUartData(data, length, prop);
return;
// var _hpacket = new HeaderPacket();
// var hpacket = dpkt.Packet(_hpacket);
// var headerObj = hpacket.unpack(data);
// if (headerObj["header"] == 0x5aa5) {
// this.testLogs += "\nhad been received\nhead status:correct.";
// console.log("is correct.");
// var pData = headerObj["data"];
// console.log("the package data:" + pData);
// if (pData == this.testData) {
// this.testLogs += "\ndata:" + this.testData + "\nstatus:normal。";
// this.testPct++;
// var tempVal = Math.round((this.testPct / this.testCnt) * 100);
// this.testPcts = "pass rate:" + tempVal + "%";
// }
// } else {
// this.testLogs +=
// "\nhad been received\nhead status:abnormal-" + headerObj["header"];
// console.log("isnt correct.header:" + headerObj["header"]);
// }
// // this.testPct++;
// data.free();
// console.log("serial data read finished.");
// return;
},
getUartData: function (data, length, prop) {
var router = require("@system.router");
var indexObj = router.currentPage.$indexObj;
prop = indexObj;
console.log("length:" + length);
data.print();
var _hpacket = new HeaderPacket();
var hpacket = dpkt.Packet(_hpacket);
var headerObj = hpacket.unpack(data);
if (headerObj["header"] == 0x5aa5) {
prop.testLogs += "\nhad been received\nhead status:correct.";
console.log("is correct.");
var pData = headerObj["data"];
console.log("the package data:" + pData);
if (pData == prop.testData) {
prop.testLogs += "\ndata:" + prop.testData + "\nstatus:normal。";
prop.testPct++;
var tempVal = Math.round((prop.testPct / prop.testCnt) * 100);
prop.testPcts = "pass rate:" + tempVal + "%";
}
} else {
prop.testLogs +=
"\nhad been received\nhead status:abnormal-" + headerObj["header"];
console.log("isnt correct.header:" + headerObj["header"]);
}
// prop.testPct++;
data.free();
console.log("serial data read finished.");
return;
},
setUart: function () {
console.log("=====function setUart=====");
console.log(uart);
if (globalThis.uart1 != undefined) {
globalThis.getUartData = this.getUartData;
// globalThis.uart1.on("data", globalThis.getUartData, this);
// this.timer1 = this.$setInterval(
// () => {
// globalThis.uart1.read();
// //uart1.write(`11111111111111111111111111111111111111\n`)
// },
// 50,
// [],
// this
// );
return;
}
globalThis.getUartData = this.getUartData;
var port = "/dev/ttyS0";
console.log(require("@system.process"));
if (process.platform == "win32") {
console.log("its win32.");
port = "COM4";
}
console.log(port);
globalThis.uart1 = uart.open({
path: port,
baudRate: 115200,
dataBits: 8,
stopbits: 1,
parity: 0,
mode: "text", // mode="text/json/bin"
});
var prop = this;
try {
globalThis.uart1.on("data", this.getUartDataBuf, prop);
} catch (e) {
console.log("!!!ERROR:" + e)
}
this.timer1 = this.$setInterval(
() => {
try {
globalThis.uart1.read();
} catch (e) {
console.log("!!!ERROR:" + e)
}
//uart1.write(`11111111111111111111111111111111111111\n`)
},
50,
[],
this
);
},
};
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 1280;
height: 1280;
background-color: black;
}
/*********************************/
.testLog {
width: 1280;
height: 1280;
color: white;
text-align: left;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
.testPct {
top: 420;
width: 1280;
height: 40;
color: white;
text-align: left;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
</style>
\ No newline at end of file
<html>
<div class="screen" onclick="touchedScreen">
<text class="testLog">{{ testLogs }}</text>
<text class="testPct">{{ testPcts }}</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var process = require("@system.process");
var uart = require("uart.js");
var dpkt = require("dpkt.js");
function HeaderPacket() {
this.__hdr__ = [
["header", "H", 0x5aa5],
["data", "H", 0xffff],
];
this.__byteorder__ = ">";
}
export default {
data: {
testPct: 0,
testPcts: "",
testLogs: "",
testCnt: 0,
testData: 0,
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onReady: function () {
this.normalTimerOutId = this.$setTimeout(
this.normalTimerOut,
100,
[],
this
);
},
onShow: function () {
this.testPct = 0;
this.testCnt = 0;
console.log(this.$uri + "===========onShow=============");
this.timerSet();
globalThis.getUartData = this.getUartData;
// if (globalThis.uart1 != undefined) {
// globalThis.uart1.on("data", globalThis.getUartData, this);
// }
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.normalIntervalId = this.$setInterval(
this.normalInterval,
300,
[],
this
);
},
clearTimer: function () {
this.$clearInterval(this.normalIntervalId);
// this.$clearInterval(this.timer1);
this.$clearTimeout(this.normalTimerOutId);
// uart.close({
// path: "/dev/ttyS0",
// baudRate: 115200,
// dataBits: 8,
// stopbits: 1,
// parity: 0,
// mode: 'text' // mode="text/json/bin"
// })
},
normalInterval: function () {
console.log("------user uart send.----------------");
if (this.testCnt > 5) {
var tempVal = this.testPct;
if (tempVal < 1) {
globalThis.factoryTest.serialNG = 1;
} else {
globalThis.factoryTest.serialNG = 2;
}
router.push({
path: "factory_testList",
});
}
var _person = new HeaderPacket();
var packet = dpkt.Packet(_person);
this.testData = Math.floor(Math.random() * 65535);
var obj = {
header: 0x5aa5,
data: this.testData,
};
var res = packet.pack(obj);
res.print();
try {
globalThis.uart1.write(res);
} catch (e) {
console.log("!!!ERROR:" + e)
}
this.testLogs =
"the times:" +
this.testCnt +
"\ndata:" +
this.testData +
"\nstatus:sent.";
this.testCnt++;
},
normalTimerOut: function () {
console.log("in timerout");
this.setUart();
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedScreen: function (node, topnode, x, y) {
router.push({
path: "factory_testList",
});
},
getUartDataBuf: function (data, length, prop) {
console.log("length:" + length);
data.print();
globalThis.getUartData(data, length, prop);
return;
// var _hpacket = new HeaderPacket();
// var hpacket = dpkt.Packet(_hpacket);
// var headerObj = hpacket.unpack(data);
// if (headerObj["header"] == 0x5aa5) {
// this.testLogs += "\nhad been received\nhead status:correct.";
// console.log("is correct.");
// var pData = headerObj["data"];
// console.log("the package data:" + pData);
// if (pData == this.testData) {
// this.testLogs += "\ndata:" + this.testData + "\nstatus:normal。";
// this.testPct++;
// var tempVal = Math.round((this.testPct / this.testCnt) * 100);
// this.testPcts = "pass rate:" + tempVal + "%";
// }
// } else {
// this.testLogs +=
// "\nhad been received\nhead status:abnormal-" + headerObj["header"];
// console.log("isnt correct.header:" + headerObj["header"]);
// }
// // this.testPct++;
// data.free();
// console.log("serial data read finished.");
// return;
},
getUartData: function (data, length, prop) {
var router = require("@system.router");
var indexObj = router.currentPage.$indexObj;
prop = indexObj;
console.log("length:" + length);
data.print();
var _hpacket = new HeaderPacket();
var hpacket = dpkt.Packet(_hpacket);
var headerObj = hpacket.unpack(data);
if (headerObj["header"] == 0x5aa5) {
prop.testLogs += "\nhad been received\nhead status:correct.";
console.log("is correct.");
var pData = headerObj["data"];
console.log("the package data:" + pData);
if (pData == prop.testData) {
prop.testLogs += "\ndata:" + prop.testData + "\nstatus:normal。";
prop.testPct++;
var tempVal = Math.round((prop.testPct / prop.testCnt) * 100);
prop.testPcts = "pass rate:" + tempVal + "%";
}
} else {
prop.testLogs +=
"\nhad been received\nhead status:abnormal-" + headerObj["header"];
console.log("isnt correct.header:" + headerObj["header"]);
}
// prop.testPct++;
data.free();
console.log("serial data read finished.");
return;
},
setUart: function () {
console.log("=====function setUart=====");
console.log(uart);
if (globalThis.uart1 != undefined) {
globalThis.getUartData = this.getUartData;
// globalThis.uart1.on("data", globalThis.getUartData, this);
// this.timer1 = this.$setInterval(
// () => {
// globalThis.uart1.read();
// //uart1.write(`11111111111111111111111111111111111111\n`)
// },
// 50,
// [],
// this
// );
return;
}
globalThis.getUartData = this.getUartData;
var port = "/dev/ttyS0";
console.log(require("@system.process"));
if (process.platform == "win32") {
console.log("its win32.");
port = "COM4";
}
console.log(port);
globalThis.uart1 = uart.open({
path: port,
baudRate: 115200,
dataBits: 8,
stopbits: 1,
parity: 0,
mode: "text", // mode="text/json/bin"
});
var prop = this;
try {
globalThis.uart1.on("data", this.getUartDataBuf, prop);
} catch (e) {
console.log("!!!ERROR:" + e)
}
this.timer1 = this.$setInterval(
() => {
try {
globalThis.uart1.read();
} catch (e) {
console.log("!!!ERROR:" + e)
}
//uart1.write(`11111111111111111111111111111111111111\n`)
},
50,
[],
this
);
},
};
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 1280;
height: 1280;
background-color: black;
}
/*********************************/
.testLog {
width: 1280;
height: 1280;
color: white;
text-align: left;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
.testPct {
top: 420;
width: 1280;
height: 40;
color: white;
text-align: left;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
</style>
\ No newline at end of file
<html>
<div class="screen">
<text class="functionBlock" id="id_ok" onclick="touchedOK">yes</text>
<text class="functionBlock" id="id_ng" onclick="touchedNG">no</text>
<text class="functionBlock" id="id_reset" onclick="touchedReset">{{crtText}}</text>
</div>
</html>
<script>
var router = require("@system.router");
var fs = require("@system.fs");
// var rd190_factory = require("factory_rd190_factory.js");
export default {
data: {
index: 0,
crtText: "未检测到TCard",
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
this.timeCnt = 0;
},
onShow: function () {
console.log(this.$uri + "===========onShow=============")
this.index = 0
this.timerSet();
},
onHide: function () {
console.log(this.$uri + "===========onHide=============")
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============")
this.clearTimer();
},
/*************** timer ***************/
timerSet: function () {
this.readFileId = this.$setInterval(this.readFile, 1000, [], this);
},
readFile: function () {
this.timeCnt++
var ret = fs.readFile("../../update.txt"); //返回二进制数据
if (this.timeCnt % 4 == 0) {
console.log("From update.txt ret=" + ret);
}
if (ret == 1) {
this.crtText = "检测到TCard";
globalThis.factoryTest.tcard = 1
this.$setBackgroundColor("id_reset", 0x00ff00)
}
else {
this.crtText = "未检测到TCard";
globalThis.factoryTest.tcard = 2
this.$setBackgroundColor("id_reset", 0xff0000)
}
},
clearTimer: function () {
this.$clearInterval(this.readFileId);
},
/*************** connect ***************/
/*************** event ***************/
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
touchedOK: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
this.returnResult()
// rd190_factory.pwm(1)
},
touchedNG: function (node, topnode, x, y) {
console.log("Enable:" + this.index);
this.returnResult()
// rd190_factory.pwm(1)
},
returnResult: function () {
// rd190_factory.pwm(0)
router.push({
path: "factory_testList"
});
}
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 800;
height: 480;
background-color: gray;
}
/*********************************/
.chooseBlock {
width: 240;
height: 160;
border-radius: 5;
border-width: 2;
border-color: white;
background-color: gainsboro;
}
.cbName {
top: 65;
width: 240;
height: 50;
color: black;
text-align: center;
text-overflow: ellipsis;
background-color: transparent;
font-size: 35;
}
#id_cb1 {
left: 20;
top: 20;
}
#id_cb2 {
left: 280;
top: 20;
}
#id_cb3 {
left: 540;
top: 20;
}
#id_cb4 {
left: 20;
top: 200;
}
#id_cb5 {
left: 280;
top: 200;
}
#id_cb6 {
left: 540;
top: 200;
}
.functionBlock {
width: 320;
height: 100;
color: black;
border-radius: 5;
border-width: 2;
border-color: black;
background-color: gainsboro;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
}
#id_ok {
left: 40;
top: 360;
}
#id_ng {
left: 440;
top: 360;
}
#id_reset {
left: 240;
top: 180;
}
</style>
\ No newline at end of file
<!--结构描述-->
<html>
<!--背景块区域 样式container 点击事件 bgclick-->
<div class="screen">
<text id="wifiInfo">{{crtWifiInfo}}</text>
<text id="wifiStatus">{{crtWifi}}</text>
<text id="wifi_mac" style="font-size: 40; left:0;top: 500; width: 700; height: 500; text-align: center;">{{wifi_mac}}</text>
</div>
</html>
<!--功能描述-->
<script>
//接口声明 使用路由功能模块
var router = require("@system.router");
// var libwifi = require("factory_wifi.js");
var file = require("file.js");
var macGetId = null;
//写入内容与操作
export default {
//数据写入 变量pagetitle 类型字符串 内容“页0”
data: {
crtWifi: "Start testing wifi connect...",
crtWifiInfo: "",
wifi_mac: ""
},
onShow: function () {
var mac = null;
// var mac = libwifi.getWifiMac();
this.wifi_mac = "mac:"+mac;
console.log(this.$uri + "===========onShow=============");
this.crtWifi = "Start testing wifi connect...";
this.SSID = "re832b_test 12345678";
this.crtWifiInfo = "Scan..." + this.SSID;
this.wifiFlag = 0;
this.signal = -61;
this.shortDelayId = this.$setTimeout(this.shortDelay, 200, [], this);
},
clearTimer: function () {
this.$clearTimeout(this.shortDelayId);
this.$clearTimeout(this.okShortDelayId);
this.$clearTimeout(this.ngShortDelayId);
this.$clearTimeout(this.backtoListId);
this.autotestnum = 1;
},
onHide: function () {
console.log(this.$uri + "===========onHide=============");
this.clearTimer();
},
onQuit: function () {
console.log(this.$uri + "===========onQuit=============");
this.clearTimer();
},
shortDelay: function () {
var ret = 0;
// ret = libwifi.testWifiConnect("testWifi", this.SSID);
this.wifiFlag = ret;
// ret = globalThis.factoryTest.wifi;
console.log('ret===' + ret);
var signal = null;
// var signal = libwifi.testWifiConnect("getSignal", this.SSID); //返回十进制数据
if (signal != undefined) {
this.signal = signal;
}
console.log('this.signal===' + this.signal);
var result = 0;
if (ret == 1 && (this.signal >= -60 && this.signal != undefined)) {
result = 1;
console.log('result===' + result);
}
if (result == 1) {
this.okShortDelayId = this.$setTimeout(this.okShortDelay, 500, [], this);
} else {
this.ngShortDelayId = this.$setTimeout(this.ngShortDelay, 500, [], this);
}
this.$clearTimeout(this.shortDelayId);
},
backtoList: function () {
router.push({
path: "factory_testList",
});
this.$clearTimeout(this.backtoListId);
},
okShortDelay: function () {
globalThis.factoryTest.wifi = 1;
this.crtWifiInfo = this.SSID + " || " + this.signal;
this.crtWifi = "Wifi Connection Successful!";
this.$clearTimeout(this.okShortDelayId);
this.backtoListId = this.$setTimeout(this.backtoList, 1000, [], this);
},
ngShortDelay: function () {
globalThis.factoryTest.wifi = 2;
if (this.wifiFlag != 1) {
this.crtWifiInfo = "Not Found " + this.SSID;
}
else {
this.crtWifiInfo = this.SSID + " || " + this.signal;
}
this.crtWifi = "Wifi Connection Failed!";
this.$clearTimeout(this.ngShortDelayId);
this.backtoListId = this.$setTimeout(this.backtoList, 1000, [], this);
},
saveValue: function () {
var color = globalThis.factoryTest.color;
var touch = globalThis.factoryTest.touch;
var wifi = globalThis.factoryTest.wifi;
var tcard = globalThis.factoryTest.tcard;
var serial = globalThis.factoryTest.serial;
var serialNG = globalThis.factoryTest.serialNG;
var rtcTimes = globalThis.factoryTest.rtcTimes;
var beepLT = globalThis.factoryTest.beepLT;
var encoder = globalThis.factoryTest.encoder;
var rtc = globalThis.factoryTest.rtc;
var bgLight = globalThis.factoryTest.bgLight;
var obj = {
color: color,
touch: touch,
wifi: wifi,
tcard: tcard,
serial: serial,
serialNG: serialNG,
rtcTimes: rtcTimes,
beepLT: beepLT,
encoder: encoder,
rtc: rtc,
// "bgLight": bgLight,
};
console.log(obj);
file.write("product_res.json", obj);
},
};
</script>
<!--样式描述-->
<style>
/*背景块的样式*/
.screen {
width: 1280;
height: 1280;
background-color: black;
}
#wifiInfo {
left: 0;
top: 128;
width: 720;
height: 150;
font-size: 44;
color: white;
text-align: center;
/* text-overflow: ellipsis; */
}
#wifiStatus {
left: 0;
top: 240;
width: 720;
height: 60;
font-size: 44;
color: white;
text-align: center;
/* text-overflow: ellipsis; */
}
.class_msg {
top: 240;
width: 250;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 50;
color: red;
background-color: gainsboro;
}
#id_ok {
left: 75;
}
#id_ng {
left: 475;
}
</style>
\ No newline at end of file
<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>
<text class="fontsize60" id="title_TEXT"
style="left:0;top: 10;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title_TEXT }}</text>
<text class="fontsize60" id="title2_TEXT"
style="left:0;top: 640;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title2_TEXT }}</text>
<text class="fontsize40" id="data_TEXT"
style="left:0;top: 80;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
data_TEXT }}</text>
<text class="fontsize40" id="author_TEXT"
style="left:0;top: 710;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
author_TEXT }}</text>
<div id="exit" style="width: 300;height: 80;left:200;top:1180;background-color: blue; border-radius: 10px;"
onclick="exit">
<text class="fontsize60" id="exit_TEXT"
style="width: 300;height: 80;text-align: center; background-color: transparent;color: white;">{{
exit_TEXT }}</text>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
// var lib = require("factory_fiveInch.js");
var macGetId = null;
var qosGetId = null;
// var pageInterval = null;
export default {
data: {
title_TEXT: "E-SIM信息",
title2_TEXT: "ICCID",
data_TEXT: "NC",
author_TEXT: "NC",
exit_TEXT: "退出",
},
onInit() {
},
onShow: function () {
this.checkCnt = 0;
// lib.start();
if (macGetId != null) {
clearInterval(macGetId);
macGetId = null;
}
macGetId = setInterval(() => {
// this.author_TEXT = lib.read("data");
}, 200);
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
qosGetId = setInterval(() => {
// this.data_TEXT = lib.read("author");
}, 200);
},
exit: function (node, topNode, x, y) {
this.exitEvent();
},
exitEvent: function () {
if (macGetId != null) {
clearTimeout(macGetId);
macGetId = null;
}
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
// lib.close();
router.push({
path: 'factory_testList'
})
},
};
</script>
<style>
.screen {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.trueActiveDiv {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.gifIcon {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.fontsize60 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: #ffffff;
background-color: transparent;
}
.fontsize40 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
color: #ffffff;
background-color: transparent;
}
</style>
\ No newline at end of file
<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>
<text class="fontsize60" id="title_TEXT"
style="left:0;top: 10;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title_TEXT }}</text>
<text class="fontsize60" id="title2_TEXT"
style="left:0;top: 640;width: 728;height: 1280;text-align: center; background-color: transparent;color: blue;">{{
title2_TEXT }}</text>
<text class="fontsize40" id="imei_TEXT"
style="left:0;top: 80;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
imei_TEXT }}</text>
<text class="fontsize40" id="data_TEXT"
style="left:0;top: 710;width: 728;height: 1280;text-align: center; background-color: transparent;color: white;">{{
data_TEXT }}</text>
<div id="exit" style="width: 300;height: 80;left:200;top:1180;background-color: blue; border-radius: 10px;"
onclick="exit">
<text class="fontsize60" id="exit_TEXT"
style="width: 300;height: 80;text-align: center; background-color: transparent;color: white;">{{
exit_TEXT }}</text>
</div>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
// var lib = require("factory_testlte.js");
var macGetId = null;
var qosGetId = null;
// var pageInterval = null;
export default {
data: {
title_TEXT: "4G信息",
title2_TEXT: "IMEI",
imei_TEXT: "NC",
data_TEXT: "NC",
exit_TEXT: "退出",
},
onInit() {
},
onShow: function () {
// lib.start();
if (macGetId != null) {
clearInterval(macGetId);
macGetId = null;
}
macGetId = setInterval(() => {
// this.data_TEXT =lib.read("data");
}, 200);
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
qosGetId = setInterval(() => {
// this.imei_TEXT = lib.read("imei");
}, 200);
},
exit: function (node, topNode, x, y) {
this.exitEvent();
},
exitEvent: function () {
if (macGetId != null) {
clearTimeout(macGetId);
macGetId = null;
}
if (qosGetId != null) {
clearInterval(qosGetId);
qosGetId = null
}
// lib.close();
router.push({
path: 'factory_testList'
})
},
};
</script>
<style>
.screen {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.trueActiveDiv {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.gifIcon {
width: 728;
height: 1280;
background-color: black;
color: black;
}
.fontsize60 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: #ffffff;
background-color: transparent;
}
.fontsize40 {
width: 728;
height: 1280;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
color: #ffffff;
background-color: transparent;
}
</style>
\ No newline at end of file
//var ShowLog = 1;
function O(target, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function X(target, leftKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'left',
'from': leftKeyFrame[0],
'to': leftKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function Y(target, topKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function XO(target, leftKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'left',
'from': leftKeyFrame[0],
'to': leftKeyFrame[1]
}, {
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function YO(target, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}, {
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function XY(target, leftKeyFrame, topKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'left',
'from': leftKeyFrame[0],
'to': leftKeyFrame[1]
}, {
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function XYO(target, leftKeyFrame, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'left',
'from': leftKeyFrame[0],
'to': leftKeyFrame[1]
}, {
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}, {
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function XYOZ(target, leftKeyFrame, topKeyFrame, opacityKeyFrame, zoomKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'left',
'from': leftKeyFrame[0],
'to': leftKeyFrame[1]
}, {
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}, {
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}, {
'property': 'zoom',
'from': zoomKeyFrame[0],
'to': zoomKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function OZ(target, opacityKeyFrame, zoomKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'opacity',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}, {
'property': 'zoom',
'from': zoomKeyFrame[0],
'to': zoomKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
})
}
/******************************/
function freeuse_1(target, KeyFrame, timeKeyFrame, timing_function, count, direction, callback, area) {
/*console.log(ShowLog);
if (ShowLog)
{
console.log(target + " will use " + KeyFrame[0] + " from " + KeyFrame[1] + " to " + KeyFrame[2] + ",keep " + timeKeyFrame[0] + "ms and delay " + timeKeyFrame[1] + "ms,by " +
timing_function + " loop " + count + " times on " + direction + " direction,handle the " + callback + ".");
}*/
area.$anime({
'target': target,
'keyframes': [{
'property': KeyFrame[0],
'from': KeyFrame[1],
'to': KeyFrame[2]
}],
'duration': timeKeyFrame[0],
'delay': timeKeyFrame[1],
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function freeuse_2(target, KeyFrame1, KeyFrame2, timeKeyFrame, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': KeyFrame1[0],
'from': KeyFrame1[1],
'to': KeyFrame1[2]
}, {
'property': KeyFrame2[0],
'from': KeyFrame2[1],
'to': KeyFrame2[2]
}],
'duration': timeKeyFrame[0],
'delay': timeKeyFrame[1],
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function freeuse_3(target, KeyFrame1, KeyFrame2, KeyFrame3, timeKeyFrame, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': KeyFrame1[0],
'from': KeyFrame1[1],
'to': KeyFrame1[2]
}, {
'property': KeyFrame2[0],
'from': KeyFrame2[1],
'to': KeyFrame2[2]
}, {
'property': KeyFrame3[0],
'from': KeyFrame3[1],
'to': KeyFrame3[2]
}],
'duration': timeKeyFrame[0],
'delay': timeKeyFrame[1],
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
function freeuse_4(target, KeyFrame1, KeyFrame2, KeyFrame3, KeyFrame4, timeKeyFrame, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': KeyFrame1[0],
'from': KeyFrame1[1],
'to': KeyFrame1[2]
}, {
'property': KeyFrame2[0],
'from': KeyFrame2[1],
'to': KeyFrame2[2]
}, {
'property': KeyFrame3[0],
'from': KeyFrame3[1],
'to': KeyFrame3[2]
}, {
'property': KeyFrame4[0],
'from': KeyFrame4[1],
'to': KeyFrame4[2]
}],
'duration': timeKeyFrame[0],
'delay': timeKeyFrame[1],
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
/***************** breath *****************/
function breath(target, freq, area) {
var breathTime = 60000 / freq;
area.$anime({
'target': target,
'keyframes': [{
'property': 'opacity',
'from': 158,
'to': 255
}],
'duration': breathTime,
'delay': 0,
'timing-function': "linear",
'iteration-count': "infinite",
'direction': "alternate"
});
}
function deepBreath(target, freq, area) {
var breathTime = 60000 / freq;
area.$anime({
'target': target,
'keyframes': [{
'property': 'opacity',
'from': 97,
'to': 255
}],
'duration': breathTime,
'delay': 0,
'timing-function': "linear",
'iteration-count': "infinite",
'direction': "alternate"
});
}
function fullBreath(target, freq, area) {
var breathTime = 60000 / freq;
area.$anime({
'target': target,
'keyframes': [{
'property': 'opacity',
'from': 0,
'to': 255
}],
'duration': breathTime,
'delay': 0,
'timing-function': "linear",
'iteration-count': "infinite",
'direction': "alternate"
});
}
function textMove(target, topKeyFrame, opacityKeyFrame, duration, delay, timing_function, count, direction, callback, area) {
area.$anime({
'target': target,
'keyframes': [{
'property': 'top',
'from': topKeyFrame[0],
'to': topKeyFrame[1]
}, {
'property': 'left',
'from': opacityKeyFrame[0],
'to': opacityKeyFrame[1]
}],
'duration': duration,
'delay': delay,
'timing-function': timing_function,
'iteration-count': count,
'direction': direction,
'end-callback': callback
});
}
module.exports = {
O: O,
X: X,
Y: Y,
OZ: OZ,
XO: XO,
YO: YO,
XY: XY,
XYO: XYO,
XYOZ: XYOZ,
freeuse_1: freeuse_1,
freeuse_2: freeuse_2,
freeuse_3: freeuse_3,
freeuse_4: freeuse_4,
breath: breath,
deepBreath: deepBreath,
fullBeath: fullBreath,
textMove: textMove,
}
\ No newline at end of file
var systemCtrl = require("factory_systemCtrl.js");
var egenmd5 = require("factory_egenmd5.js");
var process = require("@system.process");
/**
* 提取文件路径中的名称(含扩展名)
* @param {string} path 文件的相对路径(如 "src/file.txt" 或 "data.json")
* @returns {string} 文件名(如 "file.txt")
*/
function getFileName(path) {
// 处理路径末尾的冗余斜杠(如 "docs/" → "docs")
const trimmedPath = path.endsWith('/') ? path.slice(0, -1) : path;
// 分割路径并取最后一段
return trimmedPath.split('/').pop();
}
function create(name) {
var fs = require("@system.fs")
var ret = 0
var obj = {
"create": 0
}
// 获取文件名
var filenm = getFileName(name)
if (process.platform == "win32") {
ret = fs.writeFile(filenm, JSON.stringify(obj));
} else {
//构造相对路径
var partAFilePath = "../../../../../mnt/userdataA/files/" + filenm
var partBFilePath = "../../../../../mnt/userdataB/files/" + filenm
// 获取绝对路径
var partAFilePath_abs = "/mnt/userdataA/files/" + filenm
var partBFilePath_abs = "/mnt/userdataB/files/" + filenm
//写A区文件
ret = fs.writeFile(partAFilePath, JSON.stringify(obj));
systemCtrl.executeSystemCommand("fsync " + partAFilePath_abs);
egenmd5.update("/mnt/userdataA/files", "/mnt/userdataA/userdata.md5");
//写B区文件
ret = fs.writeFile(partBFilePath, JSON.stringify(obj));
systemCtrl.executeSystemCommand("fsync " + partBFilePath_abs);
egenmd5.update("/mnt/userdataB/files", "/mnt/userdataB/userdata.md5");
}
if (ret == 0) {
console.log(name + " Created Successfully.")
} else {
console.log(name + " Created Failed")
console.log("create ErrorCode:" + ret)
}
}
function write(name, obj) {
var fs = require("@system.fs")
// 新增参数校验逻辑
if (typeof obj === 'undefined' || obj === null || obj === "") {
console.log("Error: Invalid input object");
return;
}
let tempStr;
if (typeof obj === 'string') {
tempStr = obj;
} else {
try {
tempStr = JSON.stringify(obj);
} catch (e) {
console.log("Error: Object serialization failed");
return;
}
}
// console.log(obj)
// 获取文件名
var filenm = getFileName(name)
if (process.platform == "win32") {
ret = fs.writeFile(filenm, JSON.stringify(obj));
} else {
//构造相对路径
var partAFilePath = "../../../../../mnt/userdataA/files/" + filenm
var partBFilePath = "../../../../../mnt/userdataB/files/" + filenm
// 获取绝对路径
var partAFilePath_abs = "/mnt/userdataA/files/" + filenm
var partBFilePath_abs = "/mnt/userdataB/files/" + filenm
//写A区文件
var ret = fs.writeFile(partAFilePath, tempStr);
systemCtrl.executeSystemCommand("fsync " + partAFilePath_abs);
egenmd5.update("/mnt/userdataA/files", "/mnt/userdataA/userdata.md5");
//写B区文件
var ret = fs.writeFile(partBFilePath, tempStr);
systemCtrl.executeSystemCommand("fsync " + partBFilePath_abs);
egenmd5.update("/mnt/userdataB/files", "/mnt/userdataB/userdata.md5");
}
if (ret == 0) {
console.log(name + " write Successfully.")
} else {
console.log(name + " write Failed")
console.log("write ErrorCode:" + ret)
}
}
function check(name, obj) {
var fs = require("@system.fs")
var filenm = getFileName(name)
//构造相对路径
if (process.platform == "win32") {
var partFilePath = "./" + filenm
} else {
var partFilePath = "../../../../../mnt/userdataA/files/" + filenm
}
if (fs.exists(partFilePath)) {
console.log("the " + name + " is exists.")
return 0
} else {
return -1
}
}
function read(name, mode) {
var fs = require("@system.fs")
console.log("In Read function name is :" + name)
var filenm = getFileName(name)
//构造相对路径
if (process.platform == "win32") {
var partFilePath = "./" + filenm
} else {
var partFilePath = "../../../../../mnt/userdataA/files/" + filenm
}
if (check(partFilePath)) {
return undefined
}
console.log("In Read function path is :" + partFilePath);
if (mode == "json") {
var ret = fs.readFile(partFilePath, "r")
var data = JSON.parse(ret)
} else {
var ret = fs.readFile(partFilePath, "rb")
var data = ret
}
console.log(data)
return data
}
function checkBasicPath(name, obj) {
var fs = require("@system.fs")
if (fs.exists(name)) {
console.log("the " + name + " is exists.")
return 0
} else {
return -1
}
}
function readBasicPath(name, mode) {
var fs = require("@system.fs")
console.log("In readBasicPath name = " + name)
console.log("In readBasicPath mode = " + mode)
console.log("In readBasicPath checkBasicPath(name) = " + checkBasicPath(name))
if (checkBasicPath(name)) {
return undefined
}
if (mode == "json") {
var ret = fs.readFile(name, "r")
var data = JSON.parse(ret)
} else {
var ret = fs.readFile(name, "rb")
var data = ret
}
return data
}
module.exports = {
check: check,
create: create,
read: read,
write: write,
readBasicPath: readBasicPath,
}
var _userdata = require("userdata.js");
var userData = _userdata.userData;
const fs = require("@system.fs")
var systemCtrl = require("systemCtrl.js");
var resultsWifiList = undefined;
function parseWifiScanResults(output) {
const lines = output.split('\n');
const results = [];
// 从第三行开始解析(跳过前两行标题)
for (let i = 2; i < lines.length; i++) {
const line = lines[i].trim();
if (!line) continue; // 跳过空行
// 按多个空格分割行
const parts = line.split(/\s+/).filter(part => part !== '');
if (parts.length >= 4) {
const signalLevel = parseInt(parts[2]); // 信号强度在第3列
let ssid = parts.slice(4).join(' '); // SSID 在第5列及之后(可能包含空格)
const flags = parts[3]; // 加密标志在第4列
const isEncrypted = !flags.includes("[ESS]") ||
flags.includes("WPA") ||
flags.includes("WEP") ||
flags.includes("PSK");
results.push({
ssid: ssid || '', // 如果 SSID 为空,则设为空字符串
signalLevel: signalLevel,
isEncrypted: isEncrypted
});
}
}
return results;
}
var wlan_enalbed = userData.enableWLANSwitchFlag
// const generalSettingPage = proxy.indexObj.getPage("generalSetting");
var wifi_div = undefined;
var wifi_list_div = undefined;
// this.proxy = proxy;
// this.pageObj = proxy.indexObj.getPage("generalSetting");
// var that = this;
// proxy.on("onEnableWLANSwitch", function () {
function connect_wifi(ssid, psk) {
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 ssid \'\"" + ssid + "\"\'")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 psk \'\"" + psk + "\"\'")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 save_config")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 reconfigure")
//启动wpa_supplicant进程
systemCtrl.executeSystemCommand("usleep 200000") //200ms 用于缓冲设置和执行
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 disable_network 0")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 enable_network 0")
systemCtrl.executeSystemCommand("usleep 500000") //500ms 用于缓冲联网状态
//启动udhcpc
systemCtrl.executeSystemCommand("udhcpc -b -i wlan0 -t 1 -A 1 -R -H test")
}
function diConnectWifi() {
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 disable_network 0")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 remove_network 0")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 save_config")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 reconfigure")
systemCtrl.executeSystemCommand("usleep 200000") // 200ms 用于缓冲设置和执行
systemCtrl.executeSystemCommand("killall -9 udhcpc") // 停止 udhcpc
}
function WifiNoActive() {
console.log("=====WifiNoActive=====");
userData.wlanSsid = null;
userData.wlanSignalLevel = 0;
userData.wlanPassword = null;
that.pageObj.$setY("id_enableWLANListArea0", -800);
that.pageObj.$setY("wifiListItem", 0);
that.pageObj.$setY("id_wifiListItem_Text", -800);
that.pageObj.$setY("id_wifiListItem_xLine", -800);
systemCtrl.executeSystemCommand("ifconfig wlan0 down")
}
function refreshWifiList(wifi_list) {
var enableWLANListItemSearchDiv = document.getElementById('id_enableWLANListItemSearchDiv')
if (!enableWLANListItemSearchDiv)
return
if (!wifi_div) {
wifi_div = document.createElement('div', {
top: 0,
left: 0,
width: 420,
}, enableWLANListItemSearchDiv)
}
console.log("=====refreshWifiListlog=====1");
// if (wifi_list_div) {
// wifi_div.removeChild(wifi_list_div)
// }
wifi_list_div = document.createElement('div', {
top: 0,
left: 0,
width: 420,
"background-color": "#000000",
}, wifi_div)
console.log("=====refreshWifiListlog=====2");
var top = 0;
for (var i = 0; i < wifi_list.length; i++) {
// if (wifi_list[i].ssid == userData.wlanSsid) {
// continue;
// }
var ssid = wifi_list[i].ssid
var signalLevel = wifi_list[i].signalLevel
var isEncrypted = wifi_list[i].isEncrypted
if (ssid.length == 0)
continue
var process = require("@system.process");
if (process.platform == "win32") {
if (signalLevel > -50) {
var src = './../re860a-v1.0/images/main/wifiSignalLevel3.png'
} else if (signalLevel <= -50 && signalLevel > -70) {
var src = './../re860a-v1.0/images/main/wifiSignalLevel2.png'
} else {
var src = './../re860a-v1.0/images/main/wifiSignalLevel1.png'
}
}
else {
if (signalLevel > -50) {
var src = './../RE860A/images/main/wifiSignalLevel3.png'
} else if (signalLevel <= -50 && signalLevel > -70) {
var src = './../RE860A/images/main/wifiSignalLevel2.png'
} else {
var src = './../RE860A/images/main/wifiSignalLevel1.png'
}
}
var chooseAreaDiv = document.createElement('div', {
top: top,
left: 20,
width: 460,
height: 66,
}, wifi_list_div)
document.createElement('text', {
top: 14,
left: 50,
width: 420,
height: 50,
"text-align": "left",
"font-size": 22,
"color": "white",
'text-overflow': "ellipsis",
"background-color": "transparent",
"text": ssid+"("+signalLevel+" dBm)",
"signalValue": signalLevel,
"events": {
onclick: function (node, topNode, x, y) {
// node.attributes.text = "selected";
systemCtrl.executeSystemCommand("/mnt/app/quicknode/shell/eAplay.sh /mnt/app/voice_click.wav");
console.log("node.attributes.text = " + this.attributes.text);
console.log("click wlan_list_item"); //需要添加一个点击事件
proxy.emit("onGotoWlanEnterPasswordPage", this.attributes.text, this.attributes.signalValue);
}
}
}, chooseAreaDiv)
document.createElement('div', {
top: 65,
left: 8,
width: 464,
height: 1,
opactity: 1,
"background-color": "#999999",
}, chooseAreaDiv)
// if (isEncrypted) {
// document.createElement('img', {
// top: 20,
// left: 363,
// width: 21,
// height: 26,
// src: "./images/settings/connecteWlanLockedPng.png",
// }, chooseAreaDiv)
// }
document.createElement('img', {
top: 14,
left: 8,
width: 38,
height: 38,
src: src,
}, chooseAreaDiv)
top += 70
}
wifi_list_div.setAttribute('height', top)
wifi_div.setAttribute('height', top)
}
function enableWLANSwitch() {
console.log("Is @@@@@@@@@@@@@@@@@@@@@@@@@@#3333333")
// if (!userData.enableWLANSwitchFlag) {
// return;
// }
systemCtrl.executeSystemCommand("rm -fr /tmp/scan_result.txt")
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets scan")
setTimeout(function () {
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets scan_results > /tmp/scan_result.txt")
var content = fs.read("/tmp/scan_result.txt", "r")
if (content) {
resultsWifiList = parseWifiScanResults(content)
// console.log(JSON.stringify(resultsWifiList))
refreshWifiList(resultsWifiList)
}
}, 5000)
}
function getWifiInfo(ssid) {
console.log("getWifiInfo called with SSID: " + ssid);
if (!resultsWifiList) {
console.log("resultsWifiList is not available.");
return null; // 如果 resultsWifiList 为空,则返回 null
}
// 遍历 resultsWifiList 查找指定 SSID
let foundWifi = null;
for (let i = 0; i < resultsWifiList.length; i++) {
if (resultsWifiList[i].ssid === ssid) {
console.log("Found SSID: " + ssid);
foundWifi = resultsWifiList[i];
break;
}
}
if (!foundWifi) {
console.log("SSID not found: " + ssid);
return {
ssid: ssid,
signalLevel: null, // 信号强度为空
isEncrypted: null, // 加密状态为空
isConnected: false // 未连接
};
}
// 检查当前 WiFi 状态
let isConnected = false;
if (userData.wlanSsid === ssid && userData.enableWLANSwitchFlag === 1) {
isConnected = true;
} else {
// 通过系统命令检查当前 WiFi 状态
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("wpa_state=")) {
const state = line.split('=')[1];
if (state === "COMPLETED") {
isConnected = true;
break;
}
}
}
}
}
return {
ssid: ssid,
signalLevel: foundWifi.signalLevel, // 信号强度
isEncrypted: foundWifi.isEncrypted, // 是否加密
isConnected: isConnected // 是否已连接
};
}
module.exports = {
enableWLANSwitch: enableWLANSwitch,
connect_wifi: connect_wifi,
getWifiInfo: getWifiInfo,
}
\ No newline at end of file
//var ShowLog = 1;
function getCurrentTime() {
//获取当前时间
var d = new Date();
// 获取当前时区与UTC时间的分钟差值
// const offset = d.getTimezoneOffset();
const offset = 0;
var diff_d = d.getTime();
diff_d = diff_d + offset * 60 * 60 * 1000;
var dateT = new Date(diff_d);
//写入数据
var weekName = new Array(
"周日",
"周一",
"周二",
"周三",
"周四",
"周五",
"周六"
);
var dataMonth = dateT.getMonth();
var dataDate = dateT.getDate();
var weekDate = weekName[dateT.getDay()];
dataMonth += 1;
var tempstr1 = dataMonth + "/" + dataDate + " " + weekDate;
// var hourdata = dateT.getUTCHours();
// var secondData = dateT.getSeconds();
var hourdata = "";
var minutedata = "";
var secondData = "";
// if (dateT.getUTCHours() < 10) hourdata = "0" + dateT.getUTCHours();
// else if (dateT.getUTCHours() >= 10 && dateT.getUTCHours() <= 24)
// hourdata = dateT.getUTCHours();
console.log("hour=" + dateT.getHours());
hourdata = dateT.getHours().toString().padStart(2, "0");
if (dateT.getMinutes() < 10) minutedata = "0" + dateT.getMinutes();
else if (dateT.getMinutes() >= 10 && dateT.getMinutes() <= 60)
minutedata = dateT.getMinutes();
if (dateT.getSeconds() < 10) secondData = "0" + dateT.getSeconds();
else if (dateT.getSeconds() >= 10 && dateT.getSeconds() <= 60)
secondData = dateT.getSeconds();
//合成字符串
var tempstr2 = "";
// tempstr2 = hourdata + ":" + minutedata;
tempstr2 = hourdata + ":" + minutedata + ":" + secondData;
// console.log("tempstr1=" + tempstr1);
// console.log("tempstr2=" + tempstr2);
tempstr1 = tempstr1 + " " + tempstr2;
// console.log("tempstr1+tempstr2=" + tempstr1);
//更新时间字符串
var obj = {
// "dataHours": dataHours,
// "dataMinutes": dataMinutes,
// "dataSeconds": dataSeconds,
// "dataweekday": tempstr,
// "weekDate": weekDate,
tempstr1: tempstr1,
tempstr2: tempstr2,
};
return tempstr1;
}
// console.log(getCurrentTime());
function setCurrentTime(obj) {
//设置当前时间
//写入数据
var weekName = new Array(
"周日",
"周一",
"周二",
"周三",
"周四",
"周五",
"周六"
);
var dataMonth = obj.mon;
var dataDate = obj.day;
var weekDate = weekName[obj.week];
// dataMonth += 1;
var tempstr1 = dataMonth + " / " + dataDate + " " + weekDate;
var hourdata = "";
var minutedata = "";
var secondData = "";
if (obj.hour < 10) hourdata = "0" + obj.hour;
else hourdata = obj.hour;
if (obj.min < 10) minutedata = "0" + obj.min;
else minutedata = obj.min;
if (obj.sec < 10) secondData = "0" + obj.sec;
else secondData = obj.sec;
//合成字符串
var tempstr2 = "";
tempstr2 = hourdata + ":" + minutedata;
// tempstr2 = hourdata + ":" + minutedata + ":" + secondData;
//更新时间字符串
var obj = {
tempstr1: tempstr1,
tempstr2: tempstr2,
};
return obj;
}
module.exports = {
getCurrentTime: getCurrentTime,
setCurrentTime: setCurrentTime,
};
var _varSpace = require("varSpace.js");
var varSpace = _varSpace.varSpace;
var keyDevice = require("keyDevice.js");
keyDevice.psbInit();
setInterval(doOneSecond, 100)
var keyValue = 0
var crtTime = 0
var longTimeNop = 0
var longTimeNopMax = 60
function checkKeypad() {
var keypadAction = keyDevice.psbGetValue("keypad");
keyDevice.psbClearValue("keypad");
if (keyValue != keypadAction) {
activeScreen()
keyValue = keypadAction
if (keypadAction != 0) {
console.log("keypadAction:" + keypadAction);
doKeyPadMatter(keypadAction);
}
//end
}
}
function activeScreen() {
longTimeNop = crtTime
}
function checkLongTimeNop() {
// console.log("crtTime=" + crtTime + " longTimeNop=" + longTimeNop)
if (crtTime - longTimeNop > longTimeNopMax) {
globalThis.eventEmitter.emit("logicLongTimeNop", "logic-checkLongTimeNop");
}
}
function doOneSecond() {
crtTime++
checkLongTimeNop()
checkKeypad()
}
function doKeyPadMatter(keyValue) {
switch (keyValue) {
case 13: {
globalThis.eventEmitter.emit("logicKeypadTouched1", "logic-doKeyPadMatter");
console.log("No.1 has been pressed.")
break;
}
case 15: {
globalThis.eventEmitter.emit("logicKeypadTouched2", "logic-doKeyPadMatter");
console.log("No.2 has been pressed.")
break;
}
case 17: {
globalThis.eventEmitter.emit("logicKeypadTouched3", "logic-doKeyPadMatter");
console.log("No.3 has been pressed.")
break;
}
default:
break;
}
}
initConnect()
function emitUIDeviceGroupTouched1() {
activeScreen()
varSpace.lightGroup1 = (varSpace.lightGroup1 == 0 ? 1 : 0)
}
function emitUIDeviceGroupTouched2() {
activeScreen()
varSpace.lightGroup2 = (varSpace.lightGroup2 == 0 ? 1 : 0)
}
function emitUIDeviceGroupTouched3() {
activeScreen()
varSpace.lightGroup3 = (varSpace.lightGroup3 == 0 ? 1 : 0)
}
function initConnect() {
globalThis.eventEmitter.on("uiDeviceGroupTouched1", emitUIDeviceGroupTouched1);
globalThis.eventEmitter.on("uiDeviceGroupTouched2", emitUIDeviceGroupTouched2);
globalThis.eventEmitter.on("uiDeviceGroupTouched3", emitUIDeviceGroupTouched3);
}
module.exports = {
activeScreen: activeScreen,
}
// const systemCtrl = require("systemCtrl.js");
const process = require("@system.process");
const rnapi = require('rnapi.js')
var _userdata = require("userdata.js");
var userData = _userdata.userData;
const fs = require("@system.fs")
var systemCtrl = require("systemCtrl.js");
const userdata = require("../logicJS/userdata");
var handleJumpPage = require("handleJumpPage.js");
// const system = rnapi.require('lib/system/build-lib/libsystem.so')
function parseWifiScanResults(output) {
const lines = output.split('\n');
const results = [];
// 从第三行开始解析(跳过前两行标题)
for (let i = 2; i < lines.length; i++) {
const line = lines[i].trim();
if (!line) continue; // 跳过空行
// 按多个空格分割行
const parts = line.split(/\s+/).filter(part => part !== '');
if (parts.length >= 4) {
const signalLevel = parseInt(parts[2]); // 信号强度在第3列
let ssid = parts.slice(4).join(' '); // SSID 在第5列及之后(可能包含空格)
const flags = parts[3]; // 加密标志在第4列
const isEncrypted = !flags.includes("[ESS]") ||
flags.includes("WPA") ||
flags.includes("WEP") ||
flags.includes("PSK");
results.push({
ssid: ssid || '', // 如果 SSID 为空,则设为空字符串
signalLevel: signalLevel,
isEncrypted: isEncrypted
});
}
}
return results;
}
function Wlan(proxy) {
var wlan_enalbed = userData.enableWLANSwitchFlag
const generalSettingPage = proxy.indexObj.getPage("generalSetting");
var wifi_div = undefined;
var wifi_list_div = undefined;
this.proxy = proxy;
this.pageObj = proxy.indexObj.getPage("generalSetting");
var that = this;
function refreshWifiList(wifi_list) {
var enableWLANListItemSearchDiv = generalSettingPage.$getElementById('id_enableWLANListItemSearchDiv')
if (!enableWLANListItemSearchDiv)
return
if (!wifi_div) {
wifi_div = document.createElement('div', {
top: 0,
left: 0,
width: 480,
}, enableWLANListItemSearchDiv)
}
// if (wifi_list_div) {
// wifi_div.removeChild(wifi_list_div)
// }
wifi_list_div = document.createElement('div', {
top: 0,
left: 0,
width: 480,
}, wifi_div)
var top = 0;
for (var i = 0; i < wifi_list.length; i++) {
if (wifi_list[i].ssid == userData.wlanSsid) {
continue;
}
var ssid = wifi_list[i].ssid
var signalLevel = wifi_list[i].signalLevel
var isEncrypted = wifi_list[i].isEncrypted
if (ssid.length == 0)
continue
if (signalLevel > -50) {
var src = 'images/main/wifiSignalLevel3.png'
} else if (signalLevel <= -50 && signalLevel > -70) {
var src = 'images/main/wifiSignalLevel2.png'
} else {
var src = 'images/main/wifiSignalLevel1.png'
}
var chooseAreaDiv = document.createElement('div', {
top: top,
left: 20,
width: 460,
height: 66,
}, wifi_list_div)
document.createElement('text', {
top: 14,
left: 8,
width: 480,
height: 50,
"text-align": "left",
"font-size": 22,
"color": "white",
'text-overflow': "ellipsis",
"background-color": "transparent",
"text": ssid,
"signalValue": signalLevel,
"events": {
onclick: function (node, topNode, x, y) {
// node.attributes.text = "selected";
systemCtrl.executeSystemCommand("/mnt/app/quicknode/shell/eAplay.sh /mnt/app/voice_click.wav");
console.log("node.attributes.text = " + this.attributes.text);
console.log("click wlan_list_item"); //需要添加一个点击事件
proxy.emit("onGotoWlanEnterPasswordPage", this.attributes.text, this.attributes.signalValue);
}
}
}, chooseAreaDiv)
document.createElement('div', {
top: 65,
left: 8,
width: 464,
height: 1,
opactity: 1,
"background-color": "#999999",
}, chooseAreaDiv)
if (isEncrypted) {
document.createElement('img', {
top: 20,
left: 363,
width: 21,
height: 26,
src: "./images/settings/connecteWlanLockedPng.png",
}, chooseAreaDiv)
}
document.createElement('img', {
top: 14,
left: 392,
width: 38,
height: 38,
src: src,
}, chooseAreaDiv)
top += 70
}
wifi_list_div.setAttribute('height', top)
wifi_div.setAttribute('height', top)
}
refreshWifiList([]);
proxy.on("onEnableWLANSwitch", function () {
console.debug("Is @@@@@@@@@@@@@@@@@@@@@@@@@@#3333333")
if (!userData.enableWLANSwitchFlag) {
return;
}
if (wifi_list_div) {
wifi_div.removeChild(wifi_list_div)
}
// if (userData.wlanEnalbed)
// if (wlan_enalbed) {
// if (process.platform == "win32") {
// systemCtrl.executeSystemCommand("wpa_cli scan")
systemCtrl.executeSystemCommand("rm -fr /tmp/scan_result.txt")
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets scan")
setTimeout(function () {
// systemCtrl.executeSystemCommand("wpa_cli scan_results > /tmp/scan_result.txt")
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets scan_results > /tmp/scan_result.txt")
var content = fs.read("/tmp/scan_result.txt", "r")
if (content) {
var results = parseWifiScanResults(content)
console.debug(JSON.stringify(results))
refreshWifiList(results)
}
}, 5000)
// }
// }
})
function connect_wifi(ssid, psk) {
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 ssid \'\"" + ssid + "\"\'")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 set_network 0 psk \'\"" + psk + "\"\'")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 save_config")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 reconfigure")
//启动wpa_supplicant进程
systemCtrl.executeSystemCommand("usleep 200000") //200ms 用于缓冲设置和执行
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 disable_network 0")
systemCtrl.executeSystemCommand("usleep 10000") //10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 enable_network 0")
systemCtrl.executeSystemCommand("usleep 500000") //500ms 用于缓冲联网状态
//启动udhcpc
systemCtrl.executeSystemCommand("udhcpc -b -i wlan0 -t 1 -A 1 -R -H test")
}
function diConnectWifi() {
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 disable_network 0")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 remove_network 0")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 save_config")
systemCtrl.executeSystemCommand("usleep 10000") // 10ms 用于缓冲
systemCtrl.executeSystemCommand("wpa_cli -p /tmp/wpa_supplicant/sockets -i wlan0 reconfigure")
systemCtrl.executeSystemCommand("usleep 200000") // 200ms 用于缓冲设置和执行
systemCtrl.executeSystemCommand("killall -9 udhcpc") // 停止 udhcpc
}
function WifiNoActive() {
console.debug("=====WifiNoActive=====");
userData.wlanSsid = null;
userData.wlanSignalLevel = 0;
userData.wlanPassword = null;
that.pageObj.$setY("id_enableWLANListArea0", -800);
that.pageObj.$setY("wifiListItem", 0);
that.pageObj.$setY("id_wifiListItem_Text", -800);
that.pageObj.$setY("id_wifiListItem_xLine", -800);
systemCtrl.executeSystemCommand("ifconfig wlan0 down")
}
proxy.on("onEnableWLANSwitchClick", function () {
console.debug("onEnableWLANSwitchClick")
if (userData.enableWLANSwitchFlag == 0) {
userData.enableWLANSwitchFlag = 1;
systemCtrl.executeSystemCommand("ifconfig wlan0 up")
if (userData.wlanSsid != null) {
console.debug("userData.wlanSsid :" + userData.wlanSsid + "userData.wlanPassword :" + userData.wlanPassword + "---> reload wifi");
connect_wifi(userData.wlanSsid, userData.wlanPassword);
}
that.pageObj.refreshEnableWLANSwitchState(userData.enableWLANSwitchFlag);
//判断文件是否有ssid ,如果有开启onGotoWlanEnterPasswordPage
} else {
userData.enableWLANSwitchFlag = 0;
// diConnectWifi();
WifiNoActive();
}
that.pageObj.refreshEnableWLANSwitchState(userData.enableWLANSwitchFlag);
})
}
module.exports = {
Wlan: Wlan
}
\ No newline at end of file
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["changeBgLight", "iii"],
];
console.log("in factory_bglight.js")
function register() {
console.log("will register bglight.so")
var isSuccess = dlfcn.register("@native.bglight", "./lib/factory/bglight.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var bglight = require("@native.bglight");
return bglight
} else {
console.log("load so failed")
}
return undefined;
}
var bglight = register();
function changeBgLight(value) {
console.log("Change the screen bglight to the highest!")
// bglight.changeBgLight(2, value)
}
// function pwmInit() {
// if (globalThis.Simu.En == 1) {
// return 0
// }
// bglight.pwmInit()
// }
// function pwm(val) {
// console.log("pwm:" + val)
// if (globalThis.Simu.En == 1) {
// return 0
// }
// if (val == 0) {
// bglight.pwmOff()
// }
// if (val == 1) {
// bglight.pwmLv1()
// bglight.pwmOn()
// }
// if (val == 2) {
// bglight.pwmLv2()
// bglight.pwmOn()
// }
// if (val == 3) {
// bglight.pwmLv3()
// bglight.pwmOn()
// }
// if (val == 4) {
// bglight.pwmLv4()
// bglight.pwmOn()
// }
// if (val == 5) {
// bglight.pwmLv5()
// bglight.pwmOn()
// }
// if (val == 6) {
// bglight.pwmLv6()
// bglight.pwmOn()
// }
// }
module.exports = {
changeBgLight: changeBgLight,
// pwmInit: pwmInit,
// pwm: pwm,
}
\ No newline at end of file
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["get_ble_mac_address", "ss"],
];
console.log("in factory_bleInfo.js")
function register() {
console.log("will register test_ble.so")
var isSuccess = dlfcn.register("@native.test_ble", "./lib/factory/test_ble.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var test_ble = require("@native.test_ble");
return test_ble
} else {
console.log("load so failed")
}
return undefined;
}
var test_ble = register();
function read(option) {
// option -> "mac" // return "78:22:88:7B:65:3F"
// option -> "qos" // return "11"
// return test_ble.read(option);
console.log("will read ble info")
var mac = undefined;
try {
mac = test_ble.get_ble_mac_address();
} catch (e) {
mac = undefined
console.log("!!!ERROR:" + e)
}
// console.log("mac: " + mac)
return mac;
}
module.exports = {
read: read,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn);
var funcs = [["generate_md5_for_directory", "vss"]];
console.log("in factory_egenmd5.js");
function register() {
console.log("will register saveData process.platform=" + process.platform)
if (process.platform == "win32") {
console.log("***will register win32_register_func*****")
const Win32RegFunc = require("win32_register_func.js").Win32RegFunc;
var win32Reg = new Win32RegFunc(funcs);
return win32Reg;
}
console.log("will register egenmd5.so");
var isSuccess = dlfcn.register(
"@native.egenmd5",
"./lib/factory/egenmd5.so",
funcs
);
if (isSuccess) {
console.log("load so successfully");
var egenmd5 = require("@native.egenmd5");
return egenmd5;
} else {
console.log("load so failed");
}
return undefined;
}
var egenmd5 = register();
function update(filepath,md5path) {
egenmd5.generate_md5_for_directory(filepath,md5path);
}
module.exports = {
update: update,
};
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["get_modem_signal", "ss"],
["get_modem_iccid", "ss"],
["get_modem_imei", "ss"],
];
console.log("in factory_esim.js")
function register() {
console.log("will register test_modem.so")
var isSuccess = dlfcn.register("@native.test_modem", "./lib/factory/test_modem.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var test_modem = require("@native.test_modem");
return test_modem
} else {
console.log("load so failed")
}
return undefined;
}
var test_modem = register();
function read(option) {
var value;
switch (option) {
case "signal":
try {
value = test_modem.get_modem_signal();
} catch (e) {
value = undefined
console.log("!!!ERROR:" + e)
}
break;
case "iccid":
try {
value = test_modem.get_modem_iccid();
} catch (e) {
value = undefined
console.log("!!!ERROR:" + e)
}
break;
case "imei":
try {
value = test_modem.get_modem_imei();
} catch (e) {
value = undefined
console.log("!!!ERROR:" + e)
}
break;
default:
break;
}
console.log("....");
console.log("============" + "read" + option + "/// value:" + value + "============");
console.log("....");
return value;
}
module.exports = {
read: read,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["startFiveInch", "v"],
["closeFiveInch", "v"],
["read", "is"],
];
console.log("in factory_fiveInch.js")
function register() {
console.log("will register fiveInch.so")
var isSuccess = dlfcn.register("@native.fiveInch", "./lib/factory/fiveInch.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var fiveInch = require("@native.fiveInch");
return fiveInch
} else {
console.log("load so failed")
}
return undefined;
}
var fiveInch = register();
function start() {
fiveInch.startFiveInch();
}
function close() {
fiveInch.closeFiveInch();
}
function read(option) {
// option -> "data" // return "aaaaaaaaaaa"
// option -> "author" // return "11"
return fiveInch.read(option);
}
module.exports = {
start: start,
close: close,
read: read,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["soundInit", "v"],
["soundOn", "v"],
["pwmInit", "i"],
["pwmLv1", "i"],
["pwmLv2", "i"],
["pwmLv3", "i"],
["pwmLv4", "i"],
["pwmLv5", "i"],
["pwmLv6", "i"],
["pwmOff", "i"],
["pwmOn", "i"],
["gpio1On", "vi"],
["gpio1Off", "vi"],
["gpio2On", "vi"],
["gpio2Off", "vi"],
["gpio3On", "vi"],
["gpio3Off", "vi"],
["gpio4On", "vi"],
["gpio4Off", "vi"],
["gpio5On", "vi"],
["gpio5Off", "vi"],
["gpio6On", "vi"],
["gpio6Off", "vi"],
["gpio7On", "vi"],
["gpio7Off", "vi"],
["insModEncoder", "v"],
["rmModEncoder", "v"],
["gpioUnexport", "v"],
["gpioInit", "v"],
];
console.log("in factory_rd190_factory.js")
function register() {
console.log("will register rd190_factory.so")
if (globalThis.Simu.En == 1) {
return undefined
}
var isSuccess = dlfcn.register("@native.rd190_factory", "./lib/factory/rd190_factory.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var rd190_factory = require("@native.rd190_factory");
return rd190_factory
} else {
console.log("load so failed")
}
return undefined;
}
var rd190_factory = register();
function pwmInit() {
if (globalThis.Simu.En == 1) {
return 0
}
rd190_factory.pwmInit()
}
function soundInit() {
if (globalThis.Simu.En == 1) {
return 0
}
rd190_factory.soundInit()
}
function soundOn() {
if (globalThis.Simu.En == 1) {
return 0
}
rd190_factory.soundOn()
}
function pwm(val) {
console.log("pwm:" + val)
if (globalThis.Simu.En == 1) {
return 0
}
if (val == 0) {
rd190_factory.pwmOff()
}
if (val == 1) {
rd190_factory.pwmLv1()
rd190_factory.pwmOn()
}
if (val == 2) {
rd190_factory.pwmLv2()
rd190_factory.pwmOn()
}
if (val == 3) {
rd190_factory.pwmLv3()
rd190_factory.pwmOn()
}
if (val == 4) {
rd190_factory.pwmLv4()
rd190_factory.pwmOn()
}
if (val == 5) {
rd190_factory.pwmLv5()
rd190_factory.pwmOn()
}
if (val == 6) {
rd190_factory.pwmLv6()
rd190_factory.pwmOn()
}
}
function gpio(index, status) {
console.log("index:" + index)
console.log("status:" + status)
if (globalThis.Simu.En == 1) {
return 0
}
if (status == 1) {
switch (index) {
case 1: {
rd190_factory.gpio1On()
break
}
case 2: {
rd190_factory.gpio2On()
break
}
case 3: {
rd190_factory.gpio3On()
break
}
case 4: {
rd190_factory.gpio4On()
break
}
case 5: {
rd190_factory.gpio5On()
break
}
case 6: {
rd190_factory.gpio6On()
break
}
case 7: {
rd190_factory.gpio7On()
break
}
default:
break
}
} else {
switch (index) {
case 1: {
rd190_factory.gpio1Off()
break
}
case 2: {
rd190_factory.gpio2Off()
break
}
case 3: {
rd190_factory.gpio3Off()
break
}
case 4: {
rd190_factory.gpio4Off()
break
}
case 5: {
rd190_factory.gpio5Off()
break
}
case 6: {
rd190_factory.gpio6Off()
break
}
case 7: {
rd190_factory.gpio7Off()
break
}
default:
break
}
}
}
function gpioInit() {
rd190_factory.gpioInit()
}
function insmodEncoder() {
rd190_factory.gpioUnexport()
rd190_factory.insModEncoder()
}
function rmmodEncoder() {
rd190_factory.rmModEncoder()
rd190_factory.gpioInit()
}
module.exports = {
pwmInit: pwmInit,
soundInit: soundInit,
soundOn:soundOn,
pwm: pwm,
gpio: gpio,
gpioInit: gpioInit,
insmodEncoder: insmodEncoder,
rmmodEncoder: rmmodEncoder,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["set", "viiiiii"],
["isRTC", "is"],
];
console.log("in factory_rtc.js")
function register() {
console.log("will register rtc.so")
var isSuccess = dlfcn.register("@native.rtc", "./lib/factory/rtc.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var rtc = require("@native.rtc");
return rtc
} else {
console.log("load so failed")
}
return undefined;
}
var rtc = register();
function ctrl(word, obj) {
switch (word) {
case "set": {
rtc.set(obj['year'],
obj['month'],
obj['day'],
obj['hour'],
obj['minute'],
obj['second'])
break
}
default: {
console.log("ERROR:rtc ctrl word undefined..")
}
}
}
function getrtc(word) {
switch (word) {
case "getRTC": {
var ret = 0
try {
ret = rtc.isRTC("rtc1")
} catch (e) {
ret = 0
console.log("!!!ERROR:" + e)
}
console.log(ret);
return ret
// break
}
default: {
console.log("ERROR:rtc getRTC word undefined..")
}
}
}
module.exports = {
ctrl: ctrl,
getrtc: getrtc,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["startlte", "v"],
["closelte", "v"],
["read", "is"],
];
console.log("in factory_testlte.js")
function register() {
console.log("will register lte.so")
var isSuccess = dlfcn.register("@native.lte", "./lib/factory/lte.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var lte = require("@native.lte");
return lte
} else {
console.log("load so failed")
}
return undefined;
}
var lte = register();
function start() {
lte.startlte();
}
function close() {
lte.closelte();
}
function read(option) {
// option -> "data" // return "aaaaaaaaaaa"
// option -> "imei" // return "11"
return lte.read(option);
}
module.exports = {
start: start,
close: close,
read: read,
}
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["isWifi", "is"],
["getWifiSignalLevel", "is"],
["initWifi", "is"],
["getVersion", "ss"],
["syncSave", "is"],
["get_wifi_mac", "ss"],
];
console.log("in factory_wifi.js")
function register() {
console.log("will register testWifi.so")
var isSuccess = dlfcn.register("@native.wifi", "./lib/factory/testWifi.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var wifi = require("@native.wifi");
return wifi
} else {
console.log("load so failed")
}
return undefined;
}
var wifi = register();
function testWifiConnect(word, SSID) {
switch (word) {
case "testWifi": {
var ret = 0
try {
ret = wifi.isWifi(SSID);
} catch (e) {
ret = 0
console.log("!!!ERROR:" + e)
}
console.log("ret[0]=" + ret);
return ret;
}
case "getSignal": {
var ret = 0
try {
ret = wifi.getWifiSignalLevel("signal");
} catch (e) {
ret = -999
console.log("!!!ERROR:" + e)
}
console.log("ret[1]=" + ret);
return ret;
}
default: {
console.log("ERROR:wifi testWifiConnect word undefined..")
}
}
}
function initWifiTest(word) {
console.log("start run initWifiTest function");
switch (word) {
case "init": {
var ret = wifi.initWifi(word);
console.log(ret);
return ret
// break
}
default: {
console.log("ERROR:wifi initTest word undefined..")
}
}
}
function getSysVersion(word) {
switch (word) {
case "get": {
let ret = "init";//normal=1.0.0
try {
ret = wifi.getVersion(word);
} catch (e) {
ret = "1.0.0"
console.log("!!!ERROR:" + e)
}
console.log("ret=" + ret);
return ret
// break
}
default: {
console.log("ERROR:wifi getSysVersion word undefined..")
}
}
}
function syncSave(word) {
switch (word) {
case "save": {
let ret = 1;
try {
ret = wifi.syncSave(word);
} catch (e) {
ret = 1
console.log("!!!ERROR:" + e)
}
console.log("ret=" + ret);
return ret
}
default: {
console.log("ERROR:wifi getSysVersion word undefined..")
}
}
}
function getWifiMac() {
console.log("getWifiMac///////////////////////////////////////////");
var mac = undefined
try {
mac = wifi.get_wifi_mac();
} catch (e) {
mac = "00:11:22:33:44:55"
console.log("!!!ERROR:" + e)
}
console.log("mac=" + mac);
return mac;
}
module.exports = {
testWifiConnect: testWifiConnect,
initWifiTest: initWifiTest,
getSysVersion: getSysVersion,
syncSave: syncSave,
getWifiMac: getWifiMac
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define RXBUFFER_MAX_LENGTH 80
typedef struct _obj
{
int in; //初始值
int poly; //多项式值
int xorout; //结果异或值
int ret; // crc校验值
int length; //需校验数据长度
char rxBuffer[RXBUFFER_MAX_LENGTH]; //数据数组
} CRCObj;
int _OPEN_LOG = 0;
int _REFIN = 0;
int _REFOUT = 0;
CRCObj *objCreate(void);
void openLog(void);
void closeLog(void);
void objINIT(CRCObj *obj);
void bufferINIT(CRCObj *obj);
void setBitData(CRCObj *obj, int index, int data);
void setLength(CRCObj *obj, int length);
void figResult(CRCObj *obj);
int getResult(CRCObj *obj);
void setObjIn(CRCObj *obj, int tag);
void setObjPoly(CRCObj *obj, int tag);
void setObjXorOut(CRCObj *obj, int tag);
void setREFIN(int en);
void setREFOUT(int en);
unsigned short refout(unsigned short Data);
unsigned char refin(unsigned char Data);
CRCObj *objCreate(void)
{
if (_OPEN_LOG)
printf("======enter objCreate.\n");
return (CRCObj *)malloc(sizeof(CRCObj));
}
void openLog(void)
{
if (_OPEN_LOG)
printf("======enter openLog.\n");
_OPEN_LOG = 1;
//printf("_OPEN_LOG:%d\n", _OPEN_LOG);
}
void closeLog(void)
{
if (_OPEN_LOG)
printf("======enter closeLog.\n");
_OPEN_LOG = 0;
//printf("_OPEN_LOG:%d\n", _OPEN_LOG);
}
void objINIT(CRCObj *obj)
{
if (_OPEN_LOG)
printf("======enter objINIT.\n");
obj->in &= 0x00000000;
obj->in |= 0x0000ffff;
if (_OPEN_LOG)
printf("the obj->in:%x\n", obj->in);
obj->poly &= 0x00000000;
obj->poly |= 0x00001021;
if (_OPEN_LOG)
printf("the obj->poly:%x\n", obj->poly);
obj->xorout &= 0x00000000;
obj->xorout |= 0x0000ffff;
if (_OPEN_LOG)
printf("the obj->xorout:%x\n", obj->xorout);
obj->ret &= 0x00000000;
if (_OPEN_LOG)
printf("the obj->ret:%d\n", obj->ret);
obj->length &= 0x00000000;
if (_OPEN_LOG)
printf("the obj->length:%d\n", obj->length);
bufferINIT(obj);
}
void bufferINIT(CRCObj *obj)
{
if (_OPEN_LOG)
printf("======enter bufferINIT.\n");
memset(obj->rxBuffer, 0, sizeof(obj->rxBuffer));
}
void setBitData(CRCObj *obj, int index, int data)
{
if (_OPEN_LOG)
printf("======enter setBitData.\n");
if (index >= RXBUFFER_MAX_LENGTH)
{
if (_OPEN_LOG)
printf("the index:%d too large.\n", index);
return;
}
obj->rxBuffer[index] = data;
if (_OPEN_LOG)
printf("obj->rxBuffer[%d] = %x;\n", index, data);
return;
}
void setLength(CRCObj *obj, int length)
{
if (_OPEN_LOG)
printf("======enter setLength.\n");
obj->length = length;
if (_OPEN_LOG)
printf("obj->length:%d\n", obj->length);
return;
}
void figResult(CRCObj *obj)
{
if (_OPEN_LOG)
printf("======enter figResult.\n");
int len = 0;
char cChar = 0;
unsigned char ucIndex = 0;
int uiIn = 0;
int uiPoly = 0;
int uiXorOut = 0;
len = obj->length;
uiIn = obj->in;
uiPoly = obj->poly;
uiXorOut = obj->xorout;
while (len--)
{
if (_OPEN_LOG)
printf("len:%x\n", len);
cChar = obj->rxBuffer[ucIndex++];
if (_REFIN)
cChar = refin(cChar);
if (_OPEN_LOG)
printf("cChar-29:%x\n", cChar);
uiIn ^= (cChar << 8);
if (_OPEN_LOG)
printf("uiIn-31:%x\n", uiIn);
for (int i = 0; i < 8; i++)
{
if (uiIn & 0x8000)
uiIn = (uiIn << 1) ^ uiPoly;
else
uiIn = uiIn << 1;
}
if (_OPEN_LOG)
printf("uiIn-39:%x\n", uiIn);
}
if (_REFOUT)
uiIn = refout(uiIn);
obj->ret = uiIn ^ uiXorOut;
if (_OPEN_LOG)
printf("obj->ret:%x\n", obj->ret);
return;
}
int getResult(CRCObj *obj)
{
unsigned short temp = obj->ret;
return temp;
}
//自定义设置crc初始值INIT
void setObjIn(CRCObj *obj, int tag)
{
obj->in = tag;
return;
}
//自定义设置多项式POLY
void setObjPoly(CRCObj *obj, int tag)
{
obj->poly = tag;
return;
}
//自定义设置结果异或值XOROUT
void setObjXorOut(CRCObj *obj, int tag)
{
obj->xorout = tag;
return;
}
void setREFIN(int en)
{
_REFIN = en;
return;
}
void setREFOUT(int en)
{
_REFOUT = en;
return;
}
int excObjResult(CRCObj *obj)
{
unsigned short value = obj->ret;
unsigned short ret = 0;
unsigned short tempH = ((value & 0x00ff) << 8);
unsigned short tempL = ((value & 0xff00) >> 8);
if (_OPEN_LOG)
printf("value:%x\n", value);
if (_OPEN_LOG)
printf("tempH:%x\n", tempH);
if (_OPEN_LOG)
printf("tempL:%x\n", tempL);
ret = ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
return ret;
}
unsigned short refout(unsigned short Data)
{
unsigned short ret = 0;
for (int i = 0; i < 16; i++)
{
if (Data & 0x8000)
ret += 1 << i;
Data <<= 1;
}
return ret;
}
unsigned char refin(unsigned char Data)
{
unsigned char ret = 0;
for (int i = 0; i < 8; i++)
{
if (Data & 0x80)
ret += 1 << i;
Data <<= 1;
}
return ret;
}
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
// disp驱动部分命令(与背光相关,内核目录:/include/video/sunxi_display2.h)
#define DISP_LCD_SET_BRIGHTNESS 0x102
#define DISP_LCD_GET_BRIGHTNESS 0x103
#define DISP_LCD_BACKLIGHT_ENABLE 0x104
#define DISP_LCD_BACKLIGHT_DISABLE 0x105
#define BRIGHTNESS_MAX 255 // 最大亮度
int changeBgLight(int argc, int argv)
{
int fd;
unsigned long args[3] = {0};
/*打开disp设备文件*/
fd = open("/dev/disp", O_RDWR, 0);
if (fd < 0)
{
printf("open /dev/disp failed.\n");
return -1;
}
/*打印旧的背光值*/
args[0] = 0; // 选择fb0(lcd0)
// printf("the old lcd%d brightness is %d\n",\args[0], ioctl(fd, DISP_LCD_GET_BRIGHTNESS, args));
if (argc != 2)
{
printf("ERROR: the right format: ./app [brightness]\n");
return -1;
}
int brightness = argv;
if (brightness < 0 || brightness > BRIGHTNESS_MAX)
{
printf("ERROR: the range is 0 to %d\n", BRIGHTNESS_MAX);
return -1;
}
/*参数数组填参*/
args[0] = 0;
args[1] = brightness; // 背光值(本人配置里最高为255)
args[2] = 0; // 暂时用不到的参数
ioctl(fd, DISP_LCD_SET_BRIGHTNESS, args);
// printf("the new lcd%d brightness is %d\n",\args[0], ioctl(fd, DISP_LCD_GET_BRIGHTNESS, args));
close(fd);
return 0;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
typedef struct saveGroup
{
int backLight;
int screenSaverPara;
int startUpPara;
int language;
int startUpTemp;
} EVEN_SAVE_GROUP;
static EVEN_SAVE_GROUP saveObj = {6, 0, 0, 0, 225};
void setBackLight(int val)
{
printf("setBackLight:%d\n", val);
saveObj.backLight = val;
return;
}
void setScreenSaverPara(int val)
{
printf("setScreenSaverPara:%d\n", val);
saveObj.screenSaverPara = val;
return;
}
void setStartUpPara(int val)
{
printf("setStartUpPara:%d\n", val);
saveObj.startUpPara = val;
return;
}
void setLanguage(int val)
{
printf("setLanguage:%d\n", val);
saveObj.language = val;
return;
}
void setStartUpTemp(int val)
{
printf("setStartUpTemp:%d\n", val);
saveObj.startUpTemp = val;
return;
}
int getBackLight(void)
{
int tempVal = saveObj.backLight;
printf("getBackLight:%d\n", tempVal);
return tempVal;
}
int getScreenSaverPara(void)
{
int tempVal = saveObj.screenSaverPara;
printf("getScreenSaverPara:%d\n", tempVal);
return tempVal;
}
int getStartUpPara(void)
{
int tempVal = saveObj.startUpPara;
printf("getStartUpPara:%d\n", tempVal);
return tempVal;
}
int getLanguage(void)
{
int tempVal = saveObj.language;
printf("getLanguage:%d\n", tempVal);
return tempVal;
}
int getStartUpTemp(void)
{
int tempVal = saveObj.startUpTemp;
printf("getStartUpTemp:%d\n", tempVal);
return tempVal;
}
void saveOption(void)
{
FILE *fp = fopen("/usr/local/quicknode/file/user.cfg", "w+");
if (fp == NULL)
return;
fwrite(&saveObj, sizeof(saveObj), 1, fp);
fflush(fp);
fsync(fileno(fp));
fclose(fp);
}
void readOption(void)
{
FILE *fp = fopen("/usr/local/quicknode/file/user.cfg", "w+");
if (fp == NULL)
return;
fread(&saveObj, sizeof(saveObj), 1, fp);
fclose(fp);
}
void clearOption(void)
{
saveObj={0,0,0,0,0};
}
// 在文件开头添加(在所有#include之前)
#define _XOPEN_SOURCE 600 // 启用POSIX 2004标准API
#define _GNU_SOURCE
#include <dirent.h> // 添加 dirent.h 头文件以支持目录操作
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "emd5.h"
#include <sys/stat.h>
#include <errno.h>
#include <libgen.h>
#include "egenmd5.h"
#include <fcntl.h> // 添加 open/close/write 头文件
#include <unistd.h> // 已存在 fsync
#include <sys/syscall.h>
// 修改:使用静态数组存储结果,移除动态内存分配
#define MAX_MD5_RESULTS 256 // 设置最大支持的文件数量
typedef struct {
char filename[1024]; // 直接使用固定大小缓冲区
char md5[33];
} Md5Result;
typedef struct {
Md5Result results[MAX_MD5_RESULTS];
size_t count;
} Md5ResultList;
// 初始化结果列表(静态实现)
void init_md5_result_list(Md5ResultList *list) {
list->count = 0;
}
// void force_metadata_sync(const char* path) {
// int fd = open(path, O_RDONLY);
// if (fd >= 0) {
// syscall(SYS_syncfs, fd); // Linux特有系统调用
// close(fd);
// }
// sync(); // 双重保障
// }
// 添加结果(静态检查溢出)
int add_md5_result(Md5ResultList *list, const char *filename, const char *md5) {
if (list->count >= MAX_MD5_RESULTS) {
fprintf(stderr, "Too many files, MD5 result limit reached: %d\n", MAX_MD5_RESULTS);
return -1; // 超出最大文件数限制
}
strncpy(list->results[list->count].filename, filename, sizeof(list->results[list->count].filename) - 1);
list->results[list->count].filename[sizeof(list->results[list->count].filename) - 1] = '\0';
strncpy(list->results[list->count].md5, md5, sizeof(list->results[list->count].md5) - 1);
list->results[list->count].md5[sizeof(list->results[list->count].md5) - 1] = '\0';
list->count++;
return 0;
}
#define EGENMD5_VERSION "1.0.0"
// 在文件开头添加以下宏定义以简化日志输出
#define LOG_INFO() ;
// #define LOG_INFO() fprintf(stderr, "[%s %d]\r\n", __FUNCTION__, __LINE__)
// 提取路径最后一级目录名
char *get_last_dir_name(const char *path)
{
static char result[512]; // 使用静态缓冲区避免 malloc
char *copy = strdup(path); // 可能仍需要临时复制,但不暴露给外部释放
if (copy == NULL)
{
LOG_INFO();
return NULL;
}
size_t len = strlen(copy);
while (len > 0 && copy[len - 1] == '/')
copy[--len] = '\0';
char *base = basename(copy);
strncpy(result, base, sizeof(result) - 1);
result[sizeof(result) - 1] = '\0';
free(copy);
return result;
}
// 计算文件MD5
static int compute_file_md5(const char *file_path, unsigned char *md5_value)
{
LOG_INFO();
if (!file_path || !md5_value)
{
LOG_INFO();
return -1;
}
FILE *file = fopen(file_path, "rb");
if (!file)
{
LOG_INFO();
return -1;
}
MD5_CTX ctx;
if (!e_MD5_Init(&ctx))
{ // 添加初始化状态检查
LOG_INFO();
fclose(file);
return -1;
}
unsigned char buffer[1024];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file)) > 0)
{
LOG_INFO();
if (!e_MD5_Update(&ctx, buffer, bytes_read))
{ // 添加安全检查
LOG_INFO();
fclose(file);
return -1;
}
LOG_INFO();
}
LOG_INFO();
if (!e_MD5_Final(md5_value, &ctx))
{ // 添加安全检查
LOG_INFO();
fclose(file);
return -1;
}
LOG_INFO();
fclose(file);
return 0;
}
// 回调数据结构保持不变
struct callback_data {
const char *base_dir; // 基础目录路径
const char *base_with_slash;// 带斜杠的基础目录
const char *dir_prefix; // 新增:要保留的目录前缀(如"files"")
int output_fd; // 修改:使用文件描述符替代 FILE*
};
// 自定义递归遍历函数
static int traverse_directory(const char *dir_path, struct callback_data *data, Md5ResultList *result_list) {
DIR *dir = opendir(dir_path);
if (!dir) {
LOG_INFO();
fprintf(stderr, "Failed to open directory: %s\n", dir_path);
return -1;
}
struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
continue;
}
char file_path[1024];
snprintf(file_path, sizeof(file_path), "%s/%s", dir_path, entry->d_name);
struct stat sb;
if (lstat(file_path, &sb) == -1) {
LOG_INFO();
fprintf(stderr, "Failed to get file status: %s\n", file_path);
continue;
}
if (S_ISDIR(sb.st_mode)) {
traverse_directory(file_path, data, result_list);
} else if (S_ISREG(sb.st_mode)) {
unsigned char md5_value[MD5_DIGEST_LENGTH];
if (compute_file_md5(file_path, md5_value) != 0) {
LOG_INFO();
fprintf(stderr, "Failed to compute MD5 for file: %s\n", file_path);
continue;
}
char md5_string[33] = {0};
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(md5_string + i * 2, "%02x", md5_value[i]);
}
// 构建完整路径
size_t base_len = strlen(data->base_with_slash);
const char *rel_path = file_path + base_len;
char full_path[1024] = {0};
snprintf(full_path, sizeof(full_path), "%s/%s", data->dir_prefix, rel_path);
// 缓存结果
if (add_md5_result(result_list, full_path, md5_string) != 0) {
LOG_INFO();
fprintf(stderr, "Failed to add MD5 result, too many files\n");
closedir(dir);
return -1;
}
LOG_INFO();
fprintf(stderr, "Cached MD5: %s %s\n", md5_string, full_path);
}
}
closedir(dir);
return 0;
}
// 主函数:遍历目录并生成MD5记录
void generate_md5_for_directory(const char *dir_path, const char *output_path) {
LOG_INFO();
if (!dir_path || !output_path) {
LOG_INFO();
return;
}
// 使用静态缓冲区替代动态分配
char base_with_slash[1024] = {0};
strncpy(base_with_slash, dir_path, sizeof(base_with_slash) - 2);
size_t len = strlen(base_with_slash);
if (len > 0 && base_with_slash[len - 1] != '/') {
strcat(base_with_slash, "/");
}
// 提取目录名
char *dir_prefix = get_last_dir_name(dir_path);
if (!dir_prefix) {
LOG_INFO();
fprintf(stderr, "Failed to extract directory prefix\n");
return;
}
// 修改:使用 open 替代 fopen
int output_fd = open(output_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0644);
if (output_fd == -1) {
LOG_INFO();
fprintf(stderr, "Failed to open output file: %s\n", output_path);
return;
}
struct callback_data data = {
.base_dir = dir_path,
.base_with_slash = base_with_slash,
.dir_prefix = dir_prefix,
.output_fd = output_fd
};
// 初始化结果列表(静态内存)
Md5ResultList result_list;
init_md5_result_list(&result_list); // 修改:不再传入初始容量
LOG_INFO();
if (traverse_directory(dir_path, &data, &result_list) != 0) {
LOG_INFO();
fprintf(stderr, "Directory traversal failed for path: %s\n", dir_path);
}
// 统一写入文件
for (size_t i = 0; i < result_list.count; i++) {
char buffer[1024];
int bytes = snprintf(buffer, sizeof(buffer), "%s %s\n", result_list.results[i].md5, result_list.results[i].filename);
if (write(output_fd, buffer, bytes) == -1) {
LOG_INFO();
fprintf(stderr, "Failed to write to output file\n");
}
LOG_INFO();
fprintf(stderr, "Wrote to output file: %s %s\n", result_list.results[i].md5, result_list.results[i].filename);
}
if (fsync(output_fd) == -1) { // 检查fsync结果
printf("MD5 file fsync failed: %s", strerror(errno));
}
syncfs(output_fd);
close(output_fd); // 修改:使用 close 替代 fclose
// 增加延迟(可选,针对慢速存储)
usleep(50000); // 50ms延迟
// 同步文件系统元数据
// sync(); // 强制全局缓存刷新
// force_metadata_sync(dir_path);
}
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
#define USE_ROTATION_ENCODER 1
#define USE_TOGGLE_ENCODER 1
#define SLEEP_DELAY_MS 1
#define HOLD_DELAY_MS 80
#define REPORT_DELAY_MS 120
#define PROJECT_NAME re818
#define __parse_str(tag) #tag
#define parse_str(tag) __parse_str(tag)
#if USE_ROTATION_ENCODER
#define ROTATION_MODE 1
#endif
#if USE_TOGGLE_ENCODER
#define TOGGLE_MODE 2
#endif
#ifndef ROTATION_MODE
#define ROTATION_MODE 0
#endif
#ifndef TOGGLE_MODE
#define TOGGLE_MODE 0
#endif
#if PROJECT_NAME == re818
#define KCROT 0
#define KCENT 103
#define KCUP 104
#define KCDN 105
#define KCLT 106
#define KCRT 107
#define KVLROT 1
#define KVRROT -1
#define KVPRS 0
#define KVRLS 1
#define KVNOP 2
#else
#define KCROT 0
#define KCENT 103
#define KCUP 104
#define KCDN 105
#define KCLT 106
#define KCRT 107
#define KVLROT 1
#define KVRROT -1
#define KVPRS 0
#define KVRLS 1
#define KVNOP 2
#endif
typedef enum
{
KRY_PSB_NOP = 0, //静默事件索引值 left rotation
KRY_PSB_LROT = 1, //左旋事件索引值 left rotation
KRY_PSB_RROT = 2, //右旋事件索引值 right rotation
KRY_PSB_ENTP = 3, //按钮按下事件索引值 enter press
KRY_PSB_ENTR = 4, //按钮释放事件索引值 enter release
KRY_PSB_UPP = 5, //上拨动触发事件索引值 upper press
KRY_PSB_UPR = 6, //上拨动释放事件索引值 upper release
KRY_PSB_DNP = 7, //下拨动触发事件索引值 down press
KRY_PSB_DNR = 8, //下拨动释放事件索引值 down release
KRY_PSB_LTP = 9, //左拨动触发事件索引值 left press
KRY_PSB_LTR = 10, //左拨动释放事件索引值 left release
KRY_PSB_RTP = 11, //右拨动触发事件索引值 right press
KRY_PSB_RTR = 12, //右拨动释放事件索引值 right release
KRY_PSB_END
} KEY_PSB;
typedef enum
{
KEY_CODE_ROT = KCROT, //旋钮code值
KEY_CODE_ENT = KCENT, //按钮code值
KEY_CODE_UP = KCUP, //上拨code值
KEY_CODE_DN = KCDN, //下拨code值
KEY_CODE_LT = KCLT, //左拨code值
KEY_CODE_RT = KCRT, //右拨code值
KEY_CODE_END
} KEY_CODE;
typedef enum
{
KEY_VALUE_LROT = KVLROT, //左旋value值
KEY_VALUE_RROT = KVRROT, //右旋value值
KEY_VALUE_NP = KVPRS, //按下value值
KEY_VALUE_NR = KVRLS, //释放value值
KEY_VALUE_NOP = KVNOP, //空置value值
KEY_VALUE_END
} KEY_VALUE;
typedef struct KeyList
{
int mode;
int code;
int value;
int ret;
} EVEN_KEY_LIST;
int retKey(int code, int value, int mode)
{
EVEN_KEY_LIST keyList[] = {
{ROTATION_MODE, KEY_CODE_ROT, KEY_VALUE_LROT, KRY_PSB_LROT},
{ROTATION_MODE, KEY_CODE_ROT, KEY_VALUE_RROT, KRY_PSB_RROT},
{TOGGLE_MODE, KEY_CODE_ENT, KEY_VALUE_NP, KRY_PSB_ENTP},
{TOGGLE_MODE, KEY_CODE_ENT, KEY_VALUE_NR, KRY_PSB_ENTR},
{TOGGLE_MODE, KEY_CODE_UP, KEY_VALUE_NP, KRY_PSB_UPP},
{TOGGLE_MODE, KEY_CODE_UP, KEY_VALUE_NR, KRY_PSB_UPR},
{TOGGLE_MODE, KEY_CODE_DN, KEY_VALUE_NP, KRY_PSB_DNP},
{TOGGLE_MODE, KEY_CODE_DN, KEY_VALUE_NR, KRY_PSB_DNR},
{TOGGLE_MODE, KEY_CODE_LT, KEY_VALUE_NP, KRY_PSB_LTP},
{TOGGLE_MODE, KEY_CODE_LT, KEY_VALUE_NR, KRY_PSB_LTR},
{TOGGLE_MODE, KEY_CODE_RT, KEY_VALUE_NP, KRY_PSB_RTP},
{TOGGLE_MODE, KEY_CODE_RT, KEY_VALUE_NR, KRY_PSB_RTR},
{TOGGLE_MODE, KEY_CODE_ENT, KEY_VALUE_NOP, KRY_PSB_NOP}};
int cnt = 0;
for (cnt = 0; cnt < 13; cnt++)
{
if ((keyList[cnt].code == code) && (keyList[cnt].value == value) && (keyList[cnt].mode == mode))
{
return keyList[cnt].ret;
}
}
// printf("not found.\n");
return 0;
}
int getCurrentTime() //直接调用这个函数就行了,返回值最好是int64_t,long long应该也可以
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
#if USE_ROTATION_ENCODER
static int encoder_rotation_fd = 0;
static int keyRotValue = 0; //业务逻辑的index
static int invRotValue = 0; //业务逻辑的index
static int timerRotMark = 0;
static int holdRotAction = 0; //持续触发
static int reportDelayMs = 0; //上报延时
void *psbRotHandler(void *p)
{
struct input_event in;
int tempVal = 0;
int tempTimerMart = 0;
while (1)
{
tempTimerMart = getCurrentTime();
if (read(encoder_rotation_fd, &in, sizeof(struct input_event)) == sizeof(struct input_event))
{
// printf("[%8d]psbRotHandler KEY_CODE=%d KEY_NUM=%d\n", getCurrentTime(), in.code, in.value); // psb的数值
tempVal = retKey(in.code, in.value, ROTATION_MODE);
if (tempVal == 0)
{
}
else
{
// printf("now Time:%d\n", tempTimerMart);
if (tempTimerMart - timerRotMark > HOLD_DELAY_MS)
{
holdRotAction = 0;
}
else
{
holdRotAction = 1;
// printf("now Time:%d mark time:%d\n", tempTimerMart, timerRotMark);
}
timerRotMark = tempTimerMart;
reportDelayMs = tempTimerMart;
keyRotValue = tempVal;
// printf("keyRotValue=%d\n", keyRotValue);
}
}
if (holdRotAction)
{
// printf("faster rotation!\n");
}
usleep(SLEEP_DELAY_MS * 1000);
}
return NULL;
}
int psbGetRotValue(void)
{
return keyRotValue;
}
int psbGetRotActionValue(void)
{
return holdRotAction;
}
void psbClearRotValue(void)
{
keyRotValue = 0;
return;
}
void psbClearRotActionValue(void)
{
holdRotAction = 0;
timerRotMark = 0;
return;
}
#endif
#if USE_TOGGLE_ENCODER
static int encoder_toggle_fd = 0;
static int keyTogValue = 0; //业务逻辑的index
static int timerTogMark = 0;
static int holdTogAction = 0; //持续触发
static int realToggleTrigger = 0; //防止摇杆触发按下
static int enterPressLock = 0;
static int avoidShakeLock = 0; //避免按下时抖动
int isToggleAction(int *val)
{
if (enterPressLock == 1)
{
return 0;
}
int tempVal = *val;
if ((tempVal == KRY_PSB_UPP) ||
(tempVal == KRY_PSB_DNP) ||
(tempVal == KRY_PSB_LTP) ||
(tempVal == KRY_PSB_RTP))
{
realToggleTrigger = 1;
return 1;
}
else if ((tempVal == KRY_PSB_UPR) ||
(tempVal == KRY_PSB_DNR) ||
(tempVal == KRY_PSB_LTR) ||
(tempVal == KRY_PSB_RTR))
{
realToggleTrigger = 2;
return 1;
}
else if ((realToggleTrigger != 0) && ((tempVal == KRY_PSB_ENTR) || (tempVal == KRY_PSB_ENTP)))
{
if (realToggleTrigger == 1 && tempVal == KRY_PSB_ENTP)
*val = 0;
if (realToggleTrigger == 2 && tempVal == KRY_PSB_ENTR)
{
*val = 0;
realToggleTrigger = 0;
}
return 0;
}
else
{
return 0;
}
}
int isEnterPressAction(int *val)
{
int tempVal = *val;
if ((tempVal == KRY_PSB_ENTP))
{
enterPressLock = 1;
printf(" trigger press ENTER.\n");
}
else if ((tempVal == KRY_PSB_ENTR))
{
enterPressLock = 0;
printf(" trigger release ENTER.\n");
}
else
{
if (enterPressLock)
{
*val = 0;
}
}
return 0;
}
void *psbTogHandler(void *p) //摇杆处理函数
{
struct input_event in;
int tempVal = 0;
int tempTimerMart = 0;
while (1)
{
tempTimerMart = getCurrentTime();
if (read(encoder_toggle_fd, &in, sizeof(struct input_event)) == sizeof(struct input_event))
{
tempVal = retKey(in.code, in.value, TOGGLE_MODE);
if (tempVal == 0)
{
}
else
{
printf("[%8d]psbTogHandler KEY_CODE=%d KEY_NUM=%d \n", tempTimerMart, in.code, in.value); // psb的数值
//处理摇杆时同时触发摇杆与按钮问题
isToggleAction(&tempVal);
if (tempVal == 0)
{
continue;
}
//处理按下时不响应其他摇杆操作
isEnterPressAction(&tempVal);
if (tempVal == 0)
{
continue;
}
// printf("now Time:%d\n", tempTimerMart);
if (tempTimerMart - timerTogMark > HOLD_DELAY_MS)
{
holdTogAction = 0;
}
else
{
holdTogAction = 1;
}
timerTogMark = tempTimerMart;
keyTogValue = tempVal;
// printf("keyTogValue=%d\n", keyTogValue);
}
}
usleep(SLEEP_DELAY_MS * 1000);
}
return NULL;
}
int psbGetTogValue(void)
{
return keyTogValue;
}
void psbClearTogValue(void)
{
keyTogValue = 0;
return;
}
#endif
void psbInit(void)
{
#if USE_ROTATION_ENCODER
pthread_t thread_rotation;
encoder_rotation_fd = open("/dev/input/event1", O_RDONLY); //打开event1
if (encoder_rotation_fd <= 0)
{
printf("psbInit:encoder_rotation_fd <= 0.\n");
}
else
{
pthread_create(&thread_rotation, NULL, psbRotHandler, NULL); //用handler读和处理
}
#endif
#if USE_TOGGLE_ENCODER
pthread_t thread_toggle;
encoder_toggle_fd = open("/dev/input/event2", O_RDONLY); //打开event1
if (encoder_toggle_fd <= 0)
{
printf("psbInit:encoder_toggle_fd <= 0.\n");
}
else
{
pthread_create(&thread_toggle, NULL, psbTogHandler, NULL); //用handler读和处理
}
#endif
return;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
void backlightLv0(void)
{
// printf("c-backlight off\n");
system("echo 210 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv1(void)
{
// printf("c-backlight off\n");
system("echo 175 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv2(void)
{
// printf("c-backlight off\n");
system("echo 140 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv3(void)
{
// printf("c-backlight off\n");
system("echo 105 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv4(void)
{
// printf("c-backlight off\n");
system("echo 70 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv5(void)
{
// printf("c-backlight off\n");
system("echo 35 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
void backlightLv6(void)
{
// printf("c-backlight off\n");
system("echo 0 > /sys/class/disp/disp/attr/lcdbl"); /*0~255,值越小,亮度越亮*/
return;
}
int keypaddev_fd = 0;
int keypaddev_fdex = 0;
int keyValue = 0; //业务逻辑的index
typedef enum
{
KRY_PSB_LROT = 1, //左旋事件索引值 left rotation
KRY_PSB_RROT = 2, //右旋事件索引值 right rotation
KRY_PSB_ENTP = 3, //按钮按下事件索引值 enter press
KRY_PSB_ENTR = 4, //按钮释放事件索引值 enter release
KRY_PSB_UPP = 5, //上拨动触发事件索引值 upper press
KRY_PSB_UPR = 6, //上拨动释放事件索引值 upper release
KRY_PSB_DNP = 7, //下拨动触发事件索引值 down press
KRY_PSB_DNR = 8, //下拨动释放事件索引值 down release
KRY_PSB_LTP = 9, //左拨动触发事件索引值 left press
KRY_PSB_LTR = 10, //左拨动释放事件索引值 left release
KRY_PSB_RTP = 11, //右拨动触发事件索引值 right press
KRY_PSB_RTR = 12, //右拨动释放事件索引值 right release
KRY_PSB_END
} KEY_PSB;
typedef enum
{
KEY_CODE_ROT = 0, //旋钮code值
KEY_CODE_ENT = 103, //按钮code值
KEY_CODE_UP, //上拨code值
KEY_CODE_DN, //下拨code值
KEY_CODE_LT, //左拨code值
KEY_CODE_RT, //右拨code值
KEY_CODE_END
} KEY_CODE;
typedef enum
{
KEY_VALUE_LROT = 1, //左旋value值
KEY_VALUE_RROT = -1, //右旋value值
KEY_VALUE_NP = 0, //按下value值
KEY_VALUE_NR = 1, //释放value值
KEY_VALUE_END
} KEY_VALUE;
typedef struct KeyList
{
int index;
int code;
int value;
int ret;
} RD163A_KEY_LIST;
int retKey(int code, int value)
{
RD163A_KEY_LIST keyList[] = {
{0, KEY_CODE_ROT, KEY_VALUE_LROT, KRY_PSB_LROT},
{1, KEY_CODE_ROT, KEY_VALUE_RROT, KRY_PSB_RROT},
};
int cnt = 0;
for (cnt = 0; cnt < 2; cnt++)
{
if (keyList[cnt].code == code)
{
if (keyList[cnt].value == value)
{
return keyList[cnt].ret;
}
}
}
return 0;
}
int keyexFlag = 0;
int retKeyex(int code, int value)
{
RD163A_KEY_LIST keyList[] = {
{2, KEY_CODE_ENT, KEY_VALUE_NP, KRY_PSB_ENTP},
{3, KEY_CODE_ENT, KEY_VALUE_NR, KRY_PSB_ENTR},
{4, KEY_CODE_UP, KEY_VALUE_NP, KRY_PSB_UPP},
{5, KEY_CODE_UP, KEY_VALUE_NR, KRY_PSB_UPR},
{6, KEY_CODE_DN, KEY_VALUE_NP, KRY_PSB_DNP},
{7, KEY_CODE_DN, KEY_VALUE_NR, KRY_PSB_DNR},
{8, KEY_CODE_LT, KEY_VALUE_NP, KRY_PSB_LTP},
{9, KEY_CODE_LT, KEY_VALUE_NR, KRY_PSB_LTR},
{10, KEY_CODE_RT, KEY_VALUE_NP, KRY_PSB_RTP},
{11, KEY_CODE_RT, KEY_VALUE_NR, KRY_PSB_RTR}};
int cnt = 0;
for (cnt = 2; cnt < 10; cnt++)
{
if ((keyList[cnt].code == code) && (keyList[cnt].value == value))
{
if (value == 0)
{
keyexFlag = 1;
return keyList[cnt].ret;
}
if (value == 1)
{
keyexFlag = 0;
return keyList[cnt].ret;
}
}
}
for (cnt = 0; cnt < 2; cnt++)
{
if (keyList[cnt].code == code)
{
if ((value == 0) && (keyexFlag == 0))
{
return keyList[cnt].ret;
}
}
}
return 0;
}
void psbHandler(void *p)
{
// printf("===================into psbHandler======================\n");
struct input_event in;
int tempVal = 0;
while (1)
{
// printf("psbHandler\n");
if (read(keypaddev_fd, &in, sizeof(struct input_event)) > 0)
{
// printf("keypaddev_read KEY_CODE=%d KEY_NUM=%d\n", in.code, in.value); // psb的数值
tempVal = retKey(in.code, in.value);
if (tempVal == 0)
{
}
else
{
keyValue = tempVal;
// printf("keyValue=%d\n",keyValue);
}
}
usleep(1 * 1000);
}
return keyValue;
}
void psbexHandler(void *p)
{
// printf("======================into psbexHandler================\n");
struct input_event in;
int tempVal = 0;
while (1)
{
// printf("psbexHandler\n");
if (read(keypaddev_fdex, &in, sizeof(struct input_event)) > 0)
{
// printf("keypaddev_readex KEY_CODE=%d KEY_NUM=%d \n", in.code, in.value); // psb的数值
tempVal = retKeyex(in.code, in.value);
if (tempVal == 0)
{
}
else
{
keyValue = tempVal;
// printf("keyValue=%d\n",keyValue);
}
}
usleep(1 * 1000);
}
return keyValue;
}
void psbInit(void)
{
// printf("enter psb init.\n");
pthread_t thread;
// printf("pthread_t create.\n");
keypaddev_fd = open("/dev/input/event1", O_RDONLY); //打开event1
// printf("has opened event1.\n");
if (keypaddev_fd <= 0)
{
// printf("unable open keypad interface,error code:%d.\n", keypaddev_fd);
return;
}
// printf("open event1 successfully,will create pthread.\n");
pthread_create(&thread, NULL, psbHandler, NULL); //用handler读和处理
// printf("create pthread successfully.\n");
return;
}
void psbexInit(void)
{
// printf("enter psb init.\n");
pthread_t thread;
// printf("pthread_t create.\n");
keypaddev_fdex = open("/dev/input/event2", O_RDONLY); //打开event2
// printf("has opened event2.\n");
if (keypaddev_fdex <= 0)
{
// printf("unable open keypad interface,error code:%d.\n", keypaddev_fdex);
return;
}
// printf("open event2 successfully,will create pthread.\n");
pthread_create(&thread, NULL, psbexHandler, NULL); //用handler读和处理
// printf("create pthread successfully.\n");
return;
}
int psbGetValue(void)
{
return keyValue;
}
void psbClearValue(void)
{
keyValue = 0;
return;
}
void pwmInit(void)
{
// printf("c-pwm:init\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 600000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
system("echo normal > /sys/class/pwm/pwmchip0/pwm1/polarity"); /*设置pwm1的极性:normal 正极性,inverse 负极性*/
system("echo 0 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
void pwmLv1(void)
{
// printf("c-pwm:lv1 on\n");
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 200000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv2(void)
{
// printf("c-pwm:lv2 on\n");
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm2的周期,单位是ns*/
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm2的占空比,单位是ns*/
return;
}
void pwmLv3(void)
{
// printf("c-pwm:lv3 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm3功能位*/
system("echo 600000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm3的周期,单位是ns*/
system("echo 200000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm3的占空比,单位是ns*/
return;
}
void pwmLv4(void)
{
// printf("c-pwm:lv4 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm4功能位*/
system("echo 600000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm4的周期,单位是ns*/
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm4的占空比,单位是ns*/
return;
}
void pwmLv5(void)
{
// printf("c-pwm:lv5 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm5功能位*/
system("echo 600000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm5的周期,单位是ns*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm5的占空比,单位是ns*/
return;
}
void pwmLv6(void)
{
// printf("c-pwm:lv6 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm6功能位*/
system("echo 700000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm6的周期,单位是ns*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm6的占空比,单位是ns*/
return;
}
void pwmOff(void)
{
// printf("c-pwm:off\n");
system("echo 0 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
void pwmOn(void)
{
// printf("c-pwm:off\n");
system("echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
void pwmInit(void)
{
printf("c-pwm:init\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 120000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
system("echo normal > /sys/class/pwm/pwmchip0/pwm1/polarity"); /*设置pwm1的极性:normal 正极性,inverse 负极性*/
system("echo 0 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
void pwmLv1(void)
{
printf("c-pwm:lv1 on\n");
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 120000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv2(void)
{
printf("c-pwm:lv2 on\n");
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 90000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv3(void)
{
printf("c-pwm:lv3 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 160000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv4(void)
{
printf("c-pwm:lv4 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 120000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv5(void)
{
printf("c-pwm:lv5 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 200000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv6(void)
{
printf("c-pwm:lv6 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 150000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmOff(void)
{
printf("c-pwm:off\n");
system("echo 0 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
void pwmOn(void)
{
printf("c-pwm:off\n");
system("echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
// system("echo 163 > /sys/class/gpio/unexport"); /*释放对应编号的io口*/
void gpio1On(char val)
{
system("echo 1 > /sys/class/gpio/gpio132/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio1Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio132/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio2On(char val)
{
system("echo 1 > /sys/class/gpio/gpio133/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio2Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio133/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio3On(char val)
{
system("echo 1 > /sys/class/gpio/gpio135/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio3Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio135/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio4On(char val)
{
system("echo 1 > /sys/class/gpio/gpio136/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio4Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio136/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio5On(char val)
{
system("echo 1 > /sys/class/gpio/gpio137/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio5Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio137/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio6On(char val)
{
system("echo 1 > /sys/class/gpio/gpio138/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio6Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio138/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio7On(char val)
{
system("echo 1 > /sys/class/gpio/gpio139/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio7Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio139/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void insModEncoder(void)
{
system("insmod /etc/rotary_encoder_device.ko ");
system("insmod /etc/rotary_encoder.ko");
system("insmod /etc/gpio_keys.ko");
}
void rmModEncoder(void)
{
system("rmmod /etc/gpio_keys.ko");
system("rmmod /etc/rotary_encoder.ko");
system("rmmod /etc/rotary_encoder_device.ko ");
}
void gpioUnexport(void)
{
system("echo 132 > /sys/class/gpio/unexport");
system("echo 133 > /sys/class/gpio/unexport");
system("echo 135 > /sys/class/gpio/unexport");
system("echo 136 > /sys/class/gpio/unexport");
system("echo 137 > /sys/class/gpio/unexport");
system("echo 138 > /sys/class/gpio/unexport");
system("echo 139 > /sys/class/gpio/unexport");
}
void gpioInit(void)
{
system("echo 132 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio132/direction");
system("echo 0 > /sys/class/gpio/gpio132/value");
system("echo 133 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio133/direction");
system("echo 0 > /sys/class/gpio/gpio133/value");
system("echo 135 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio135/direction");
system("echo 0 > /sys/class/gpio/gpio135/value");
system("echo 136 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio136/direction");
system("echo 0 > /sys/class/gpio/gpio136/value");
system("echo 137 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio137/direction");
system("echo 0 > /sys/class/gpio/gpio137/value");
system("echo 138 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio138/direction");
system("echo 0 > /sys/class/gpio/gpio138/value");
system("echo 139 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio139/direction");
system("echo 0 > /sys/class/gpio/gpio139/value");
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
void pwmInit(void)
{
printf("c-pwm:init\n");
system("echo 3 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm3/period"); /*设置pwm1的周期,单位是ns*/
system("echo 120000 > /sys/class/pwm/pwmchip0/pwm3/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
system("echo normal > /sys/class/pwm/pwmchip0/pwm3/polarity"); /*设置pwm1的极性:normal 正极性,inverse 负极性*/
system("echo 0 > /sys/class/pwm/pwmchip0/pwm3/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
// void pwmLv0(void)
// {
// printf("c-pwm:lv0 on\n");
// system("echo 434782 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
// system("echo 217391> /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
// return;
// }
void pwmLv1(void)
{
printf("c-pwm:lv1 on\n");
system("echo 434782 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 217391 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv2(void)
{
printf("c-pwm:lv2 on\n");
system("echo 300000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 90000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv3(void)
{
printf("c-pwm:lv3 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 160000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv4(void)
{
printf("c-pwm:lv4 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 400000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 120000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv5(void)
{
printf("c-pwm:lv5 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 200000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmLv6(void)
{
printf("c-pwm:lv6 on\n");
system("echo 1 > /sys/class/pwm/pwmchip0/export"); /*启动pwm1功能位*/
system("echo 500000 > /sys/class/pwm/pwmchip0/pwm1/period"); /*设置pwm1的周期,单位是ns*/
system("echo 150000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle"); /*设置pwm1的占空比,单位是ns*/
return;
}
void pwmOff(void)
{
printf("c-pwm:off\n");
system("echo 0 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
void pwmOn(void)
{
printf("c-pwm:off\n");
system("echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable"); /*使能pwm1,1 使能,0 禁用*/
return;
}
// system("echo 163 > /sys/class/gpio/unexport"); /*释放对应编号的io口*/
void gpio1On(char val)
{
system("echo 1 > /sys/class/gpio/gpio132/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio1Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio132/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio2On(char val)
{
system("echo 1 > /sys/class/gpio/gpio133/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio2Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio133/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio3On(char val)
{
system("echo 1 > /sys/class/gpio/gpio135/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio3Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio135/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio4On(char val)
{
system("echo 1 > /sys/class/gpio/gpio136/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio4Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio136/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio5On(char val)
{
system("echo 1 > /sys/class/gpio/gpio137/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio5Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio137/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio6On(char val)
{
system("echo 1 > /sys/class/gpio/gpio138/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio6Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio138/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio7On(char val)
{
system("echo 1 > /sys/class/gpio/gpio139/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void gpio7Off(char val)
{
system("echo 0 > /sys/class/gpio/gpio139/value"); /*使能io口的高低电平:1 高电平,0 低电平*/
return;
}
void insModEncoder(void)
{
system("insmod /etc/rotary_encoder_device.ko ");
system("insmod /etc/rotary_encoder.ko");
system("insmod /etc/gpio_keys.ko");
}
void rmModEncoder(void)
{
system("rmmod /etc/gpio_keys.ko");
system("rmmod /etc/rotary_encoder.ko");
system("rmmod /etc/rotary_encoder_device.ko ");
}
void gpioUnexport(void)
{
system("echo 132 > /sys/class/gpio/unexport");
system("echo 133 > /sys/class/gpio/unexport");
system("echo 135 > /sys/class/gpio/unexport");
system("echo 136 > /sys/class/gpio/unexport");
system("echo 137 > /sys/class/gpio/unexport");
system("echo 138 > /sys/class/gpio/unexport");
system("echo 139 > /sys/class/gpio/unexport");
}
void gpioInit(void)
{
system("echo 132 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio132/direction");
system("echo 0 > /sys/class/gpio/gpio132/value");
system("echo 133 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio133/direction");
system("echo 0 > /sys/class/gpio/gpio133/value");
system("echo 135 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio135/direction");
system("echo 0 > /sys/class/gpio/gpio135/value");
system("echo 136 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio136/direction");
system("echo 0 > /sys/class/gpio/gpio136/value");
system("echo 137 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio137/direction");
system("echo 0 > /sys/class/gpio/gpio137/value");
system("echo 138 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio138/direction");
system("echo 0 > /sys/class/gpio/gpio138/value");
system("echo 139 > /sys/class/gpio/export");
system("echo out > /sys/class/gpio/gpio139/direction");
system("echo 0 > /sys/class/gpio/gpio139/value");
}
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
// cmd length
#define CMD_LENGTH 100
// 通用字符串
#define CS_ECHO "echo "
#define CS_REDIRECT " > "
#define CS_IN "in"
#define CS_OUT "out"
#define CS_NORMAL "normal"
#define CS_INVERSE "inverse"
// rtc
#define CS_RTC_DATE "date "
#define CS_RTC_HWCLOCK "hwclock "
#define HWCLOCK_W " -w"
#define DATE_S " -s"
// 公共函数
int retIntBits(int value)
{
int bit = 0;
while (1)
{
int res = value % 10;
int resEx = value / 10;
value /= 10;
if (res != 0 || resEx != 0)
{
bit++;
}
else
{
if (bit == 0)
{
bit = 1;
}
return bit;
}
}
}
int strToInt(char c)
{
int res = -1;
res = c - '0';
return res;
}
char *intToStr(int value)
{
int bits = retIntBits(value);
char *p = (char *)malloc(bits + 1);
int cnt = 0;
for (cnt = 0; cnt < bits; cnt++)
{
*(p + cnt) = '0' + value / pow(10, bits - cnt - 1);
value %= (int)pow(10, bits - cnt - 1);
}
*(p + cnt) = '\0';
return p;
}
// 指令构建函数
char *rtcDate(const char *option,
int year,
int month,
int day,
int hour,
int minute,
int second)
{
char *sValue;
sValue = intToStr(year);
char *resString = (char *)malloc(CMD_LENGTH);
memset(resString, 0, CMD_LENGTH);
strcat(resString, CS_RTC_DATE);
strcat(resString, option);
strcat(resString, " \"");
strcat(resString, sValue);
strcat(resString, "-");
sValue = intToStr(month);
strcat(resString, sValue);
strcat(resString, "-");
sValue = intToStr(day);
strcat(resString, sValue);
strcat(resString, " ");
sValue = intToStr(hour);
strcat(resString, sValue);
strcat(resString, ":");
sValue = intToStr(minute);
strcat(resString, sValue);
strcat(resString, ":");
sValue = intToStr(second);
strcat(resString, sValue);
strcat(resString, "\"");
free(sValue);
return resString;
}
char *rtcHwclock(const char *option)
{
char *resString = (char *)malloc(CMD_LENGTH);
memset(resString, 0, CMD_LENGTH);
strcat(resString, CS_RTC_HWCLOCK);
strcat(resString, option);
return resString;
}
// 指令外部声明函数
void set(int year,
int month,
int day,
int hour,
int minute,
int second)
{
char *p = rtcDate(DATE_S,
year,
month,
day,
hour,
minute,
second);
printf("set=%s\n", p);
system(p);
free(p);
p = rtcHwclock(HWCLOCK_W);
printf("set=%s\n", p);
system(p);
free(p);
return;
}
int isRTC(char *name)
{
int maxlen = 50;
char buf[50] = {0};
printf("isRTC function is run!");
memset(buf, 0, maxlen);
// system("hwclock\n");
// system("ls /sys/class/rtc/ | grep rtc1");
printf("Find RTC Name is %s\n", name);
FILE *stream = popen("ls /sys/class/rtc/ | grep rtc1", "r");
if (stream != NULL)
{
fread(buf, 1, maxlen, stream);
char *strp = strstr(buf, name);
if (strp != NULL)
{
printf("RTC Finded!");
return 1;
}
}
printf("RTC NOT Finded!");
return 0;
}
\ No newline at end of file
#include <fcntl.h>
#include <linux/input.h>
#include <math.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#define MOUNT_POINT "/mnt/exUDISK/swuUpdate"
#define INTERVAL 1 // 检查间隔,单位:秒
#define BUFFER_SIZE 2048
#define ENV_CMD "fw_printenv -n %s 2>/dev/null"
#define SET_CMD "fw_setenv %s %s"
void executeSync(int value) {
system("sync");
return;
}
bool get_env(const char* name, char* buf, size_t len) {
char cmd[128];
snprintf(cmd, sizeof(cmd), ENV_CMD, name);
FILE* fp = popen(cmd, "r");
if (!fp) return false;
bool ret = (fgets(buf, len, fp) != NULL);
pclose(fp);
// 去除换行符
buf[strcspn(buf, "\n")] = '\0';
return ret;
}
int checkPartition(int value) {
printf("++++++++++++++start to checkPartition\n");
FILE *fp_check;
char buffer[BUFFER_SIZE] = {0};
size_t bytesRead;
int checkFlag = 0;
char partitionValue[1] = {0};
// 使用 popen 执行命令
// // 假设这是一个有效的命令
fp_check =
popen("fw_printenv | grep 'appAB='", "r"); // 假设这是一个有效的命令
if (fp_check == NULL) {
perror("popen failed");
return 1;
}
// 读取扫描结果
while (fgets(buffer, sizeof(buffer), fp_check)) {
printf("++++++++++++++popen checkPartition result is %s", buffer);
}
partitionValue[0] = buffer[6];
printf("+++++++++partitionValue=%s", partitionValue);
printf("+++++++++partitionValue=%c", partitionValue[0]);
if (partitionValue[0] == 'A') {
checkFlag = 0; //表示当前分区是A分区
} else {
checkFlag = 1; //表示当前分区是B分区
}
if (ferror(fp_check)) {
perror("fread error");
}
pclose(fp_check);
printf("++++++++++++++checkFlag=%d\n", checkFlag);
return checkFlag;
}
// int checkPartition(int value) {
// printf("++++++++++++++start to checkPartition\n");
// FILE *fp_check;
// char buffer[BUFFER_SIZE] = {0};
// size_t bytesRead;
// int checkFlag = 0;
// char partitionValue[1] = {0};
// // 使用 popen 执行命令
// // // 假设这是一个有效的命令
// fp_check =
// popen("fw_printenv | grep 'boot_partition='", "r"); // 假设这是一个有效的命令
// if (fp_check == NULL) {
// perror("popen failed");
// return 1;
// }
// // 读取扫描结果
// while (fgets(buffer, sizeof(buffer), fp_check)) {
// printf("++++++++++++++popen checkPartition result is %s", buffer);
// }
// partitionValue[0] = buffer[6];
// printf("+++++++++partitionValue=%s", partitionValue);
// printf("+++++++++partitionValue=%c", partitionValue[0]);
// if (partitionValue[0] == 'bootA') {
// checkFlag = 0; //表示当前分区是A分区
// } else {
// checkFlag = 1; //表示当前分区是B分区
// }
// if (ferror(fp_check)) {
// perror("fread error");
// }
// pclose(fp_check);
// printf("++++++++++++++checkFlag=%d\n", checkFlag);
// return checkFlag;
// }
int findSwuFile(int value) {
// printf("+++++++++++++++++findSwuFile is OK!\n");
printf("++++++++++++++start to findSwuFile\n");
FILE *fp_in;
char buffer[BUFFER_SIZE] = {0};
size_t bytesRead;
int findSwuFile = 0;
// system("cp /mnt/exUDISK/swuUpdate/msdk_t113_bcmdhd /mnt/UDISK");
// system("chmod -R 777 /mnt/UDISK/msdk_t113_bcmdhd");
// system("sync");
// 使用 popen 执行命令
if (value == 0) {
fp_in = popen("find /mnt/exUDISK/swuUpdate/*.swu | grep 'openwrt_t113_evb1-ab.swu'","r"); // 假设这是一个有效的命令
if (fp_in == NULL) {
perror("popen failed");
return 2;
}
// 读取扫描结果
if (fgets(buffer, sizeof(buffer), fp_in) != NULL) {
printf("++++++++++++++popen findSwuFile result is %s", buffer);
findSwuFile = 0; // 表示查找swu文件成功
}
// 检查并处理任何可能的错误
else {
findSwuFile = 2; // 表示查找swu文件失败
}
}
else{
fp_in = popen("find /mnt/exUDISK/swuUpdate/*.swu | grep 'openwrt_t113_evb1-ba.swu'","r"); // 假设这是一个有效的命令
if (fp_in == NULL) {
perror("popen failed");
return 2;
}
// 读取扫描结果
if (fgets(buffer, sizeof(buffer), fp_in) != NULL) {
printf("++++++++++++++popen findSwuFile result is %s", buffer);
findSwuFile = 1; // 表示查找swu文件成功
}
// 检查并处理任何可能的错误
else {
findSwuFile = 2; // 表示查找swu文件失败
}
}
if (ferror(fp_in)) {
perror("fread error");
}
pclose(fp_in);
printf("++++++++++++++findSwuFile=%d\n", findSwuFile);
return findSwuFile;
}
int executeUpdate(int value) {
printf("++++++++++++++start to executeUpdate\n");
FILE *fp_update;
char buffer[BUFFER_SIZE] = {0};
size_t bytesRead;
int updateFlag = 0;
// 使用 popen 执行命令
// fp_update = popen("swupdate -v -i /mnt/exUDISK/swuUpdate/openwrt_t113_evb1-ab.swu","r");
// // 假设这是一个有效的命令
if (value == 0) {
fp_update = popen("swupdate -v -i /mnt/exUDISK/swuUpdate/openwrt_t113_evb1-ab.swu -e stable,now_A_next_B | grep 'SWUPDATE successful !'","r"); // 假设这是一个有效的命令
}
else if(value == 1){
fp_update = popen("swupdate -v -i /mnt/exUDISK/swuUpdate/openwrt_t113_evb1-ba.swu -e stable,now_B_next_A | grep 'SWUPDATE successful !'","r"); // 假设这是一个有效的命令
}
else{
return 0;
}
if (fp_update == NULL) {
perror("popen failed");
return 1;
}
// 读取扫描结果
while (fgets(buffer, sizeof(buffer), fp_update)) {
printf("++++++++++++++popen executeUpdate result is %s", buffer);
updateFlag = 1; // 表示swu升级成功
}
// // 检查并处理任何可能的错误
// else {
// updateFlag = 0; // 表示swu升级失败
// }
if (ferror(fp_update)) {
perror("fread error");
}
pclose(fp_update);
printf("++++++++++++++updateFlag=%d\n", updateFlag);
return updateFlag;
}
// 执行系统命令的函数
int executeSystemCommand(const char *cmd) {
int status = system(cmd);
if (status == -1) {
perror("system() failed");
return -1;
} else {
printf("命令执行状态码: %d\n", WEXITSTATUS(status));
return status;
}
}
//传入一个参数str,打印str
int executePrint(const char *str) {
printf("%s", str); // 使用固定格式字符串
}
void systemReboot(int value) {
system("sync");
system("reboot");
return;
}
int main(int value) {
printf("There are in systemCtrl main function!");
int num=0;
num=executeUpdate(1);
printf("num=%d\n",num);
return 0;
}
// void runswuUpdate(int value) {
// system("swupdate -v -i /mnt/exUDISK/swuUpdate/openwrt_t113_evb1-ab.swu -e "
// "stable,now_B_next_A");
// return;
// }
// void execute_upgrade() {
// // 假设执行升级的命令是 "swu_update"
// char *upgrade_command[] = {"/mnt/exUDISK/swuUpdate/openwrt_t113_evb1-ab.swu", NULL};
// pid_t pid = fork();
// if (pid == 0) { // 子进程
// execvp(upgrade_command, upgrade_command);
// printf("Error executing upgrade command.\n");
// _exit(EXIT_FAILURE);
// } else if (pid > 0) {
// // 父进程等待子进程结束
// wait(NULL);
// }
// }
// int check_for_swu() {
// char find_command[128];
// snprintf(find_command, sizeof(find_command), "find %s -name '*.swu'",
// MOUNT_POINT);
// FILE *fp = popen(find_command, "r");
// if (fp == NULL) {
// perror("popen failed");
// return -1;
// }
// char line[256];
// if (fgets(line, sizeof(line), fp) != NULL) {
// // 找到了.swu文件
// pclose(fp);
// return 1;
// }
// pclose(fp);
// return 0;
// }
// void systemMain(int value) {
// printf("value=%d\n", value);
// if (value == 0) {
// return 0;
// }
// while (1) {
// if (check_for_swu()) {
// printf("Found .swu file, starting upgrade...\n");
// execute_upgrade();
// printf("Upgrade completed, exiting.\n");
// break;
// }
// printf("Checking for .swu file...\n");
// sleep(INTERVAL);
// }
// return 0;
// }
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <pthread.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <stdbool.h>
// cmd length
#define CMD_LENGTH 100
// 通用字符串
#define CS_ECHO "echo "
#define CS_REDIRECT " > "
#define CS_IN "in"
#define CS_OUT "out"
#define CS_NORMAL "normal"
#define CS_INVERSE "inverse"
// rtc
#define CS_RTC_DATE "date "
#define CS_RTC_HWCLOCK "hwclock "
#define HWCLOCK_W " -w"
#define DATE_S " -s"
#define BUFFER_SIZE 1024
#define KEYWORDS "re867a_test"
int globalSignalValue = -61;
// 公共函数
int retIntBits(int value)
{
int bit = 0;
while (1)
{
int res = value % 10;
int resEx = value / 10;
value /= 10;
if (res != 0 || resEx != 0)
{
bit++;
}
else
{
if (bit == 0)
{
bit = 1;
}
return bit;
}
}
}
int strToInt(char c)
{
int res = -1;
res = c - '0';
return res;
}
char *intToStr(int value)
{
int bits = retIntBits(value);
char *p = (char *)malloc(bits + 1);
int cnt = 0;
for (cnt = 0; cnt < bits; cnt++)
{
*(p + cnt) = '0' + value / pow(10, bits - cnt - 1);
value %= (int)pow(10, bits - cnt - 1);
}
*(p + cnt) = '\0';
return p;
}
bool contains_string(const char *filename, const char *target_string)
{
FILE *file = fopen(filename, "r");
if (file == NULL)
{
perror("Error opening file");
return false;
}
char buffer[1024]; // 缓冲区大小,可以根据需要调整
size_t bytesRead;
bool found = false;
// 逐块读取文件内容
while ((bytesRead = fread(buffer, 1, sizeof(buffer) - 1, file)) > 0)
{
// 确保字符串在缓冲区内以null终止
buffer[bytesRead] = '\0';
// 使用strstr搜索目标字符串
if (strstr(buffer, target_string) != NULL)
{
found = true;
break; // 找到后退出循环
}
// 如果字符串可能在块边界被分割,可以继续搜索剩余的缓冲区(如果需要)
// 但在这个例子中,我们假设目标字符串不会在块边界被分割
}
printf("++++++++++buffer=%s\n", buffer);
fclose(file);
return found;
}
typedef struct EVEN_WIFI_DATA_ANALYSIS
{
char *MAC;
char *delay;
char *db;
char *type;
char *name;
} EVEN_WIFI_DATA_ANALYSIS;
#define WIFI_PACKAGE_WORD_NUMBER 5
EVEN_WIFI_DATA_ANALYSIS wifi_analysis_package(char *str, unsigned int length)
{
// printf("start run wifi_analysis_package function\n");
EVEN_WIFI_DATA_ANALYSIS ewda;
char *head_p = str;
printf("188 str=%s\n", str);
for (int i = 0; i < length; i++)
{
printf("188 str=%x\n", str[i]);
}
usleep(500000);
char *token;
char *saveptr = NULL; // strtok_r 需要这个,但 strtok 不需要
// 注意:strtok 会修改原始字符串,因为它用 '\0' 替换分隔符
// 如果原始字符串不能被修改,你需要先复制它
// 获取第一个令牌
const char *HTbuffer = "\t";
token = strtok(str, HTbuffer);
int count = 0;
while (token != NULL && count <= 5)
{
printf("Token %d: %s\n", count + 1, token);
if (count == 2)
{
ewda.db = token;
}
else if (count == 4)
{
ewda.name = token;
}
// 获取下一个令牌
token = strtok(NULL, HTbuffer);
count++;
}
printf("ewda.db: %s\n", ewda.db);
printf("ewda.name: %s\n", ewda.name);
return ewda;
char *p_buf[sizeof(ewda) / sizeof(char *)] = {ewda.MAC,
ewda.delay,
ewda.db,
ewda.type,
ewda.name};
for (int cnt = 0; cnt < WIFI_PACKAGE_WORD_NUMBER;)
{
char *p = strstr(head_p, " ");
if (p - head_p > 1)
cnt++;
else
{
head_p = p;
continue;
}
p_buf[cnt] = (char *)malloc(p - head_p);
memcpy(p_buf[cnt], head_p, p - head_p);
head_p = p;
printf("p_buf[cnt]=%s\n", p_buf[cnt]);
}
printf("ewda.MAC=%s\n", ewda.MAC);
return ewda;
}
int getWifiSignalLevel(char *name)
{
return globalSignalValue;
}
int isWifi(char *name)
{
FILE *fp_in;
char buffer[BUFFER_SIZE] = {0};
size_t bytesRead;
int testFlag = 0;
// 使用 popen 执行命令
system("killall wpa_supplicant");
system("wpa_supplicant -i wlan0 -c /usr/app/quicknode/tests/867factory_test/test.conf -B -d");
struct timespec ts;
ts.tv_sec = 4; // 秒
ts.tv_nsec = 0; // 纳秒
nanosleep(&ts, NULL); // 延时1秒
system("wpa_cli -i wlan0 scan");
// 使用 popen 执行命令
// fp_in = popen("wpa_cli -i wlan0 -p /etc/wifi/wpa_supplicant/sockets scan_result | grep 're832test' | grep 'signal:' | awk '{print $2}'", "r"); // 假设这是一个有效的命令
fp_in = popen("wpa_cli -i wlan0 scan_result | grep 're867a_test' ", "r"); // 假设这是一个有效的命令
if (fp_in == NULL)
{
perror("popen failed");
return 1;
}
// 读取扫描结果
if (fgets(buffer, sizeof(buffer), fp_in) != NULL)
{
printf("++++++++++++++popen 178 result is %s\n", buffer);
EVEN_WIFI_DATA_ANALYSIS info = wifi_analysis_package(buffer, strlen(buffer));
// 打印结果以验证
// printf("MAC: %s\n", info.MAC);
// printf("Freq: %s\n", info.delay);
printf("Signal: %s\n", info.db);
// printf("Security: %s\n", info.type);
printf("SSID: %s\n", info.name);
globalSignalValue = atoi(info.db);
if ((strstr(info.name, "re867a_test") != NULL) && strlen(info.name) == 12)
{
printf("++++++++++++++++++found right SSID,continue!\n");
printf("++++++++++++++++++Signal Level is OK!");
testFlag = 1; // 表示wifi查找成功
}
else
{
printf("++++++++++++++++++Not Found right SSID,return!\n");
testFlag = 0; // 表示wifi查找失败
printf("SSID: %s\n", info.name);
printf("SSID length: %d\n", strlen(info.name));
}
}
// printf("++++++++++++++popen scan re867a_test result is%s\n", buffer);
// 检查并处理任何可能的错误
else
{
testFlag = 0; // 表示wifi测试失败
}
if (ferror(fp_in))
{
perror("fread error");
}
pclose(fp_in);
system("killall wpa_supplicant");
return testFlag;
}
int initWifi(char *name)
{
printf("start run initWifi function\n");
system("wpa_supplicant -i wlan0 -c /usr/app/quicknode/tests/867factory_test/test.conf -B -d");
}
char *getVersion(char *name)
{
FILE *fp;
char path[1024];
// 注意:这里将整个命令(包括管道)用引号括起来,并指定/bin/sh来执行它
fp = popen("fw_printenv | grep swu_version", "r");
// fp = popen("/bin/sh -c 'fw_printenv | grep swu_version'", "r");
if (fp == NULL)
{
printf("Failed to run command\n");
exit(1);
}
// 读取输出
while (fgets(path, sizeof(path) - 1, fp) != NULL)
{
printf("path=%s", path);
}
char *equal_pos = strchr(path, '=');
if (equal_pos == NULL)
{
// 如果没有找到'=',返回NULL
return NULL;
}
// 分配足够的内存来存储'='之后的部分(包括终止符'\0')
size_t len = strlen(equal_pos + 1) + 1; // +1 跳过'='字符,+1 用于'\0'
char *result = (char *)malloc(len);
if (result == NULL)
{
// 如果内存分配失败,返回NULL
return NULL;
}
// 复制'='之后的部分到新的字符串中
strncpy(result, equal_pos + 1, len); // +1 跳过'='字符
// printf("result=%s\n", result);
// 关闭文件流
pclose(fp);
return result;
// return 0;
}
char *get_wifi_mac() {
FILE *fp;
static char mac_addr[32];
char cmd[128] = "ifconfig wlan0 2>/dev/null | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'";
char buffer[64];
// 执行命令并读取输出
fp = popen(cmd, "r");
if (fp == NULL) {
perror("popen failed");
return NULL;
}
// 读取 MAC 地址
if (fgets(buffer, sizeof(buffer), fp) != NULL) {
// 去除可能的换行符
buffer[strcspn(buffer, "\n")] = '\0';
if (strlen(buffer) > 0) {
strncpy(mac_addr, buffer, sizeof(mac_addr));
pclose(fp);
return mac_addr; // 成功
}
}
pclose(fp);
return NULL; // 失败
}
int syncSave(char *name)
{
printf("Save product_res.json\n");
system("sync");
return 1;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <errno.h>
#define SERIAL_PORT "/dev/ttyS1"
#define BAUDRATE B115200
// 初始化串口
int init_serial(int fd) {
struct termios tty;
memset(&tty, 0, sizeof(tty));
if (tcgetattr(fd, &tty) != 0) {
perror("tcgetattr");
return -1;
}
// 设置波特率
cfsetospeed(&tty, BAUDRATE);
cfsetispeed(&tty, BAUDRATE);
// 8N1模式(8数据位,无校验,1停止位)
tty.c_cflag &= ~PARENB;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
// 禁用流控
tty.c_cflag &= ~CRTSCTS;
tty.c_iflag &= ~(IXON | IXOFF | IXANY);
// 原始模式(禁用规范输入和回显)
tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
tty.c_oflag &= ~OPOST;
// 超时设置:5s返回,最少读取1字节
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
if (tcsetattr(fd, TCSANOW, &tty) != 0) {
perror("tcsetattr");
return -1;
}
return 0;
}
// 发送AT指令并读取响应
int send_at_command(int fd, const char *cmd, char *resp, size_t resp_len) {
char buf[256];
ssize_t n;
// 清空缓冲区
tcflush(fd, TCIOFLUSH);
// 发送指令
printf("Sending: %s\n", cmd);
write(fd, cmd, strlen(cmd));
write(fd, "\r\n", 2);
// 读取结果
memset(resp, 0, resp_len);
n = read(fd, resp, resp_len - 1);
if (n < 0) {
perror("read");
return -1;
}
printf("Response: %s\n", resp);
return 0;
}
char *get_ble_mac_address() {
int fd;
// char *mac;
static char ble_mac[128];
char resp[256];
memset(ble_mac, 0, sizeof(ble_mac));
// 打开串口设备
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
if (init_serial(fd) != 0) {
close(fd);
exit(EXIT_FAILURE);
}
// 发送AT指令并读取响应
if (send_at_command(fd, "AT+BLEMAC?", resp, sizeof(resp)) != 0) {
return NULL;
}
// 解析响应,获取MAC地址
mac = strstr(resp, "BLEMAC:");
if(mac != NULL)
{
mac += strlen("BLEMAC:");
strncpy(ble_mac, mac, strlen(mac) - 1);
return ble_mac;
}
else{
printf("BLE MAC not found\n");
return NULL;
}
}
int main()
{
printf("main get ble mac address is %s\n",get_ble_mac_address());
return
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <errno.h>
#define SERIAL_PORT "/dev/ttyUSB1"
#define BAUDRATE B115200
// 初始化串口
int init_serial(int fd) {
struct termios tty;
memset(&tty, 0, sizeof(tty));
if (tcgetattr(fd, &tty) != 0) {
perror("tcgetattr");
return -1;
}
// 设置波特率
cfsetospeed(&tty, BAUDRATE);
cfsetispeed(&tty, BAUDRATE);
// 8N1模式(8数据位,无校验,1停止位)
tty.c_cflag &= ~PARENB;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
// 禁用流控
tty.c_cflag &= ~CRTSCTS;
tty.c_iflag &= ~(IXON | IXOFF | IXANY);
// 原始模式(禁用规范输入和回显)
tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
tty.c_oflag &= ~OPOST;
// 超时设置:5S超时,最少读取1字节
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
if (tcsetattr(fd, TCSANOW, &tty) != 0) {
perror("tcsetattr");
return -1;
}
return 0;
}
// 发送AT指令并读取响应
int send_at_command(int fd, const char *cmd, char *resp, size_t resp_len) {
char buf[256];
ssize_t n;
// 清空缓冲区
tcflush(fd, TCIOFLUSH);
// 发送指令
printf("Sending: %s\n", cmd);
write(fd, cmd, strlen(cmd));
write(fd, "\r\n", 2);
// 读取结果
memset(resp, 0, resp_len);
n = read(fd, resp, resp_len - 1);
if (n < 0) {
perror("read");
return -1;
}
printf("Response: %s\n", resp);
return 0;
}
char *get_modem_signal()
{
int fd;
static char signal[512];
memset(signal, 0, sizeof(signal));
// 打开串口设备
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
if (init_serial(fd) != 0) {
close(fd);
exit(EXIT_FAILURE);
}
if (send_at_command(fd, "AT+CSQ", signal, sizeof(signal)) == 0) {
printf("Signal Strength: %s\n", signal);
}
return signal;
}
char *get_modem_iccid()
{
int fd;
static char iccid[512];
memset(iccid, 0, sizeof(iccid));
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
if (init_serial(fd) != 0) {
close(fd);
exit(EXIT_FAILURE);
}
if (send_at_command(fd, "AT+QCCID", iccid, sizeof(iccid)) == 0) {
printf("ICCID: %s\n", iccid);
}
return iccid;
}
char *get_modem_imei()
{
int fd;
static char imei[512];
memset(imei, 0, sizeof(imei));
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
if (init_serial(fd) != 0) {
close(fd);
}
if (send_at_command(fd, "AT+GSN", imei, sizeof(imei)) == 0) {
printf("imei: %s\n", imei);
}
return imei;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{"color":2,"touch":1,"wifi":2,"sound":0,"ble":0,"uartComm":0,"bright":0,"licenseAuthor":0,"systemCheck":0,"clearAll":0,"pcba":0,"start":0}
\ No newline at end of file
killall -9 quicknode
killall -9 main.sh
# chmod 777 -R /tmp/quicknode/tests/867factory_test/ 2>/dev/null &
# chmod 777 -R /usr/app/quicknode/tests/867factory_test/ 2>/dev/null &
if ! lsmod | grep -q quicklic; then
insmod usr/app/quicknode/bin/quicklic.ko
fi
# /tmp/quicknode/bin/quicknode /tmp/quicknode/tests/867factory_test/app.js --gui --width 720 --height 1280 --evdev /dev/input/event0 --licpath /mnt/advconfigA/files/ &
/usr/app/quicknode/bin/quicknode /usr/app/quicknode/tests/867factory_test/app.js --gui --width 720 --height 1280 --evdev /dev/input/event0 --licpath /mnt/advconfigA/files/ &
# $SCRIPT_DIR/quicknode/bin/quicknode $SCRIPT_DIR/quicknode/tests/gongniu5inch/app.q.min.js.bc --gui --width 720 --height 1280 --evdev /dev/input/event0 --licpath /mnt/advconfigA/files &
\ No newline at end of file
import json
# 初始化 point_item 列表
point_item = []
# 使用循环生成列表,步进为1
for x in range(0, 481): # x 从0到480,包含480
for y in range(0, 481): # y 从0到480,包含480
point_item.append({"id": f"id_point{x}_{y}"})
# 将数据写入 JSON 文件
with open("point_item.json", "w") as json_file:
json.dump(point_item, json_file, indent=4)
print("数据已成功写入 point_item.json 文件。")
\ No newline at end of file
-61
\ No newline at end of file
0
\ No newline at end of file
#!/bin/sh
while true
do
if grep -qs '/mnt/SDCARD' /proc/mounts; then
echo "It's mounted."
echo 1 > /mnt/UDISK/quicknode/update.txt
else
echo "It's not mounted."
echo 2 > /mnt/UDISK/quicknode/update.txt
fi
sleep 1
done
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