TOP Contributors

  1. MIKROE (2657 codes)
  2. Alcides Ramos (354 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136892 times)
  2. FAT32 Library (70029 times)
  3. Network Ethernet Library (56003 times)
  4. USB Device Library (46308 times)
  5. Network WiFi Library (41934 times)
  6. FT800 Library (41222 times)
  7. GSM click (29019 times)
  8. PID Library (26434 times)
  9. mikroSDK (26401 times)
  10. microSD click (25386 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

MQTTClient

Rating:

0

Author: VCC

Last Updated: 2024-04-25

Package Version: 1.0.0.1

Category: Communication

Downloaded: 9 times

Not followed.

License: MIT license  

MQTT Client library.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "MQTTClient" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "MQTTClient" changes.

Do you want to report abuse regarding "MQTTClient".

  • Information
  • Comments (0)

Library Blog

Features:
- Written according to the specification of MQTT5 (from 2019).
- Supports multiple clients, i.e. connections to multiple brokers at the same time (requires more testing).
- Supports QoS0, QoS1 and QoS2.
- The UserProperty field (see spec), from all packet types, is enabled by a compiler directive, to save some space.
- Single event (for callback) of multiple error codes.
- Compiled and tested both for Desktop (FreePascal) and on MCU (PIC32).
- Because MQTT works with multiple pieces of data, of many sizes, the DynArrays library (which is a dependency) allows "rounded" allocation, which reduces memory fragmentation.
  Stability tests proved this feature to be a requirement, no matter how many fragments the memory manager supports.

What is not tested or implemented:
- The use of Topic Aliases.
- Responding with Disconnect to various error conditions (e.g. duplicated messsages).
- Responding with various error codes to server (e.g. "Protocol Error", "Payload format invalid", "QoS not supported", "Topic Alias invalid"  etc).
- Properly reacting to various server error messages, to free resources.
- Caching topic names for later correlation (e.g. between a subscription and a received message).
- Auth, other than plain username+password on connect.
- Retain.
- Will.
- Reconnecting.
- Clean/Reused sessions.
- The use of timeouts and expiration intervals (e.g. Message Expiry Interval).
- Compatibility with clients or servers of older protocol versions (e.g. v3.1.1).
- Handling DISCONNECT packet, which should automatically free some resources.
- Using SingleOutputBuffer. This is a feature, which automatically concatenates output packets into a single array of bytes.
- Using the library in a real life scenario, where the MCU stays connected for a long time.

Limitations:
- Havily use of inversion of control. That requires using additional FIFOs between MQTT library and Ethernet library.
  This may complicate user code, because of many required callbacks, where MQTT parameters are configured.
  Some of the internal library functions are exposed, so that users may replace existing logic with theirs, thus bypassing callbacks.
- Havily use of dynamic memory allocation.
- No safety mechanisms (so far) for dealing with too large packets. In case of OutOfMemory errors, the memory manager will have to be reset.
- Although clients can be created and destroyed dynamically, users have to make sure their instances are not in use while destroyed.
  The same limitation applies to all clients which have a greater index in the array which holds client instances, because they will be reindexed.
- The development priority has been to have a working library over an efficient one. Some areas require many optimizations.
- Very difficult to predict the required amount of memory for a given application. Because of this, only MCUs with more RAM are suitable.

Dependencies:
- DynArrays library (which depends on MemManager) for dynamic memory allocation.

Misc:
- The provided example uses "mikroMedia for PIC32MX7" board and logs MQTT activity through UART (with FT232R).
  Because of that, it requires "mikroMedia for PIC32MX7 shield".
- This example does not show how the MCU application works when it subscribes to a topic.
- No documentation available at this time.

 

ALSO FROM THIS AUTHOR

DynTFT Color Theme Generator

0

DynTFT Color Theme Generator is an editor for DynTFT color constants. It allows live preview of all supported DynTFT components under different color settings.

[Learn More]

Peak Programme Meter with LEDs

0

This is an example of a Peak Programme Meter with 2x16 LEDs. The scale is linear in volts, not dB. The integration time is much shorter than the fall time. It is useful to indicate signal clipping. This example follows no standard, it is for demonstration purposes only.

[Learn More]

USB FPGA programmer

5

The project is a Xilinx Spartan-3(E) and Spartan-6 FPGA programmer made with PIC18F4550 using USB. There are two host applications: a HID one and a CDC one, written in Delphi. Added support for Delphi XE5.

[Learn More]