Raspberry Pi - MQTT for IoT
What will the following code print when a message is received on topic 'test/topic'?
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
print(f"Received '{msg.payload.decode()}' on topic '{msg.topic}'")
client = mqtt.Client()
client.on_message = on_message
client.connect('broker.hivemq.com', 1883)
client.subscribe('test/topic')
client.loop_start()
# Assume a message with payload 'Hello' is published to 'test/topic'