From d966d76d592ea7ab4b32affe4c203f9e29bebafc Mon Sep 17 00:00:00 2001 From: Mr Keuz Date: Fri, 29 Oct 2021 17:16:24 +0300 Subject: [PATCH] umqtt.simple: Add example for mqtt tls. Signed-off-by: Damien George --- micropython/umqtt.simple/example_pub_tls.py | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 micropython/umqtt.simple/example_pub_tls.py diff --git a/micropython/umqtt.simple/example_pub_tls.py b/micropython/umqtt.simple/example_pub_tls.py new file mode 100644 index 000000000..ad353225f --- /dev/null +++ b/micropython/umqtt.simple/example_pub_tls.py @@ -0,0 +1,26 @@ +from umqtt.simple import MQTTClient + +# Test reception e.g. with: +# mosquitto_sub -t foo_topic + + +def main(server="localhost"): + # NOTE: Checking server certificate is DISABLE + ssl_params = {"server_hostname": server} + c = MQTTClient( + "umqtt_client", + server=server, + port=8883, + user="", + password="", + keepalive=60, + ssl=True, + ssl_params=ssl_params, + ) + c.connect() + c.publish(b"foo_topic", b"hello") + c.disconnect() + + +if __name__ == "__main__": + main()