자동로깅 추가, usb port추가

This commit is contained in:
2026-02-27 08:54:14 +00:00
parent 7e0e65297b
commit 961680e5ec
7 changed files with 291 additions and 21 deletions

View File

@@ -186,6 +186,15 @@ tr:active{background:rgba(233,69,96,0.1);}
<div class="spage">
<div class="sgrp">
<h3>Serial Port</h3>
<div class="fr"><label>Monitor Port</label>
<select id="sPort" onchange="switchPort()">
<option value="0" selected>UART2 (GPIO16/17) - </option>
<option value="1">UART0 (USB) - </option>
</select>
</div>
<div id="portInfo" style="font-size:10px;color:#888;margin:-4px 0 4px 0;">
UART2: TX=GPIO17, RX=GPIO16 ( )
</div>
<div class="fr"><label>Baud Rate</label>
<select id="baud"><option value="1200">1200</option><option value="2400">2400</option><option value="4800">4800</option><option value="9600">9600</option><option value="19200">19200</option><option value="38400">38400</option><option value="57600">57600</option><option value="115200" selected>115200</option><option value="230400">230400</option><option value="460800">460800</option><option value="921600">921600</option><option value="1000000">1M</option><option value="2000000">2M</option></select>
</div>
@@ -240,6 +249,20 @@ tr:active{background:rgba(233,69,96,0.1);}
<button class="abtn" onclick="sendC('new_log')" style="background:var(--warn);color:#000;">New File</button>
</div>
</div>
<div class="sgrp" id="autoGrp" style="border:1px solid var(--border);">
<h3> (Auto-Start)</h3>
<p style="font-size:11px;color:#999;margin:0 0 8px 0;"> OFFON . .</p>
<div class="fr" style="flex-direction:row;align-items:center;gap:10px;">
<label></label>
<span id="autoSt" style="font-size:13px;color:#888;">OFF</span>
</div>
<button class="abtn" id="autoBtn" onclick="toggleAutoStart()" style="margin-top:8px;background:var(--border);color:var(--text);width:100%;">
</button>
<p id="autoDesc" style="font-size:10px;color:#666;margin:6px 0 0 0;display:none;">
: RTC
</p>
</div>
</div>
</div>
@@ -266,7 +289,7 @@ tr:active{background:rgba(233,69,96,0.1);}
<div class="sbar">
<span class="ld" id="lDot"></span>
<span id="lInfo">Log OFF</span>
<span id="serInfo">115200 8N1</span>
<span id="serInfo">UART2 115200 8N1</span>
<span id="rxC">RX:0</span>
<span id="txC">TX:0</span>
<span style="margin-left:auto;" id="tInfo">--</span>
@@ -304,6 +327,7 @@ function wsConn(){
sendC('sysinfo');
sendC('get_serial_config');
sendC('get_wifi');
sendC('get_autostart');
};
ws.onmessage=function(e){
try{
@@ -313,6 +337,7 @@ function wsConn(){
else if(m.type==='serial_config') updSer(m);
else if(m.type==='log_status') updLog(m);
else if(m.type==='wifi_status') updWifi(m);
else if(m.type==='autostart_status') updAuto(m);
}catch(x){}
};
ws.onclose=function(){
@@ -432,7 +457,37 @@ function updSer(m){
if(m.dataBits) document.getElementById('dBits').value=m.dataBits;
if(m.parity) document.getElementById('par').value=m.parity;
if(m.stopBits) document.getElementById('sBits').value=m.stopBits;
document.getElementById('serInfo').textContent=m.baud+' '+m.dataBits+m.parity+m.stopBits;
// Port selector
if(m.port!==undefined){
document.getElementById('sPort').value=m.port;
updPortInfo(m.port);
}
// Status bar: show port + config
let portLabel=((m.port||0)==1)?'USB':'UART2';
document.getElementById('serInfo').textContent=portLabel+' '+m.baud+' '+m.dataBits+m.parity+m.stopBits;
}
function updPortInfo(p){
let info=document.getElementById('portInfo');
if(p==1){
info.textContent='USB: PC ';
info.style.color='var(--ok)';
}else{
info.textContent='UART2: TX=GPIO17, RX=GPIO16 ( )';
info.style.color='#888';
}
}
function switchPort(){
let port=parseInt(document.getElementById('sPort').value);
if(port===1){
if(!confirm('USB ?\n\nPC의 (PuTTY )\nESP32 COM \n웹 .')) {
document.getElementById('sPort').value='0';
return;
}
}
updPortInfo(port);
if(ws&&ws.readyState===1) ws.send(JSON.stringify({cmd:'switch_port',port:port}));
}
// ===== System Info =====
@@ -533,6 +588,35 @@ function updLog(m){
document.getElementById('logFile').value=m.file||'';
}
// ===== Autostart (Persistent Logging) =====
function updAuto(m){
let st=document.getElementById('autoSt');
let btn=document.getElementById('autoBtn');
let grp=document.getElementById('autoGrp');
let desc=document.getElementById('autoDesc');
if(m.enabled){
st.textContent='ON';st.style.color='var(--ok)';
btn.textContent=' ';
btn.style.background='var(--btn)';btn.style.color='#fff';
grp.style.borderColor='var(--ok)';
desc.style.display='block';
}else{
st.textContent='OFF';st.style.color='#888';
btn.textContent=' ';
btn.style.background='var(--border)';btn.style.color='var(--text)';
grp.style.borderColor='var(--border)';
desc.style.display='none';
}
}
function toggleAutoStart(){
let cur=document.getElementById('autoSt').textContent==='ON';
if(!cur){
if(!confirm(' ?\n\n전원이 .\n( )')) return;
}
sendC('toggle_autostart');
}
// ===== File Manager =====
function loadFiles(){
fetch('/api/files').then(r=>r.json()).then(d=>{