Commit 1c66cf7e authored by Tuzhiqiang1996's avatar Tuzhiqiang1996

增加重启和上电回复指令

parent 8885f443
#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>
int reboot(int val)
{
printf("reboot...%d\n",val);
system("reboot");
return 1;
}
\ No newline at end of file
var dlfcn = require("dlfcna.js");
console.log(dlfcn);
var funcs = [
["reboot", "ii"]
];
// "/usr/local/quicknode/enode_modules/rebootdevice.so",
console.log("in rebootdevice.js");
function register() {
console.log("will register rebootdevice.so");
var isSuccess = dlfcn.register(
"@native.rebootdevice",
"/usr/local/quicknode/enode_modules/rebootdevice.so",
funcs
);
if (isSuccess) {
console.log("load so successfully");
var rebootdevice = require("@native.rebootdevice");
return rebootdevice;
} else {
console.log("load so failed");
}
return undefined;
}
var rebootdevice = register();
function reboot() {
console.log("__________________________")
return rebootdevice.reboot(0);
}
module.exports = {
reboot:reboot
};
File added
File added
...@@ -36,6 +36,7 @@ var wwProto = globalThis["@native.ww"]; ...@@ -36,6 +36,7 @@ var wwProto = globalThis["@native.ww"];
var image = require("@native.image"); var image = require("@native.image");
var librtc = require("rtc.js"); var librtc = require("rtc.js");
var os = require("@system.os"); var os = require("@system.os");
var rebootdevice = require("rebootdevice.js");
//nodejs调试模式 //nodejs调试模式
var NodeJs = 0; var NodeJs = 0;
// 当前页面ID // 当前页面ID
...@@ -447,6 +448,17 @@ function qrcodeGetSrc(id, src) { ...@@ -447,6 +448,17 @@ function qrcodeGetSrc(id, src) {
var res = element.attributes.value; var res = element.attributes.value;
return res; return res;
} }
function start_test(args){
console.log('==='+args )
}
function reboot_device(rebootnum){
if (rebootnum=="1"){
console.log('==='+rebootnum )
rebootdevice.reboot()
}
}
function handleCallback(indexObj, funcId, args) { function handleCallback(indexObj, funcId, args) {
console.log("{ Get } funcId=" + funcId + " args=" + args); console.log("{ Get } funcId=" + funcId + " args=" + args);
// console.log(typeof args); // console.log(typeof args);
...@@ -482,14 +494,16 @@ function handleCallback(indexObj, funcId, args) { ...@@ -482,14 +494,16 @@ function handleCallback(indexObj, funcId, args) {
// push_page_and_refresh_caches, //22,跳转页面并立即刷新缓存 // push_page_and_refresh_caches, //22,跳转页面并立即刷新缓存
// write_cache, //23,写缓存 // write_cache, //23,写缓存
// indexObj.$show, //24:显示 // indexObj.$show, //24:显示
efix_show, //24:显示 efix_show, //22:显示
indexObj.$hide, //25:隐藏 indexObj.$hide, //23:隐藏
indexObj.$imageRender, //26:设置图片控件图片源 indexObj.$imageRender, //24:设置图片控件图片源
buttonGetKey, //27:获取按钮键值 buttonGetKey, //25:获取按钮键值
buttonSetKey, //28:设置按钮键值 buttonSetKey, //26:设置按钮键值
systemGetRunState, //29:系统功能 查询运行状态 systemGetRunState, //27:系统功能 查询运行状态
qrcodeGetSrc, //30 获取二维码内容 qrcodeGetSrc, //28 获取二维码内容
qrcodeSetSrc, //30 设置二维码内容 qrcodeSetSrc, //29 设置二维码内容
start_test,//30 开始
reboot_device,//31 重启
]; ];
} }
console.log("{ Server } funcName=" + funcAPIs[funcId]); console.log("{ Server } funcName=" + funcAPIs[funcId]);
...@@ -568,6 +582,24 @@ function touchClick(node) { ...@@ -568,6 +582,24 @@ function touchClick(node) {
node.attributes.KeySet = node.attributes.KeyCode; node.attributes.KeySet = node.attributes.KeyCode;
} }
function refreshPageMessage() {} function refreshPageMessage() {}
function start_senddata(){
var resArr = wwProto.response(undefined, 30);
var resU8Arr = new Uint8Array(resArr);
var resBinArr = Buffer.from(resU8Arr);
console.log("{ Resp } binBuffer");
resBinArr.print();
uartWW.write(resBinArr);
resBinArr.free();
console.log("{ Get } End.");
console.log("***************************")
}
var setTimeoutdata=setTimeout(function () {
start_senddata();
clearTimeout(setTimeoutdata);
}, 500);
module.exports = { module.exports = {
setup: setup, setup: setup,
touchClick: touchClick, touchClick: touchClick,
......
No preview for this file type
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