monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 12 forks source link

Reduce the `yield` execution time #14

Closed monstrenyatko closed 7 years ago

monstrenyatko commented 7 years ago

When no data available to receive or it is not a time to send keep alive message, etc...yield still consumes a lot of time due to the NET_MIN_TM_MS value (see #12 discussion). The NET_MIN_TM_MS was introduced to guaranty reception of the entire message by single recvPacket call.

Solution:

Risks: May increase the number of disconnections in case of bad network connection because the library still needs to receive the entire message while single yield call.

monstrenyatko commented 7 years ago

Hi @tarzan115

This improvement is related to your problem (#12). Could you please try and let me know.

monstrenyatko commented 7 years ago

Hi @gjt211

The latest changes should allow you to have very quick loop iterations. Just call the MqttClient::yield with 0 or any other small enough value for you and set the NET_MIN_TM_MS to something very small using MqttClient constructor. The default value of the NET_MIN_TM_MS is 10 ms.

tarzan115 commented 7 years ago

hi @monstrenyatko I have tested with NET_MIN_TM_MS = 10 and NET_MIN_TM_MS = 1 in a few days. and it works fine 😃 thank you so much for that ❤️

monstrenyatko commented 7 years ago

Hi @tarzan115 Great! I'll prepare the new release. Thank you for the confirmation!