Can't Decode Uplink Message from MQTT client

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

Hi,
Quick tip without deeper study - check your marshaller setting in gwbridge toml, it defaults to protobuf, but I guess you would like to use json format:

[integration]
marshaler="json"

https://www.chirpstack.io/gateway-bridge/install/config/

1 Like

hey
i think martin is right, i copied your script and it works fine on my side.
if the integration is changed to json it should work.

i can recommed you also to have a look on the mqtt-data-logger link. is a usefull and more powerfull tool for the same as you do in your script.

regards, sil

right Son ! thanks !