From 057f31e7e9fdb6b194bfaad29a636463b42c3acd Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Mon, 6 Feb 2017 12:07:09 -0600 Subject: 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 --- samples/net/mqtt_publisher/src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'samples') 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"; -- cgit v1.2.3