Maj des services annexes

This commit is contained in:
Jérémy CHOMAZ 2024-12-23 22:02:57 +01:00
parent 723b6ce9f5
commit deb8843f42
2 changed files with 10 additions and 1 deletions

View File

@ -3,7 +3,7 @@ const mqtt = require('mqtt');
const fs = require('fs'); const fs = require('fs');
// Lecture du fichier de configuration // Lecture du fichier de configuration
const config = JSON.parse(fs.readFileSync('\services\\config\\config.json', 'utf8')); const config = JSON.parse(fs.readFileSync('\services\\config\\config_network.json', 'utf8'));
// Extraction des informations de config // Extraction des informations de config
const { hosts: { buzzers: { IP: buzzerIPs, MQTTconfig: { mqttHost, mqttTopic } } } } = config; const { hosts: { buzzers: { IP: buzzerIPs, MQTTconfig: { mqttHost, mqttTopic } } } } = config;

View File

@ -217,6 +217,15 @@ client.on('message', (topic, message) => {
}); });
(async () => {
while (true) {
console.log("Boucle en arrière-plan");
await new Promise((resolve) => setTimeout(resolve, 2000)); // Pause de 2 secondes
client.publish(mqttScoreTopic, JSON.stringify(global.jsonData));
}
})();
client.on('error', (error) => { client.on('error', (error) => {
console.error('Erreur de connexion au broker MQTT:', error.message); console.error('Erreur de connexion au broker MQTT:', error.message);
}); });