@@ -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();