Skip to content

Commit 4dc1f1c

Browse files
author
Paul Sokolovsky
committed
umqtt.simple: Add pubsub example.
1 parent cfa1b9c commit 4dc1f1c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

umqtt.simple/example_pubsub.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
from umqtt.simple import MQTTClient
3+
4+
def sub_cb(topic, msg):
5+
print((topic, msg))
6+
7+
c = MQTTClient("uqmtt_client", "localhost")
8+
c.connect()
9+
c.subscribe(b"foo_topic")
10+
c.publish(b"foo_topic", b"hello")
11+
while 1:
12+
c.wait_msg()
13+
c.disconnect()

0 commit comments

Comments
 (0)