"Christian Z." <
chri...@zuckschwerdt.org> writes:
> We do use a network library, which comes with e.g. MQTT support: Mongoose.
> But (like most things C) it is pretty low-level. TLS is supported and
> enabled in rtl_433 for some time now -- the piece needed was the
> certificate setup, parsing options and retaining them.
>
> Similar with MQTT QoS, keeping sent messages around is supported, as are
> timers. But we'd need to manage memory for that and handle timeout/resend
> logic.
> Currently messages are on the stack, so if QoS, copy to heap, keep a list,
> remove from list or resend until some retry limit, and the hard question:
> what to do on repeated fail? Warn and give up? Scale the retry time
> indefinitly? What if the retry list fills up?
I see - the issue is that the mqtt library is too low level. I have
written some (very simple) code in python with the paho python library,
and it deals with all of this for me.
> All very much do-able, but opinionated on the use-case. (there a are good
> reason to "just want QoS", but what exactly is the detailed behaviour
> needed?)
That's a much deeper question. MQTT is pubsub, not state transfer and
not database sync. One could desire that every report generated by
rtl_433 should appear in some remote database, and that leads to writing
it locally and dropping it only when it is acked by the rmeote database
(as committted to stable storage), vs the broker.
With qos 1, you avoid loss due to network breaking (sending into a TCP
connection that has failed, but that you don't know has failed), but I
don't see much point with qos 2, absent a design to do something more
complicated on top of it. However, I'm not sure qos1 messages survive
broker disconnect, even though to me obviously that's the point.
> I guess you never get anything for free (in the sense that it happens like
> magic), in C, except for, well, very fine grained control over things ;)
C libraries could certainly be written that manage all that and hook
into the event loop (or have their own thread). But yes, there's a
complexity tradeoff. I'm not trying to say you should, just that "using
a C library" and "have to do it all yourself" aren't necessarily so
tightly linked.
But fair enough that this is all hard given how things are now.