Skip to content

MQTTv5 Implementation #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 266 commits into
base: main
Choose a base branch
from
Open

MQTTv5 Implementation #316

wants to merge 266 commits into from

Conversation

adituc
Copy link

@adituc adituc commented Mar 11, 2025

Upgrading MQTT Library to support v5 features

Description

Test Steps

  • Unit Tests are added for all new and modified features.
  • Unit Tests for MQTTv5 functions are added in a separate folder in test.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@DakshitBabbar
Copy link
Member

/bot run formatting

* duplicate incoming publishes. */
* before sending acks. */

reasonCode = MQTT_REASON_PUBREC_SUCCESS;
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't the callback modify this value? Why are we explicitly setting this?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the callback has the option to modify the reason code. The reason code has been initialized to this defualt value in the case where the callback does not modify this value. According to the v5 spec, In the Publish Ack packets, if the Remaining Length is 2, then there is no Reason Code and the value of 0x00 (Success) is used.

MQTT_REASON_PUBREC_SUCCESS (0x00) is just the default value to indicate no modification of the reason code.


if( ( ackPropsAdded == false ) && ( reasonCode == MQTT_REASON_PUBREC_SUCCESS ) )
{
status = sendPublishAcks( pContext,
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me why are we not using MQTT_PRE_SEND_HOOK and POST send hooks here?

Copy link
Author

Choose a reason for hiding this comment

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

We changed MQTT_PRE_SEND_HOOK and MQTT_POST_SEND_HOOK into just MQTT_PRE_STATE_UPDATE_HOOK and MQTT_POST_STATE_UPDATE_HOOK and shifted the hooks inside the sendPublishAcks function ( to make it thread - safe ). These hooks are then called while sending a packet as well as updating the state. Removed the send hooks from the sendPublishAcksWithProperty() as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants