# ajouter la lib paho : pip install paho# python2.7importpaho.mqtt.clientasmqttimportjsonimportbase64importlogging# configmqttServer="loraserver.tetaneutral.net"appID="5"deviceID="010203040506070b"# du log pour debuglogging.basicConfig(level=logging.DEBUG)# callback appele lors de la reception d un messagedefon_message(mqttc,obj,msg):jsonMsg=json.loads(msg.payload)device=jsonMsg["devEUI"]gw=jsonMsg["rxInfo"][0]["gatewayID"]rssi=jsonMsg["rxInfo"][0]["rssi"]data=base64.b64decode(jsonMsg["data"])print("dev id : "+device+", gw id : "+gw+", data : "+data+", rssi : "+str(rssi))# creation du clientmqttc=mqtt.Client()mqttc.on_message=on_messagelogger=logging.getLogger(__name__)mqttc.enable_logger(logger)mqttc.connect(mqttServer,1883,60)# soucription au devicemqttc.subscribe("application/"+appID+"/device/"+deviceID+"/rx",0)mqttc.loop_forever()