Commit 25754d9e authored by lyong's avatar lyong

feat:增加自动化RTC写入

parent c6c06710
...@@ -29,6 +29,7 @@ const cmdTable = [ ...@@ -29,6 +29,7 @@ const cmdTable = [
{ kw: 'GET_CRC', fn: doGetCrc }, { kw: 'GET_CRC', fn: doGetCrc },
{ kw: 'TEST_END', fn: doEnd }, { kw: 'TEST_END', fn: doEnd },
{ kw: 'RTC', fn: doGetRtc }, { kw: 'RTC', fn: doGetRtc },
{ kw: 'WRITE_RTC', fn: doSetRtc },
]; ];
const cmdTableHex = [ const cmdTableHex = [
{ kw: '57524954455F4C4943', fn: doWriteLic }, //WRITE_LIC { kw: '57524954455F4C4943', fn: doWriteLic }, //WRITE_LIC
...@@ -62,6 +63,23 @@ function doGetRtc(fd) { ...@@ -62,6 +63,23 @@ function doGetRtc(fd) {
console.log('RTC:' + time); console.log('RTC:' + time);
send(fd, 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) { function doVersion(fd) {
var version = "+" + userData.softwareVersion var version = "+" + userData.softwareVersion
...@@ -165,7 +183,7 @@ function doEnd(fd) { ...@@ -165,7 +183,7 @@ function doEnd(fd) {
function doWriteMac(fd, recvBuf) { function doWriteMac(fd, recvBuf) {
// const mac = recvBuf.split('=')[1].trim(); // const mac = recvBuf.split('=')[1].trim();
console.log('write mac:' + mac); console.log('write mac:' + mac);
send(fd, '+OK'); send(fd, '+FAIL');
} }
function doWriteSn(fd, recvBuf) { function doWriteSn(fd, recvBuf) {
const sn = recvBuf.split('=')[1].trim(); const sn = recvBuf.split('=')[1].trim();
......
...@@ -233,8 +233,8 @@ function getTempHum() { ...@@ -233,8 +233,8 @@ function getTempHum() {
function writeLic(hexStr) { function writeLic(hexStr) {
var filePath1 = "/tmp/operation_license"; var filePath1 = "/tmp/operation_license";
// var filePath2 = "/tmp/sn_data.bin"; // var filePath2 = "/tmp/sn_data.bin";
const SECURE_APP_PATH = "/mnt/app/eOpteeCtrl" // const SECURE_APP_PATH = "/mnt/app/eOpteeCtrl"
console.log('Full license written:' + hexStr); console.log('Full license written:' + hexStr);
...@@ -247,7 +247,7 @@ function writeLic(hexStr) { ...@@ -247,7 +247,7 @@ function writeLic(hexStr) {
} }
system("sync"); system("sync");
system(SECURE_APP_PATH + " -b " + filePath1); system(SECURE_APP_PATH + " -b " + filePath1);
// handleSNDataBinFile.writeInnerSNDataToBinFile(lic) // handleSNDataBinFile.writeInnerSNDataToBinFile(lic)
system("cp /tmp/operation_license /mnt/userdataA/files/"); system("cp /tmp/operation_license /mnt/userdataA/files/");
system("/mnt/app/eMideaSetMac"); system("/mnt/app/eMideaSetMac");
...@@ -594,6 +594,26 @@ function getMacAddressFromLicenseFile() { ...@@ -594,6 +594,26 @@ function getMacAddressFromLicenseFile() {
return "FAIL"; 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) { function system(cmd) {
systemCtrl.executeSystemCommand(cmd) systemCtrl.executeSystemCommand(cmd)
} }
...@@ -629,5 +649,6 @@ module.exports = { ...@@ -629,5 +649,6 @@ module.exports = {
initautoFactorySetting: initautoFactorySetting, initautoFactorySetting: initautoFactorySetting,
getWifiInfo: getWifiInfo, getWifiInfo: getWifiInfo,
gotoWriteLic: gotoWriteLic, 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