All Projects → iwanbk → Nyamuk

iwanbk / Nyamuk

Licence: bsd-2-clause
Python MQTT Client Library Based on libmosquitto

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Nyamuk

Tdm
GUI application to discover and monitor devices flashed with https://github.com/arendst/Sonoff-Tasmota
Stars: ✭ 385 (+434.72%)
Mutual labels:  mqtt, mqtt-client
Mosquitto Php
A wrapper for the Eclipse Mosquitto™ MQTT client library for PHP.
Stars: ✭ 448 (+522.22%)
Mutual labels:  mqtt, mqtt-client
Hivemq Mqtt Client
HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
Stars: ✭ 402 (+458.33%)
Mutual labels:  mqtt, mqtt-client
Mqtt Panel
A web interface for MQTT
Stars: ✭ 315 (+337.5%)
Mutual labels:  mqtt, mqtt-client
Phpmqttclient
a mqtt client library for php
Stars: ✭ 33 (-54.17%)
Mutual labels:  mqtt, mqtt-client
Wolfmqtt
wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
Stars: ✭ 316 (+338.89%)
Mutual labels:  mqtt, mqtt-client
Adafruit mqtt library
Arduino library for MQTT support
Stars: ✭ 441 (+512.5%)
Mutual labels:  mqtt, mqtt-client
ESPecial
ESP32 automation with web interface and telegram bot
Stars: ✭ 77 (+6.94%)
Mutual labels:  mqtt, mqtt-client
Paho.mqttdotnet
A .Net wrapper for eclipse/paho.mqtt.c
Stars: ✭ 33 (-54.17%)
Mutual labels:  mqtt, mqtt-client
Mqttx
MQTT X - Elegant MQTT 5.0 Client Tool of Cross-platform
Stars: ✭ 892 (+1138.89%)
Mutual labels:  mqtt, mqtt-client
Kmansonoff
Firmware for ESP8266 based itead Sonoff switches for use with HomeAssistant / mqtt
Stars: ✭ 282 (+291.67%)
Mutual labels:  mqtt, mqtt-client
Luamqtt
luamqtt - Pure-lua MQTT v3.1.1 and v5.0 client
Stars: ✭ 58 (-19.44%)
Mutual labels:  mqtt, mqtt-client
node-deepstackai-trigger
Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
Stars: ✭ 154 (+113.89%)
Mutual labels:  mqtt, mqtt-client
Mqtt C
A portable MQTT C client for embedded systems and PCs alike.
Stars: ✭ 342 (+375%)
Mutual labels:  mqtt, mqtt-client
asyncio-mqtt
Idomatic asyncio wrapper around paho-mqtt
Stars: ✭ 137 (+90.28%)
Mutual labels:  mqtt, mqtt-client
Qmqtt
MQTT Client for Qt
Stars: ✭ 409 (+468.06%)
Mutual labels:  mqtt, mqtt-client
ArduinoMqtt
MQTT client for Arduino
Stars: ✭ 58 (-19.44%)
Mutual labels:  mqtt, mqtt-client
WeConnect-mqtt
MQTT Client that publishes data from Volkswagen WeConnect
Stars: ✭ 14 (-80.56%)
Mutual labels:  mqtt, mqtt-client
Hbmqtt
MQTT client/broker using Python asynchronous I/O
Stars: ✭ 667 (+826.39%)
Mutual labels:  mqtt, mqtt-client
Lua Mosquitto
Lua bindings to the libmosquitto MQTT client library.
Stars: ✭ 47 (-34.72%)
Mutual labels:  mqtt, mqtt-client

Nyamuk

Nyamuk is a python MQTT library, originally based on libmosquitto.
It implements both 3.1 and 3.1.1 versions of MQTT protocol.
Currently only supporting python 2.7

Features

  • [x] MQTT v3.1
  • [x] MQTT v3.1.1
  • [x] SSL
  • [x] Qos 0, 1 & 2 support
  • [ ] docstring & documentation
  • [ ] python3 support
  • [ ] advanced logging

Install

from sources:

$> python setup.py install

using pypi package:

$> pip install nyamuk

Example

Publishing a message with Qos 1 (with MQTT v3.1.1)

import sys
from nyamuk import *

def nloop(client):
    client.packet_write()     # flush write buffer (messages sent to MQTT server)
    client.loop()             # fill read buffer   (enqueue received messages)
    return client.pop_event() # return 1st received message (dequeued)

client = Nyamuk("test_nyamuk", server="test.mosquitto.org")
ret = client.connect(version=4)
ret = nloop(client) # ret should be EventConnack object
if not isinstance(ret, EventConnack) or ret.ret_code != 0:
    print 'connection failed'; sys.exit(1)

client.publish('foo/bar', 'this is a test', qos=1)
ret = nloop(client) # ret should be EventPuback

client.disconnect()

Subscribing a topic

import sys
from nyamuk import *

def nloop(client):
    client.packet_write()     # flush write buffer (messages sent to MQTT server)
    client.loop()             # fill read buffer   (enqueue received messages)
    return client.pop_event() # return 1st received message (dequeued)

client = Nyamuk("test_nyamuk", server="test.mosquitto.org")
ret = client.connect(version=4)
ret = nloop(client) # ret should be EventConnack object
if not isinstance(ret, EventConnack) or ret.ret_code != 0:
    print 'connection failed'; sys.exit(1)

client.subscribe('foo/bar', qos=1)
ret = nloop(client)
if not isinstance(ret, EventSuback):
    print 'SUBACK not received'; sys.exit(2)
print 'granted qos is', ret.granted_qos[0]

try:
    while True:
        evt = nloop(client)
        if isinstance(evt, EventPublish):
            print 'we received a message: {0} (topic= {1})'.format(evt.msg.payload, evt.msg.topic)
            
            # received message is either qos 0 or 1
            # in case of qos 1, we must send back PUBACK message with same packet-id
            if evt.msg.qos == 1:
                client.puback(evt.msg.mid)

except KeyboardInterrupt:
    pass

client.disconnect()

Authors

Original creator: Iwan B. Kusnanto
Current maintainer: Guillaume Bour

License

Nyamuk is distributed under BSD license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].