kopia lustrzana https://github.com/micropython/micropython-lib
umqtt.simple: Add pubsub example.
rodzic
cfa1b9cce0
commit
4dc1f1c264
|
@ -0,0 +1,13 @@
|
||||||
|
import time
|
||||||
|
from umqtt.simple import MQTTClient
|
||||||
|
|
||||||
|
def sub_cb(topic, msg):
|
||||||
|
print((topic, msg))
|
||||||
|
|
||||||
|
c = MQTTClient("uqmtt_client", "localhost")
|
||||||
|
c.connect()
|
||||||
|
c.subscribe(b"foo_topic")
|
||||||
|
c.publish(b"foo_topic", b"hello")
|
||||||
|
while 1:
|
||||||
|
c.wait_msg()
|
||||||
|
c.disconnect()
|
Ładowanie…
Reference in New Issue