Skip to content

Fix QOS arguments parsing for mqttc_pub#3415

Merged
simbit18 merged 2 commits intoapache:masterfrom
dmihai03:mqtt-pub
Mar 2, 2026
Merged

Fix QOS arguments parsing for mqttc_pub#3415
simbit18 merged 2 commits intoapache:masterfrom
dmihai03:mqtt-pub

Conversation

@dmihai03
Copy link
Contributor

@dmihai03 dmihai03 commented Feb 28, 2026

Summary

Modify the switch cases in parsearg function for QOS levels definition. The comparison was made between a long value and a char.

Impact

All the 2 levels of QOS are now supported by the mqtt publisher example.

Testing

Host used for build:

  • OS: Linux 6.18.9-arch1-2
  • CPU: AMD Ryzen 7 5800HS
  • compiler: xtensa-esp32-elf-gcc

Target used for verification:

  • board: ESP32C3
  • config: esp32-devkitc:wifi

Connected the board to laptop's hotspot and dumped the packets in Wireshark. The broker used in testing is broker.hivemq.com.
For every QOS level the right handshakes are triggered.

  1. Before:
    Before the changes, both QOS 1 and QOS 2 message publishing looked like this:

    image

    They were sent with QOS 0, fire and forget, because the QOS level was not modified in the packet.

  2. After:

    QOS 1 handshake:
    image

    QOS 2 handshake:
    image

@cederom
Copy link
Contributor

cederom commented Feb 28, 2026

Thank you @dmihai03 :-)

examples/mqttc: Fix QOS arguments parsing (char->long).

Modify the switch cases in parsearg function for QOS levels definition.
The comparison was made between a long value and a char.

Signed-off-by: ...
  • It is always nice to show logs before and after the fix to show what the problem was and that you fixed it. For now we only see it is working but we do not see it was not working before :-)
  • Other than that looks good :-)

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: git commit fix :-)

Modify the switch cases in parsearg function for QOS levels definition.
The comparison was made between a long value and a char.

Signed-off-by: Mihai Pacuraru <mpacuraru@protonmail.com>
@dmihai03
Copy link
Contributor Author

dmihai03 commented Mar 1, 2026

Thank you!

Before the changes, both QOS 1 and QOS 2 message publishing looked like this:
image

They were sent with QOS 0, fire and forget, because the QOS level was not modified in the packet.

acassis
acassis previously approved these changes Mar 1, 2026
@acassis
Copy link
Contributor

acassis commented Mar 1, 2026

@dmihai03 nice finding! Thank you for submitting this fix.

BTW, could you please fix this typo that the CI found:

$ git grep ERRPR
examples/mqttc/mqttc_pub.c:      printf("ERRPR! mqtt_init() failed.\n");

Modify the message logged when mqtt_init() failed to execute properly.

Signed-off-by: Mihai Pacuraru <mpacuraru@protonmail.com>
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @dmihai03 good catch! :-)

The CI mixed case error comes from underlying library and cannot be changed.

@cederom
Copy link
Contributor

cederom commented Mar 2, 2026

Uhm, still some Linux build problem, CI restarted.

@acassis
Copy link
Contributor

acassis commented Mar 2, 2026

Uhm, still some Linux build problem, CI restarted.

Uhm, still some Linux build problem, CI restarted.

@cederom did you restarted the CI or did you restart only failing Jobs? Full restart can delay more, face similar issues and use more Runners

@acassis
Copy link
Contributor

acassis commented Mar 2, 2026

I'm going to restart failing Jobs (I already did it two times).

@simbit18 seems like msvc is failing most of the time. BTW, the check is failing because MQTT CamelCase names, but let's ignore it

@cederom
Copy link
Contributor

cederom commented Mar 2, 2026

Okay so there is something more to fix here lets investigate :-)

@simbit18
Copy link
Contributor

simbit18 commented Mar 2, 2026

I'm going to restart failing Jobs (I already did it two times).

@simbit18 seems like msvc is failing most of the time. BTW, the check is failing because MQTT CamelCase names, but let's ignore it

Hi @acassis, Runner images can fail for a thousand reasons, and sometimes it's not our fault but GitHub. This can happen for images for macOS, x64 Linux, and Windows images.

@simbit18
Copy link
Contributor

simbit18 commented Mar 2, 2026

@dmihai03 please fix

8dfcac252 Merge e51a1dc2b0197423a07e64ace2fe7af1d5a873f7 into e4b84b29d47b98a666df524d6f2d38904c972de5
e51a1dc2b examples/mqttc: Fix mqtt_init() failed message typo (ERRPR -> ERROR).
450592206 examples/mqttc: Fix QOS arguments parsing (char->long).
../nuttx/tools/checkpatch.sh -c -u -m -g e4b84b29d47b98a666df524d6f2d38904c972de5..HEAD
Error: /home/runner/work/nuttx-apps/nuttx-apps/apps/examples/mqttc/mqttc_pub.c:496:7: error: Mixed case identifier found
Used config files:
    1: .codespellrc
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.

update
enum MQTTErrors mqtterr;
This is due to our nxstyle control tool.

@simbit18 simbit18 merged commit 7d13ee2 into apache:master Mar 2, 2026
63 of 114 checks passed
@dmihai03 dmihai03 deleted the mqtt-pub branch March 2, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants