Recent

Author Topic: Updated MQTT v2 client package somewhere?  (Read 1137 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Updated MQTT v2 client package somewhere?
« on: October 20, 2022, 11:26:50 am »
I am trying to find a package which will allow me to include MQTT transfers of IoT data into my Lazarus/FPC application.
I need it to be able to handle the protocol used by the latest mosquitto MQTT broker.

I have installed the mosquitto broker on a RaspberryPi4 and it got version as shown:
Code: Pascal  [Select][+][-]
  1. mosquitto version 2.0.11
  2. mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.

Is there any way to make a subscribe/publish client with Lazarus (on Linux) using this broker?
What I have found by googling for it is not encouraging since it seems like what is available is quite old and apparently does not work properly nowadays with the updated protocol.
The Github pages shows code to be quite old too, like 5-6 years or more...

Any suggestions?
--
Bo Berglund
Sweden

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Updated MQTT v2 client package somewhere?
« Reply #1 on: October 20, 2022, 11:30:19 am »

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: Updated MQTT v2 client package somewhere?
« Reply #2 on: October 20, 2022, 12:16:12 pm »
Thanks, I will check that and see if I get it running.
Not a package then?
--
Bo Berglund
Sweden


prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: Updated MQTT v2 client package somewhere?
« Reply #4 on: November 14, 2022, 03:46:58 pm »
I want to add my own implementation to that list:

https://github.com/prof7bit/fpc-mqtt-client

It is very new (3 days at the time of this writing) and currently implements only user/pass authentication, no ssl (yet) and no QoS (yet).

It does not need any additional networking library and needs nothing installed in the IDE because it uses only TInetSocket from the SSockets unit. It implements protocol version 5. The license is LGPL v2 with static linking exception.

It can already connect, subscribe, publish, it supports the MQTT5 features "topic alias", "response-topic" and "correlation-data" and I am currently testing on Linux against mosquitto 2.0.x (the one that comes with the home assistant addon).

Edit: 17.11.22: SSL implemented
Edit: 18.11.22: client certificate authentication implemented
Edit: 22.11.22: QoS 1 and 2 implemented
« Last Edit: November 23, 2022, 12:14:23 pm by prof7bit »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Updated MQTT v2 client package somewhere?
« Reply #5 on: November 14, 2022, 11:54:00 pm »
I want to add my own implementation to that list
Thank you!

Unfortunately without SSL, authentication and QoS your lib is currently off my radar.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: Updated MQTT v2 client package somewhere?
« Reply #6 on: November 15, 2022, 03:27:19 pm »
I want to add my own implementation to that list
Thank you!

Unfortunately without SSL, authentication and QoS your lib is currently off my radar.
All this is on my todo list, the next thing I am planning to implement is SSL.

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: Updated MQTT v2 client package somewhere?
« Reply #7 on: November 23, 2022, 12:19:56 pm »
I want to add my own implementation to that list
Thank you!

Unfortunately without SSL, authentication and QoS your lib is currently off my radar.

What you requested has been implemented now. Although I do not yet recommend it for production use at this early time, it should be ready for some tests in real world scenarios. And please file issues on github if anything goes wrong.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Updated MQTT v2 client package somewhere?
« Reply #8 on: November 23, 2022, 01:57:41 pm »
I want to add my own implementation to that list
Thank you!

Unfortunately without SSL, authentication and QoS your lib is currently off my radar.

What you requested has been implemented now. Although I do not yet recommend it for production use at this early time, it should be ready for some tests in real world scenarios. And please file issues on github if anything goes wrong.
Thanks! I will try it on my next MQTT project.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018