Great library, this is just an issue regarding the examples.
Describe the bug
In example "espMqttClient/examples/simple-esp32/simple-esp32.ino" the loop code to reconnect to broker does not seem to work properly, since currentMIllis is updated only on first time of execution (it is a static variable). The reconnection tries run with no delay:
void loop() {
static uint32_t currentMillis = millis();
if (reconnectMqtt && currentMillis - lastReconnect > 5000) {
connectToMqtt();
}
}
Platform: esp32?
Do you use TLS or not? No
Do you use an IDE (Arduino, Platformio...)? Plarformio
Please include any debug output and/or decoded stack trace if applicable.
Publishing at QoS 2, packetId: 2
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 3
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 4
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 5
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 6
Expected behaviour
Correct timing in reconnection.
Great library, this is just an issue regarding the examples.
Describe the bug
In example "espMqttClient/examples/simple-esp32/simple-esp32.ino" the loop code to reconnect to broker does not seem to work properly, since currentMIllis is updated only on first time of execution (it is a static variable). The reconnection tries run with no delay:
void loop() {
static uint32_t currentMillis = millis();
if (reconnectMqtt && currentMillis - lastReconnect > 5000) {
connectToMqtt();
}
}
Platform: esp32?
Do you use TLS or not? No
Do you use an IDE (Arduino, Platformio...)? Plarformio
Please include any debug output and/or decoded stack trace if applicable.
Publishing at QoS 2, packetId: 2
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 3
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 4
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 5
Disconnected from MQTT: 7.
Connecting to MQTT...
Publishing at QoS 2, packetId: 6
Expected behaviour
Correct timing in reconnection.