add: autorun

This commit is contained in:
Jérémy 2025-04-26 15:28:48 +02:00
parent c474aff5eb
commit 769d801687
2 changed files with 8 additions and 5 deletions

1
autorun.lua Normal file
View file

@ -0,0 +1 @@
dofile('client.lua')

View file

@ -1,5 +1,6 @@
-- Description: Client MQTT pour jouer une mélodie sur un ESP8266
client = mqtt.client("AlarmeStarWars","localhost",1883,false)
client:connect("student","ensibs")
-- Initialiser la broche GPIO2 pour la sortie
@ -70,10 +71,11 @@ function recp(mess)
end
end
-- Boucle principale pour maintenir le script actif
while true do
tmr.delay(1000) -- Attendre 1 seconde entre les itérations
end
-- Connexion au broker MQTT et abonnement au canal
client:subscribe("NOM_CHANNEL", mqtt.QOS0, recp)
-- Boucle principale pour maintenir le script actif
while true do
client:loop() -- Boucle pour traiter les messages MQTT
tmr.delay(1000) -- Attendre 1 seconde entre les itérations
end