add: autorun
This commit is contained in:
parent
c474aff5eb
commit
769d801687
2 changed files with 8 additions and 5 deletions
1
autorun.lua
Normal file
1
autorun.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dofile('client.lua')
|
|
@ -1,5 +1,6 @@
|
||||||
-- Description: Client MQTT pour jouer une mélodie sur un ESP8266
|
-- Description: Client MQTT pour jouer une mélodie sur un ESP8266
|
||||||
client = mqtt.client("AlarmeStarWars","localhost",1883,false)
|
client = mqtt.client("AlarmeStarWars","localhost",1883,false)
|
||||||
|
|
||||||
client:connect("student","ensibs")
|
client:connect("student","ensibs")
|
||||||
|
|
||||||
-- Initialiser la broche GPIO2 pour la sortie
|
-- Initialiser la broche GPIO2 pour la sortie
|
||||||
|
@ -70,10 +71,11 @@ function recp(mess)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Boucle principale pour maintenir le script actif
|
-- Connexion au broker MQTT et abonnement au canal
|
||||||
while true do
|
|
||||||
tmr.delay(1000) -- Attendre 1 seconde entre les itérations
|
|
||||||
end
|
|
||||||
|
|
||||||
client:subscribe("NOM_CHANNEL", mqtt.QOS0, recp)
|
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
|
Loading…
Add table
Add a link
Reference in a new issue