quartiq / minimq

Minimal no_std MQTT v5.0 client implementation
MIT License
143 stars 16 forks source link

Refactoring session state buffer management #139

Closed ryan-summers closed 1 year ago

ryan-summers commented 1 year ago

This PR fixes #92 by refactoring the session state to use a singular ring buffer supplied by the user for maintaining republication state.

This should reduce code size and RAM memory footprint.

Now, the session state is backed primarily with a user-provided session buffer. This buffer is used for storing publish messages with QoS > 0 until they are acked.

ryan-summers commented 1 year ago

@jordens This is ready for an initial review, but I'm going to add some more testing around the ring buffer and republication semantics. I'd love to get your opinion on the implementation though.

ryan-summers commented 1 year ago

This should now have all the kinks worked out. I gave it a spin on stabilizer just to be sure, although that isn't using any of the QoS stuff

ryan-summers commented 1 year ago

@jordens Ping on this - it should be ready to go now

ryan-summers commented 1 year ago

Yeah that technically works just fine. There's a little less protection against code defects though because we never check the republication buffer, so it's possible that a defect that corrupts the buffer may mess with our republication state.

However, if that happened, we'd cause protocol errors on the TCP socket and everything would reset anyways, so it's likely not a big deal. It's not updated.