Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

mqttsn

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqttsn

Python client based on Eclipse RSMB client for MQTT-SN brokers

pipPyPI
Version
0.0.3
Maintainers
1

Python Client for MQTT-SN brokers

Usage examples

from mqttsn.client import Client, Callback

import sys


class MyCallback(Callback):
    def message_arrived(self, topic_name, payload, qos, retained, msgid):
        print(f'{self} | topic_name: {topic_name} | payload: {payload} | '
              f'qos {qos} | retained {retained} | msgid {msgid}',
              file=sys.stderr)

        return True


if __name__ == '__main__':
    aclient = Client("linh", port=1883)
    aclient.register_callback(MyCallback())
    aclient.connect()

    rc, topic1 = aclient.subscribe("topic1")
    print("topic id for topic1 is", topic1)

    rc, topic2 = aclient.subscribe("topic2")
    print("topic id for topic2 is", topic2)

    aclient.publish(topic1, "aaaa", qos=0)
    aclient.publish(topic2, "bbbb", qos=0)

    aclient.unsubscribe("topic1")

    aclient.publish(topic2, "cccc", qos=0)
    aclient.publish(topic1, "dddd", qos=0)

    aclient.disconnect()

Keywords

iot

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts