refacto: reorganize folder tree to split lora gateway stack from app
Those stack won't necessarily be on the same host, so they need to be split
This commit is contained in:
parent
31a1c14831
commit
851e8947bc
11 changed files with 9 additions and 11 deletions
30
app/consumer/main.py
Normal file
30
app/consumer/main.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
import logging
|
||||
import sys
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(levelname)s] %(message)s",
|
||||
datefmt="%Y-%m-%dT%H:%M:%S",
|
||||
stream=sys.stdout, # Docker lit stdout par défaut
|
||||
force=True
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def on_connect(client, userdata, flags, reason_code, properties):
|
||||
log.info(f"Connected with result code {reason_code}")
|
||||
client.subscribe("application/+/device/+/event/up")
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
log.info(msg.topic+" "+str(msg.payload))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
|
||||
mqttc.on_connect = on_connect
|
||||
mqttc.on_message = on_message
|
||||
|
||||
mqttc.connect("mosquitto", 1883, 60)
|
||||
mqttc.loop_forever()
|
||||
Loading…
Add table
Add a link
Reference in a new issue