Commit 25754d9e authored by lyong's avatar lyong

feat:增加自动化RTC写入

parent c6c06710
......@@ -29,6 +29,7 @@ const cmdTable = [
{ kw: 'GET_CRC', fn: doGetCrc },
{ kw: 'TEST_END', fn: doEnd },
{ kw: 'RTC', fn: doGetRtc },
{ kw: 'WRITE_RTC', fn: doSetRtc },
];
const cmdTableHex = [
{ kw: '57524954455F4C4943', fn: doWriteLic }, //WRITE_LIC
......@@ -62,6 +63,23 @@ function doGetRtc(fd) {
console.log('RTC:' + time);
send(fd, time);
}
function doSetRtc(fd, recvBuf) {
console.log("doSetRtc " + recvBuf);
autoUtil.setRtc(recvBuf);
if (doSetRtc._rtcTimerOut === undefined) {
doSetRtc._rtcTimerOut = null;
}
if (doSetRtc._rtcTimerOut != null) {
clearTimeout(doSetRtc._rtcTimerOut);
doSetRtc._rtcTimerOut = null;
}
doSetRtc._rtcTimerOut = setTimeout(function () {
send(fd, '+OK');
}, 500);
}
function doVersion(fd) {
var version = "+" + userData.softwareVersion
......@@ -165,7 +183,7 @@ function doEnd(fd) {
function doWriteMac(fd, recvBuf) {
// const mac = recvBuf.split('=')[1].trim();
console.log('write mac:' + mac);
send(fd, '+OK');
send(fd, '+FAIL');
}
function doWriteSn(fd, recvBuf) {
const sn = recvBuf.split('=')[1].trim();
......
......@@ -233,8 +233,8 @@ function getTempHum() {
function writeLic(hexStr) {
var filePath1 = "/tmp/operation_license";
// var filePath2 = "/tmp/sn_data.bin";
const SECURE_APP_PATH = "/mnt/app/eOpteeCtrl"
// var filePath2 = "/tmp/sn_data.bin";
// const SECURE_APP_PATH = "/mnt/app/eOpteeCtrl"
console.log('Full license written:' + hexStr);
......@@ -247,7 +247,7 @@ function writeLic(hexStr) {
}
system("sync");
system(SECURE_APP_PATH + " -b " + filePath1);
// handleSNDataBinFile.writeInnerSNDataToBinFile(lic)
system("cp /tmp/operation_license /mnt/userdataA/files/");
system("/mnt/app/eMideaSetMac");
......@@ -594,6 +594,26 @@ function getMacAddressFromLicenseFile() {
return "FAIL";
}
function setRtc(iso) {
console.log("setRtc:" + iso);
// const iso = "1999-10-03 19:50:00";
// 一次性解析
const [datePart, timePart] = iso.split(' ');
const [year, month, day] = datePart.split('-').map(Number);
const [hour, minute, sec] = timePart.split(':').map(Number);
console.log("!!-----" + year +"," +month +","+ day +","+ hour +","+ minute +","+ sec);
// 写入 RTC
var librtc = require("rtc.js");
librtc.ctrl("set", {
year: year,
month: month,
day: day,
hour: hour,
minute: minute,
second: sec // 这里用解析出来的秒(示例 00)
});
}
function system(cmd) {
systemCtrl.executeSystemCommand(cmd)
}
......@@ -629,5 +649,6 @@ module.exports = {
initautoFactorySetting: initautoFactorySetting,
getWifiInfo: getWifiInfo,
gotoWriteLic: gotoWriteLic,
getMacAddressFromLicenseFile: getMacAddressFromLicenseFile
getMacAddressFromLicenseFile: getMacAddressFromLicenseFile,
setRtc: setRtc
}
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