Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added explicit settings to control segmented write length and delay #333

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ehong-tl
Copy link

Added a method to set the maximum data length to be written into the network buffer in segments, as well as a method to set the delay between each successive write.

This helps prevent network overloading and network buffer overflow, particularly when using an external GSM/LTE module like the u-blox LARA R280, which I'm using for my project.

Allow to set partial write length for each successive client write into network buffer, as well as delay for each successive partial write.
@256dpi
Copy link
Owner

256dpi commented Sep 13, 2024

Thanks for taking the time to compose this PR! Unfortunately, I cannot merge this right away. The changes to lwmqtt, would need to be submitted to its repository first. But I generally think that for such a problem there would be a better approach:

The library already uses the Arduino Client interface to interact with the network layer. A class that wraps a Client and also implements the Client interface, could efficiently impose the max. write buffer restriction and add the required delays. We could add the class as part of an example for the board you're using. This would be a much better separation of concern. WDYT?

@ehong-tl
Copy link
Author

How about adding the maxPartialWriteLength and partialWriteDelayms variables into lwmqtt_arduino_network_t structure and they can be accessed via ref pointer in the inline lwmqtt_arduino_network_write function?

This will not modify the lwmqtt library.

I try not to touch the Client interface as I believe some of the network libraries have their own implementation of Client wrapper for their device.

I'll try this on Monday.

Revert lwmqtt back to original and modify MQTTClient instead.
Added variables to lwmqtt_arduino_network_t structure for network segmented write and delay control.
@ehong-tl ehong-tl changed the title Added explicit settings to control partial write length and delay Added explicit settings to control segmented write length and delay Sep 16, 2024
@ehong-tl
Copy link
Author

ehong-tl commented Sep 16, 2024

Hey @256dpi

I tested the latest code changes, and everything is working perfectly. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants