Hi,
I’m trying to read the uplink message from mqtt broker, with python client script, when the gateway bridge publish, i can read the topic, but not payload.
My client.py :
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt #import the client1
import time
import json
import requests
import ssl
#------------------------------------------------------------------------------------------------
def on_log(client, userdata, level, buf) :
#print("log: "+buf)
k=0
#------------------------------------------------------------------------------------------------
def on_connect(client, userdata, flags, rc) :
if rc==0:
print("connected ok")
else:
print("not connected", rc)
#------------------------------------------------------------------------------------------------
def on_disconnect(client, userdata, flags, rc=0) :
print("disconnect result code "+str(rc))
#------------------------------------------------------------------------------------------------
def on_message(client,userdata,msg) :
global m_decode
topic=msg.topic
print("message received " ,msg.payload.decode("utf-8","ignore"))
#------------------------------------------------------------------------------------------------
broker_address="127.0.0.1:1883"
client = mqtt.Client("paclido") #create new instance
client.on_connect=on_connect
client.on_disconnect=on_disconnect
client.on_log=on_log
client.on_message=on_message
print ("cnct to broker", broker_address)
client.connect("127.0.0.1", 1883, 60)
client.subscribe([("gateway/#", 0), ("gateway/abcdef1010101010/up", 0)])
client.loop_forever()
Log of script :
the message from the log of gateway bridge :
Can you help guys ? Thanks