시간 동기화
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
#ifndef SERIAL2_TERMINAL_H
|
#ifndef SERIAL2_TERMINAL_H
|
||||||
#define SERIAL2_TERMINAL_H
|
#define SERIAL2_TERMINAL_H
|
||||||
|
|
||||||
const char serial2_terminal_html[] PROGMEM = R"rawliteral(
|
const char serial2_terminal_html[] PROGMEM = R"rawliteral(
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -686,12 +685,35 @@ const char serial2_terminal_html[] PROGMEM = R"rawliteral(
|
|||||||
0x2B: 'Read Device Identification'
|
0x2B: 'Read Device Identification'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function syncTimeFromPhone() {
|
||||||
|
const now = new Date();
|
||||||
|
const timeData = {
|
||||||
|
cmd: 'syncTimeFromPhone',
|
||||||
|
year: now.getFullYear(),
|
||||||
|
month: now.getMonth() + 1,
|
||||||
|
day: now.getDate(),
|
||||||
|
hour: now.getHours(),
|
||||||
|
minute: now.getMinutes(),
|
||||||
|
second: now.getSeconds()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
|
ws.send(JSON.stringify(timeData));
|
||||||
|
console.log('Time sync command sent:', timeData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initWebSocket() {
|
function initWebSocket() {
|
||||||
ws = new WebSocket('ws://' + window.location.hostname + ':81/');
|
ws = new WebSocket('ws://' + window.location.hostname + ':81/');
|
||||||
|
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
console.log('WebSocket Connected');
|
console.log('WebSocket Connected');
|
||||||
addToTerminal('System', '🟢 Connected to Serial2 Terminal');
|
addToTerminal('System', '🟢 Connected to Serial2 Terminal');
|
||||||
|
|
||||||
|
// 시간 동기화
|
||||||
|
setTimeout(function() {
|
||||||
|
syncTimeFromPhone();
|
||||||
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
|
|||||||
@@ -685,12 +685,35 @@ const char serial_terminal_html[] PROGMEM = R"rawliteral(
|
|||||||
0x2B: 'Read Device Identification'
|
0x2B: 'Read Device Identification'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function syncTimeFromPhone() {
|
||||||
|
const now = new Date();
|
||||||
|
const timeData = {
|
||||||
|
cmd: 'syncTimeFromPhone',
|
||||||
|
year: now.getFullYear(),
|
||||||
|
month: now.getMonth() + 1,
|
||||||
|
day: now.getDate(),
|
||||||
|
hour: now.getHours(),
|
||||||
|
minute: now.getMinutes(),
|
||||||
|
second: now.getSeconds()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
|
ws.send(JSON.stringify(timeData));
|
||||||
|
console.log('Time sync command sent:', timeData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initWebSocket() {
|
function initWebSocket() {
|
||||||
ws = new WebSocket('ws://' + window.location.hostname + ':81/');
|
ws = new WebSocket('ws://' + window.location.hostname + ':81/');
|
||||||
|
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
console.log('WebSocket Connected');
|
console.log('WebSocket Connected');
|
||||||
addToTerminal('System', '🟢 Connected to Serial1 Terminal');
|
addToTerminal('System', '🟢 Connected to Serial1 Terminal');
|
||||||
|
|
||||||
|
// 시간 동기화
|
||||||
|
setTimeout(function() {
|
||||||
|
syncTimeFromPhone();
|
||||||
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
@@ -1213,6 +1236,4 @@ const char serial_terminal_html[] PROGMEM = R"rawliteral(
|
|||||||
</html>
|
</html>
|
||||||
)rawliteral";
|
)rawliteral";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user