My code minus networking stuff:
Code: Select all
with open("key", "r") as f:
key = f.read()
print("Got Key")
with open("cert", "r") as f:
cert = f.read()
print("Got Cert")
client = MQTTClient(client_id="e1474d", server="fastanddirty-mqtt.com", port=8883,
user="MyTCPusername", password="MyTCPpassword",
keepalive=5000, ssl=True,
ssl_params={"cert":cert, "key":key, "server_side":False})
client.set_callback(sub_cb)
client.connect()
client.subscribe(topic="e1474d/temp/sub")
while True:
print("Sending ON")
client.publish(topic="e1474d/temp", msg="high")
time.sleep(1)
print("Sending OFF")
client.publish(topic="e1474d/temp", msg="low")
for i in range(14):
print("waiting for new message")
#only client.wait_msg works with full tls - some problem at line 203 of umqtt library
client.check_msg() # two functions exist: client.wait_msg() or client.check_msg()
print("received new message")
time.sleep(1)
Code: Select all
Traceback (most recent call last):
File "main.py", line 80, in <module>
File "umqtt/simple.py", line 203, in check_msg
NotImplementedError:
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.