Skip to content

Commit 21d13f0

Browse files
committed
Improve logging for mqtt polling aws example
1 parent 53c3332 commit 21d13f0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/examples/mqtt_polling_aws/mqtt_polling_aws.ino

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Tool allows for publishing and subscribing on thing_id/topic. If you want to
1717
// publish and subscribe on other topics, see the AWS IoT Core Policy
1818
// documentation.
19-
#define MQTT_SUB_TOPIC_FMT "%s/mchp_topic_sub"
19+
#define MQTT_SUB_TOPIC_FMT "%s/sensors"
2020
#define MQTT_PUB_TOPIC_FMT "%s/sensors"
2121

2222
char mqtt_sub_topic[128];
@@ -94,7 +94,6 @@ bool initMQTTTopics() {
9494

9595
void setup() {
9696
Log.begin(115200);
97-
Log.setLogLevel(LogLevel::DEBUG);
9897
LedCtrl.begin();
9998
LedCtrl.startupCycle();
10099

@@ -120,15 +119,15 @@ void loop() {
120119
// new message
121120

122121
if (message != "") {
123-
Log.info("Got new message: ");
124-
Log.info(message);
125-
Log.info("\r\n");
122+
Log.infof("Got new message: %s\r\n", message.c_str());
126123
}
127124

128125
bool publishedSuccessfully =
129126
MqttClient.publish(mqtt_pub_topic, "{\"light\": 9, \"temp\": 9}");
130127

131-
if (!publishedSuccessfully) {
128+
if (publishedSuccessfully) {
129+
Log.info("Published message");
130+
} else {
132131
Log.error("Failed to publish\r\n");
133132
}
134133
} else {

0 commit comments

Comments
 (0)