Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Fix to MQTT client example: correct if() check. (#1115)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RobMeades authored Mar 11, 2024
1 parent 2f39e1b commit 1c57c42
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion example/mqtt_client/mqtt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c57c42

Please sign in to comment.