From 17f1ec6d8ce888ae8975f212a5a26579b87f2b7f Mon Sep 17 00:00:00 2001 From: byun Date: Sat, 11 Oct 2025 00:27:40 +0000 Subject: [PATCH] =?UTF-8?q?=EC=A0=84=EC=86=A1=20=EC=9B=A8=EC=9D=B4?= =?UTF-8?q?=ED=8C=85=20=ED=83=80=EC=9E=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- transmit.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/transmit.h b/transmit.h index d765020..72c88b5 100644 --- a/transmit.h +++ b/transmit.h @@ -123,6 +123,10 @@ const char transmit_html[] PROGMEM = R"rawliteral( background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%); color: white; } + .btn-info { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; + } .btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); } .message-list { @@ -357,6 +361,15 @@ const char transmit_html[] PROGMEM = R"rawliteral( +
+ + + + Delay between messages when using "Send All Once" button + +
+
@@ -381,6 +394,7 @@ const char transmit_html[] PROGMEM = R"rawliteral(
+
@@ -587,6 +601,11 @@ const char transmit_html[] PROGMEM = R"rawliteral( } function sendCanMessage(id, type, dlc, data) { + if (!ws || ws.readyState !== WebSocket.OPEN) { + alert('WebSocket not connected!'); + return; + } + const cmd = { cmd: 'sendCan', id: id, @@ -594,7 +613,9 @@ const char transmit_html[] PROGMEM = R"rawliteral( dlc: dlc, data: data.join('') }; + ws.send(JSON.stringify(cmd)); + console.log('Sent CAN message: ID=' + id + ', DLC=' + dlc + ', Data=' + data.join('')); } function updateMessageList() { @@ -664,6 +685,61 @@ const char transmit_html[] PROGMEM = R"rawliteral( updateMessageList(); } + function sendAllOnce() { + if (messages.length === 0) { + alert('No messages in the list!'); + return; + } + + if (!ws || ws.readyState !== WebSocket.OPEN) { + alert('WebSocket not connected!'); + return; + } + + const delayMs = parseInt(document.getElementById('send-all-delay').value) || 10; + + // λ²„νŠΌ λΉ„ν™œμ„±ν™” 및 μ‹œκ°μ  ν”Όλ“œλ°± + const btn = event.target; + const originalText = btn.innerHTML; + btn.disabled = true; + btn.innerHTML = '⏳ Sending...'; + + let sentCount = 0; + + // 순차적으둜 λ©”μ‹œμ§€ 전솑 (λ”œλ ˆμ΄ 포함) + function sendNext(index) { + if (index >= messages.length) { + // λͺ¨λ“  λ©”μ‹œμ§€ 전솑 μ™„λ£Œ + console.log('Sent all messages once: ' + sentCount + ' messages'); + + btn.innerHTML = 'βœ“ Sent ' + sentCount + ' msgs'; + btn.style.background = 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)'; + + setTimeout(() => { + btn.innerHTML = originalText; + btn.style.background = ''; + btn.disabled = false; + }, 2000); + return; + } + + const msg = messages[index]; + sendCanMessage(msg.id, msg.type, msg.dlc, msg.data); + sentCount++; + + // μ§„ν–‰ 상황 ν‘œμ‹œ + btn.innerHTML = '⏳ Sending ' + (index + 1) + '/' + messages.length; + + // λ‹€μŒ λ©”μ‹œμ§€ 전솑 (λ”œλ ˆμ΄ ν›„) + setTimeout(() => { + sendNext(index + 1); + }, delayMs); + } + + // 첫 번째 λ©”μ‹œμ§€λΆ€ν„° μ‹œμž‘ + sendNext(0); + } + function clearAll() { if (confirm('Clear all messages?')) { stopAll();