From 0186a0a83e7da63ea45868dc9263ecb9fcd9e02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20CHOMAZ?= Date: Fri, 23 Jan 2026 18:40:23 +0100 Subject: [PATCH] Modification du buzzer-manager --- VNode/services/buzzer/buzzer-manager.js | 30 +++++++------------------ 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/VNode/services/buzzer/buzzer-manager.js b/VNode/services/buzzer/buzzer-manager.js index 92919af4..ce768ed4 100644 --- a/VNode/services/buzzer/buzzer-manager.js +++ b/VNode/services/buzzer/buzzer-manager.js @@ -2,7 +2,7 @@ const mqtt = require('mqtt'); // MQTT broker configuration -const brokerUrl = 'mqtt://localhost'; // Broker URL (change if needed) +const brokerUrl = 'mqtt://192.168.1.178'; // Broker URL (change if needed) const clientId = 'buzzer_manager'; const options = { clientId, @@ -64,8 +64,7 @@ function sendTiltStatus(action, buzzerId) { client.publish('vulture/buzzer/status', JSON.stringify({ status: "tilt_update", tilt_buzzers: tiltList, - message: `Buzzer ID ${buzzerId} ${action} to tilt mode`, - timestamp: new Date().toISOString() + message: `Buzzer ID ${buzzerId} ${action} to tilt mode` })); console.log(`[INFO] Tilt status updated: ${tiltList.length} buzzers in tilt mode`); @@ -106,8 +105,7 @@ client.on('message', (topic, message) => { status: "received", action: status, buzzer_id: buzzer_id, - message: `Tilt command '${status}' received for buzzer ID ${buzzer_id}`, - timestamp: new Date().toISOString() + message: `Tilt command '${status}' received for buzzer ID ${buzzer_id}` })); // Send the updated tilt status to all components @@ -131,8 +129,7 @@ client.on('message', (topic, message) => { client.publish(`vulture/buzzer/confirmation/${buzzerId}`, JSON.stringify({ status: "received", buzzer_id: buzzerId, - message: `Buzzer ID ${buzzerId} received (Color: ${color})`, - timestamp: new Date().toISOString() + message: `Buzzer ID ${buzzerId} received (Color: ${color})` })); // Ignore if the buzzer is in tilt mode, but notify this event @@ -143,8 +140,7 @@ client.on('message', (topic, message) => { client.publish(`vulture/buzzer/tilt/ignored/${buzzerId}`, JSON.stringify({ status: "tilt_ignored", buzzer_id: buzzerId, - message: `Buzzer ID ${buzzerId} is in tilt mode and ignored.`, - timestamp: new Date().toISOString() + message: `Buzzer ID ${buzzerId} is in tilt` })); return; } @@ -154,8 +150,7 @@ client.on('message', (topic, message) => { buzzer_id: buzzerId, color: color, status: buzzerActive ? "blocked" : "free", - message: `Activity detected on buzzer ID ${buzzerId} (Color: ${color})`, - timestamp: new Date().toISOString() + message: `Activity detected on buzzer ID ${buzzerId} (Color: ${color})` })); if (!buzzerActive) { @@ -176,8 +171,7 @@ client.on('message', (topic, message) => { status: "blocked", buzzer_id: buzzerId, color: color, - message: `Buzzer activated by ID ${buzzerId} (Color: ${color})`, - timestamp: new Date().toISOString() + message: `Buzzer activated by ID ${buzzerId} (Color: ${color})` })); console.log(`[INFO] Buzzers blocked and notification sent`); @@ -188,19 +182,12 @@ client.on('message', (topic, message) => { if (topic === 'vulture/buzzer/unlock') { console.log('[INFO] Buzzer unlock requested'); - // Confirm receipt of unlock command - client.publish('vulture/buzzer/unlock/confirmation', JSON.stringify({ - status: "received", - message: "Buzzer unlock command received.", - timestamp: new Date().toISOString() - })); // Notify the light manager to change to the team's color client.publish('vulture/light/change', JSON.stringify({ color: "#FFFFFF", effect: 'rainbow' })); - // Reset buzzer manager state buzzerActive = false; buzzerThatPressed = null; @@ -208,8 +195,7 @@ client.on('message', (topic, message) => { // Notify all components of buzzer unlock client.publish('vulture/buzzer/status', JSON.stringify({ status: "unblocked", - message: "Buzzers unblocked and ready for activation.", - timestamp: new Date().toISOString() + message: "Buzzers unblocked and ready for activation." })); console.log('[INFO] Buzzers unblocked and notification sent');