Skip to content

Commit 20c2835

Browse files
committed
Allow users to specify the yield time if they want to speed up loop processing.
1 parent 3c579ac commit 20c2835

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/CayenneArduinoMQTTClient.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ class CayenneArduinoMQTTClient
8383

8484
/**
8585
* Main Cayenne loop
86+
*
87+
* @param yieldTime Time in milliseconds to yield to allow processing of incoming MQTT messages and keep alive packets.
88+
* NOTE: Decreasing the yieldTime while calling write functions (e.g. virtualWrite) in your main loop could cause a
89+
* large number of messages to be sent to the Cayenne server. Use caution when adjusting this because sending too many
90+
* messages could cause your IP to be rate limited or even blocked. If you would like to reduce the yieldTime to cause your
91+
* main loop to run faster, make sure you use a timer for your write functions to prevent them from running too often.
8692
*/
87-
void loop() {
88-
CayenneMQTTYield(&_mqttClient, 1000);
93+
void loop(int yieldTime = 1000) {
94+
CayenneMQTTYield(&_mqttClient, yieldTime);
8995
pollChannels(virtualChannels);
9096
#ifdef DIGITAL_AND_ANALOG_SUPPORT
9197
pollChannels(digitalChannels);

0 commit comments

Comments
 (0)