From 1c57c42930e69a7e049ab19185e8b9f1f49c2fe1 Mon Sep 17 00:00:00 2001 From: Rob Meades Date: Mon, 11 Mar 2024 19:24:17 +0000 Subject: [PATCH] Fix to MQTT client example: correct if() check. (#1115) Another schoolboy error, this time in the MQTT client example: the if() check around uMqttClientSubscribe() was wrong; it just happened to work sometimes because the return value (the QOS of the subscription) can be 0, but it can also be 1 or 2. This is now fixed. --- example/mqtt_client/mqtt_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example/mqtt_client/mqtt_main.c b/example/mqtt_client/mqtt_main.c index 4c026576..369f8a65 100644 --- a/example/mqtt_client/mqtt_main.c +++ b/example/mqtt_client/mqtt_main.c @@ -323,8 +323,11 @@ U_PORT_TEST_FUNCTION("[example]", "exampleMqttClient") // uMqttClientSnSubscribeNormalTopic() instead and // capture the returned MQTT-SN topic name for use with // uMqttClientSnPublish() a few lines below + // Note: >= in this case since the function + // returns the QOS of the subscription, which + // can be 0, 1 or 2 if (uMqttClientSubscribe(pContext, topic, - U_MQTT_QOS_EXACTLY_ONCE)) { + U_MQTT_QOS_EXACTLY_ONCE) >= 0) { // Publish our message to our topic on the // MQTT broker