I am implementing a paho mqtt client. Here is my code:
import paho.mqtt.client as mqtt
def mess(client, userdata, message):
print("{'" + str(message.payload) + "', " + str(message.topic) + "}")
def subscribe(c_id, topic, server, port):
cl = mqtt.Client(c_id)
cl.connect(server, port)
cl.subscribe(topic)
cl.on_message = mess
cl.loop_forever()
this works fine, but I don't want to print the data in 'mess'. I need to return the string inside print()
to the calling function.
I am calling subscribe()
from another program.
Any help, direct or recommended reading would be appreciated.