자동로깅 추가, usb port추가
This commit is contained in:
88
web_html.h
88
web_html.h
@@ -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;">전원 OFF→ON 시 자동으로 로깅 시작. 현장 장기 설치용.</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=>{
|
||||
|
||||
Reference in New Issue
Block a user