libmosquitto headers for FPC

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

libmosquitto headers for FPC

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: libmosquitto headers for FPC

Marcos Douglas B. Santos
On Thu, Mar 14, 2019 at 11:55 AM Karoly Balogh (Charlie/SGR)
<[hidden email]> wrote:

>
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: libmosquitto headers for FPC

Gustavo Enrique Jimenez
In reply to this post by Karoly Balogh (Charlie/SGR)
El jue., 14 mar. 2019 a las 13:14, Karoly Balogh (Charlie/SGR)
(<[hidden email]>) escribió:

>
> 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


> 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  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: libmosquitto headers for FPC

Karoly Balogh (Charlie/SGR)
In reply to this post by Marcos Douglas B. Santos
Hi,

On Thu, 14 Mar 2019, Marcos Douglas B. Santos wrote:

> > 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal