Skip to content

Commit 7be0074

Browse files
committed
Only writ to serial if DEBUG is set
1 parent ea32695 commit 7be0074

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/EasyMqtt.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ class EasyMqtt : public MqttMap {
2828
debug("Connected to MQTT");
2929
subscribe();
3030
} else {
31+
#ifdef DEBUG
3132
Serial.print("failed, rc=");
3233
Serial.print(mqttClient.state());
3334
Serial.println(" try again in 5 seconds");
35+
#endif
3436
delay(5000);
3537
}
3638
}
@@ -53,7 +55,9 @@ class EasyMqtt : public MqttMap {
5355
}
5456

5557
void debug(String msg) {
58+
#ifdef DEBUG
5659
Serial.println(msg);
60+
#endif
5761
get("system")["debug"].publish(msg);
5862
}
5963

@@ -66,14 +70,18 @@ class EasyMqtt : public MqttMap {
6670

6771
while (WiFi.status() != WL_CONNECTED) {
6872
delay(500);
73+
#ifdef DEBUG
6974
Serial.print(".");
75+
#endif
7076
}
77+
#ifdef DEBUG
7178
Serial.println("WiFi connected");
7279
Serial.print("IP address: ");
7380
Serial.println(WiFi.localIP());
7481

7582
Serial.print("Chip ID : ");
7683
Serial.println(ESP.getChipId());
84+
#endif
7785

7886
// Setup wifi diag
7987
get("system")["wifi"]["rssi"] << []() {
@@ -99,8 +107,10 @@ class EasyMqtt : public MqttMap {
99107
mqtt_username = username;
100108
mqtt_password = password;
101109

110+
#ifdef DEBUG
102111
Serial.print("Topic: ");
103112
Serial.println(getTopic());
113+
#endif
104114
}
105115

106116
/**

0 commit comments

Comments
 (0)