From 6d4cddeec104345206bb7ff18731ad5a78cac34d Mon Sep 17 00:00:00 2001
From: George Oikonomou <george@contiki-ng.org>
Date: Sun, 21 Oct 2018 17:13:17 +0100
Subject: [PATCH] Make the MQTT client example a little more configurable and
 verbose

Suitable for native run testing
---
 examples/mqtt-client/mqtt-client.c  | 5 +++++
 examples/mqtt-client/project-conf.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/examples/mqtt-client/mqtt-client.c b/examples/mqtt-client/mqtt-client.c
index be3c97cdbe..b71a193eae 100644
--- a/examples/mqtt-client/mqtt-client.c
+++ b/examples/mqtt-client/mqtt-client.c
@@ -47,7 +47,11 @@
 #include <strings.h>
 /*---------------------------------------------------------------------------*/
 #define LOG_MODULE "mqtt-client"
+#ifdef MQTT_CLIENT_CONF_LOG_LEVEL
+#define LOG_LEVEL MQTT_CLIENT_CONF_LOG_LEVEL
+#else
 #define LOG_LEVEL LOG_LEVEL_NONE
+#endif
 /*---------------------------------------------------------------------------*/
 /* Controls whether the example will work in IBM Watson IoT platform mode */
 #ifdef MQTT_CLIENT_CONF_WITH_IBM_WATSON
@@ -305,6 +309,7 @@ pub_handler(const char *topic, uint16_t topic_len, const uint8_t *chunk,
   }
 
   if(strncmp(&topic[10], "leds", 4) == 0) {
+    LOG_DBG("Received MQTT SUB\n");
     if(chunk[0] == '1') {
       leds_on(LEDS_RED);
     } else if(chunk[0] == '0') {
diff --git a/examples/mqtt-client/project-conf.h b/examples/mqtt-client/project-conf.h
index 66ba909ce8..6b011f7b02 100644
--- a/examples/mqtt-client/project-conf.h
+++ b/examples/mqtt-client/project-conf.h
@@ -52,7 +52,9 @@
  * devices, set your Org ID here and then make sure you set the correct token
  * through MQTT_CLIENT_CONF_AUTH_TOKEN.
  */
+#ifndef MQTT_CLIENT_CONF_ORG_ID
 #define MQTT_CLIENT_CONF_ORG_ID "quickstart"
+#endif
 
 /*
  * The MQTT username.
-- 
GitLab