File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed
examples/mqtt_with_connection_loss_handling Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -141,26 +141,26 @@ void loop() {
141141 }
142142 }
143143
144- // if (millis() - timer > 10000) {
145- if (connected_to_broker) {
146- char message_to_publish[8 ] = {0 };
147- sprintf (message_to_publish, " %lu" , counter);
148-
149- bool published_successfully = MqttClient.publish (mqtt_pub_topic,
150- message_to_publish,
151- AT_LEAST_ONCE,
152- 60000 );
153- if (published_successfully) {
154- Log.infof (" Published message: %s. Failed publishes: %d.\r\n " ,
155- message_to_publish,
156- failed_publishes);
157- } else {
158- failed_publishes++;
144+ if (millis () - timer > 10000 ) {
145+ if (connected_to_broker) {
146+ char message_to_publish[8 ] = {0 };
147+ sprintf (message_to_publish, " %lu" , counter);
148+
149+ bool published_successfully = MqttClient.publish (mqtt_pub_topic,
150+ message_to_publish,
151+ AT_LEAST_ONCE,
152+ 60000 );
153+ if (published_successfully) {
154+ Log.infof (" Published message: %s. Failed publishes: %d.\r\n " ,
155+ message_to_publish,
156+ failed_publishes);
157+ } else {
158+ failed_publishes++;
159+ }
160+
161+ counter++;
159162 }
160163
161- counter++ ;
164+ timer = millis () ;
162165 }
163-
164- timer = millis ();
165- // }
166166}
You can’t perform that action at this time.
0 commit comments