Maj des services annexes
This commit is contained in:
parent
723b6ce9f5
commit
deb8843f42
@ -3,7 +3,7 @@ const mqtt = require('mqtt');
|
||||
const fs = require('fs');
|
||||
|
||||
// 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
|
||||
const { hosts: { buzzers: { IP: buzzerIPs, MQTTconfig: { mqttHost, mqttTopic } } } } = config;
|
||||
|
@ -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) => {
|
||||
console.error('Erreur de connexion au broker MQTT:', error.message);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user