Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-03

libmosquitto headers for FPC

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Karoly Balogh (Charlie/SGR

Hi,

Not sure if anyone have done this already, but I converted the libmosquitto (which is a C-written MQTT client library) header (mosquitto.h) to Free Pascal, so it allows using libmosquitto from Pascal code. I work on some IoT projects lately which transfers data over MQTT, and I wanted to write some of the code in Pascal (after some other languages failed to meet expectations, business as usual), so I just did it. I know some Pascal MQTT libraries exist, but all I encountered seemed to have some limitations, or things I didn't like (being too Delphi centric, or something) and libmosquitto just seems to be much more used.

Note this is only a pure conversion of the C header file using ctypes, with some pascalisms added (like proper callback function types). I have an additional class-layer on top of it planned, but so far I only got the headers converted, but they work in our internal project. I want to add some examples later too.

So in case anyone needs this:

http://github.com/chainq/mosquitto-p

As we hopefully will soon use this in production, I sort of committed to keep the headers up-to-date.

I tested it on Darwin (x86_64) and Linux (x86_64 and arm), but adding Windows support should be trivial. (Probably only needs the right .dll name added as linklib, or something.)

Charlie

Reply by email

Marcos Douglas B. Santos
to Karoly Balogh (Charlie/SGR
AM Karoly Balogh wrote 29 lines
Hi, Not sure if anyone have done this already, but I converted the libmosquitto (which is a C-written MQTT client library) header (mosquitto.h) to Free Pascal, so it allows using libmosquitto from Pascal code. I work on some IoT projects lately which transfers data over MQTT, and I wanted to write some of the code in Pascal (after some other languages failed to meet expectations, business as usual), so I just did it. I know some Pascal MQTT libraries exist, but all I encountered seemed to have some limitations, or things I didn't like (being too Delphi centric, or something) and libmosquitto just seems to be much more used. Note this is only a pure conversion of the C header file using ctypes, with some pascalisms added (like proper callback function types). I have an additional class-layer on top of it planned, but so far I only got the headers converted, but they work in our internal project. I want to add some examples later too. So in case anyone needs this: http://github.com/chainq/mosquitto-p As we hopefully will soon use this in production, I sort of committed to keep the headers up-to-date. I tested it on Darwin (x86_64) and Linux (x86_64 and arm), but adding Windows support should be trivial. (Probably only needs the right .dll name added as linklib, or something.)

Good job.

I'm thinking use some like that to split a big desktop application code into few other applications, maintaining a communication among them.
Is it a good case to use mosquitto? If so, I can help you on Windows, testing and etc.

best regards,
Marcos Douglas

Reply by email

Gustavo Enrique Jimenez
to Karoly Balogh (Charlie/SGR: Not sure if anyone have done this already, but I converted the libmosquitto (which is a…
Show quoted text 13 lines
Hi, Not sure if anyone have done this already, but I converted the libmosquitto (which is a C-written MQTT client library) header (mosquitto.h) to Free Pascal, so it allows using libmosquitto from Pascal code. I work on some IoT projects lately which transfers data over MQTT, and I wanted to write some of the code in Pascal (after some other languages failed to meet expectations, business as usual), so I just did it. I know some Pascal MQTT libraries exist, but all I encountered seemed to have some limitations, or things I didn't like (being too Delphi centric, or something) and libmosquitto just seems to be much more used.

Thank you very much!

Gustavo

Show quoted text 21 lines
Note this is only a pure conversion of the C header file using ctypes, with some pascalisms added (like proper callback function types). I have an additional class-layer on top of it planned, but so far I only got the headers converted, but they work in our internal project. I want to add some examples later too. So in case anyone needs this: http://github.com/chainq/mosquitto-p As we hopefully will soon use this in production, I sort of committed to keep the headers up-to-date. I tested it on Darwin (x86_64) and Linux (x86_64 and arm), but adding Windows support should be trivial. (Probably only needs the right .dll name added as linklib, or something.) Charlie _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Karoly Balogh (Charlie/SGR
to Marcos Douglas B. Santos: On Thu, Mar 14, 2019 at 11:55 AM Karoly Balogh (Charlie/SGR) Good job. I'm thinking use…

Hi,

Marcos Douglas B. Santos wrote 9 lines
> So in case anyone needs this: > > http://github.com/chainq/mosquitto-p Good job. I'm thinking use some like that to split a big desktop application code into few other applications, maintaining a communication among them.

Well, MQTT is more like a cross-host messaging protocol, like your swarm of devices can trivally connect to a broker, and send messages, which then can be subscribed to and processed, also with higher QoS levels it can retain messages until a certain client connects (for configuration updates, etc), has quaranteed delivery, etc.

You can use it as an interprocess messaging bus (and we have some projects where we actually do that, because of reasons), but there are better tools for that maybe... :)

Is it a good case to use mosquitto? If so, I can help you on Windows, testing and etc.

Well, we use it in production and works well (on Linux). Although older versions of the library (still distributed in some older 'stable' Linux distros) had some issues regarding memory leaks, but at least the very core functionality seems to be quite stable these days. And you can always compile your own version anyway.

Charlie

Reply by email