Skip to content

Latest commit

 

History

History
98 lines (79 loc) · 6.22 KB

README.md

File metadata and controls

98 lines (79 loc) · 6.22 KB

TinyMqtt

Release AUnit Tests Issues Esp8266 Esp32 Gpl 3.0 Mqtt 3.1.1

TinyMqtt is a small, fast and capable Mqtt Broker and Client for Esp8266 / Esp32 / Esp WROOM

Statuses of all unit tests of TinyMqtt and its dependencies

Project Unit tests result
TinyMqtt
Dependencies
TinyConsole
EpoxyDuino AUnit Tests
EspMock AUnit Tests
AUnit AUnit Tests
AceRoutine AUnit Tests

Features

  • Supports retained messages (not activated by default)
  • Async Wifi compatible (me-no-dev/ESPAsyncTCP@^1.2.2)
  • Very fast broker I saw it re-sent 1000 topics per second for two clients that had subscribed (payload ~15 bytes ESP8266). No topic lost. The max I've seen was 2k msg/s (1 client 1 subscription)
  • Act as as a mqtt broker and/or a mqtt client
  • Mqtt 3.1.1 / Qos 0 supported
  • Wildcards supported (+ # $ and * (even if not part of the spec...))
  • Standalone (can work without WiFi) (degraded/local mode)
  • Brokers can connect to another broker and becomes then a proxy for clients that are connected to it.
  • zeroconf, this is a strange but very powerful mode where all brokers tries to connect together on the same local network.
  • small memory footprint (very efficient topic storage)
  • long messages are supported (>127 bytes)
  • TinyMQTT is largely unit tested, so once a bug is fixed, it is fixed forever

Limitations

  • Max of 255 different topics can be stored (change index_t type to allow more)
  • No Qos because messages are not queued but immediately sent to clients

Quickstart

  • install TinyMqtt library (you can use the Arduino library manager and search for TinyMqtt)
  • modify <libraries/TinyMqtt/src/my_credentials.h> (wifi setup)

Examples

Example Description
client-with-wifi standalone example
client-without-wifi standalone example
simple-client Connect the ESP to an external Mqtt broker
simple-broker Simple Mqtt broker with your ESP
tinymqtt-test Complex console example
  • tinymqtt-test : This is a complex sketch with a terminal console that allows to add clients publish, connect etc with interpreted commands.

Retained messages

Qos 1 is not supported, but retained messages are. So a new subscription is able to send old messages. This feature is disabled by default. The default retain parameter of MqttBroker::MqttBroker takes an optional (0 by default) number of retained messages. MqttBroker::retain(n) will also make the broker store n messages at max.

Standalone mode (zeroconf)

-> The zeroconf mode is not yet implemented zeroconf clients to connect to broker on local network.

In Zeroconf mode, each ESP is a a broker and scans the local network. After a while one ESP naturally becomes a 'master' and all ESP are connected together. No problem if the master dies, a new master will be choosen soon.

TODO List

  • Use Async library
  • Implement zeroconf mode (needs async)
  • Add a max_clients in MqttBroker. Used with zeroconf, there will be no need for having tons of clients (also RAM is the problem with many clients)
  • Why not a 'global' TinyMqtt::loop() instead of having to call loop for all broker/clients instances
  • Test what is the real max number of clients for broker. As far as I saw, 1k is needed per client which would make more than 30 clients critical.
  • MqttClient auto re-subscribe (::resubscribe works bad on broker.emqx.io)
  • MqttClient auto reconnection
  • MqttClient user/password
  • Wildcards (I may implement only # as I'm not interrested by a clever and cpu consuming matching)
  • I suspect that MqttClient::parent could be removed and replaced with a simple boolean (this'll need to rewrite a few functions)

License

Gnu GPL 3.0, see LICENSE.