Skip to main content

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

Project description

## Python Client for MQTT-SN brokers

### Usage examples

```python
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()
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mqttsn, version 0.0.4
Filename, size & hash File type Python version Upload date
mqttsn-0.0.4-py3-none-any.whl (17.8 kB) View hashes Wheel py3
mqttsn-0.0.4.tar.gz (11.7 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page