summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorFlavio Santes <flavio.santes@intel.com>2017-02-06 12:07:09 -0600
committerJukka Rissanen <jukka.rissanen@linux.intel.com>2017-02-15 12:20:08 +0200
commit057f31e7e9fdb6b194bfaad29a636463b42c3acd (patch)
treece3a384fd083aa12796729711a90568c2f67a967 /samples
parent84403077d26db9c23e75d3e575025334ad9b9de4 (diff)
net/mqtt: Remove length computations for some msg fields
Currently, for the following MQTT msg fields: - client_id - will_topic - user_name - topic their length is computed inside the routine that receives the MQTT msg. Although this simplifies development, also imposes one restriction: data must be null-terminated. Sometimes, data is received from other sources and not generated by the application, so the null-terminated constraint may be considered problematic for the user. This patch removes the assumption that string fields are null-terminated. Current data structures are already prepared to handle this case, so no API change is required. Change-Id: I5a147a5b21e0da49541cbe62baac363c8737cd3e Signed-off-by: Flavio Santes <flavio.santes@intel.com>
Diffstat (limited to 'samples')
-rw-r--r--samples/net/mqtt_publisher/src/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/samples/net/mqtt_publisher/src/main.c b/samples/net/mqtt_publisher/src/main.c
index ce7289bb2..3b485b5bf 100644
--- a/samples/net/mqtt_publisher/src/main.c
+++ b/samples/net/mqtt_publisher/src/main.c
@@ -22,6 +22,8 @@
#include "config.h"
+#define CLIENTID "zephyr_publisher"
+
/**
* @brief mqtt_client_ctx Container of some structures used by the
* publisher app.
@@ -272,7 +274,8 @@ void publisher(void)
* will be set to 0 also. Please don't do that, set always to 1.
* Clean session = 0 is not yet supported.
*/
- client_ctx.connect_msg.client_id = "zephyr_publisher";
+ client_ctx.connect_msg.client_id = CLIENTID;
+ client_ctx.connect_msg.client_id_len = strlen(CLIENTID);
client_ctx.connect_msg.clean_session = 1;
client_ctx.connect_data = "CONNECTED";