BTW, I did:
(mosquitto_message_callback_set mosq (procedure->pointer void receive-message (list '* '* '*))) Is it correct to pass '* as argument type for the struct mosquitto_message pointer (3rd arg)? On Fri, Nov 1, 2024 at 4:08 PM Mikael Djurfeldt <mik...@djurfeldt.com> wrote: > Thanks! > > Doing the (make-cdata struct-mosquitto_message* message) as well as > changing cdata-ref to cdata*-ref works fine. > > Obviously, what someone should do is to write a nice schemey interface on > top of what you get with (ffi mosquitto). > > Best regards, > Mikael > > On Fri, Nov 1, 2024 at 3:05 PM Matt Wette <matt.we...@gmail.com> wrote: > >> And one more thing. There is a manual for cdata. There is a link on >> this page >> >> https://www.nongnu.org/nyacc/ >> >> >> On 11/1/24 6:37 AM, Matt Wette wrote: >> > I got this wrong. Sorry! This is it. What I gave previously was >> > the old fh syntax. >> > >> > (msg (make-cdata struct-mosquitto_message* message)) >> > >> > >> > >> > On 11/1/24 6:32 AM, Matt Wette wrote: >> >> assuming message is a Guile pointer: >> >> >> >> (define (receive-message mosq obj message) >> >> (let ((msg (make-struct-mosquitto_message* message)) >> >> (size (cdata-ref msg '* 'payloadsize)) >> >> (payload (cdata-ref msg '* 'payload)) >> >> (pointer->string payload size))) >> >> >> >> >> >> On 10/31/24 4:49 PM, Mikael Djurfeldt wrote: >> >>> Hi Matt, >> >>> >> >>> This is very nice indeed! :-) >> >>> >> >>> I got a small client working, but I found the unpacking of values in >> >>> the message callback function a bit cumbersome. I now have: >> >>> >> >>> (define (pointer->struct-mosquitto_message pointer) >> >>> (let* ((size (ctype-size struct-mosquitto_message)) >> >>> (bvec (pointer->bytevector pointer size))) >> >>> (Xcdata-ref bvec 0 struct-mosquitto_message))) ;The only >> >>> way I found that worked! :) >> >>> >> >>> (define (receive-message mosq obj message) >> >>> (let* ((message (pointer->struct-mosquitto_message message)) >> >>> (payload (cdata-ref message 'payload)) >> >>> (size (cdata-ref message 'payloadlen)) >> >>> (payload (pointer->string payload size))) >> >>> (display payload) >> >>> (newline))) >> >>> >> >>> Is there some more convenient/right way to do that? >> >>> >> >>> Best regards, >> >>> Mikael >> >>> >> >>> On Thu, Oct 31, 2024 at 1:02 PM Matt Wette <matt.we...@gmail.com> >> >>> wrote: >> >>> >> >>> On 10/31/24 1:48 AM, Ricardo G. Herdt wrote: >> >>> > Hi, >> >>> > >> >>> > never did it myself, but you can create some bindings to >> >>> libmosquitto >> >>> > for your usecase. There are bindings for chicken, one can take >> >>> some >> >>> > inspiration from there: >> >>> http://wiki.call-cc.org/eggref/5/mosquitto#api >> >>> > >> >>> > Regards, >> >>> > >> >>> > Ricardo >> >>> > >> >>> > Am 31.10.2024 03:24 schrieb Alan Wedel: >> >>> >> I have been working on a controller that uses a >> >>> microcontroller to >> >>> >> read some sensors and publish their data to a mqtt broker. I >> >>> would >> >>> >> like to have a guile program subscribe to the mqtt broker and >> >>> log the >> >>> >> sensor readings to a file. Is there anyone using guile with >> >>> mqtt like >> >>> >> this? If so, how are you doing it? >> >>> > >> >>> >> >>> Here is a dot-ffi file for mosquitto using nyacc: >> >>> >> >>> (define-ffi-module (ffi mosquitto) >> >>> #:pkg-config "libmosquitto" >> >>> #:include '("mosquitto.h")) >> >>> >> >>> >> >>> I just uploaded nyacc-2.01.2, needed to compile above. >> >>> >> >>> refs: >> >>> https://savannah.nongnu.org/projects/nyacc >> >>> https://www.nongnu.org/nyacc/nyacc-fh-ug.html >> >>> >> >>> Matt >> >>> >> >>> >> >>> >> >>> >> >>> >> > >> > >> >>