-
Notifications
You must be signed in to change notification settings - Fork 638
Upgrade MQTT demos to v5 #1942
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
base: main
Are you sure you want to change the base?
Upgrade MQTT demos to v5 #1942
Conversation
@@ -97,7 +98,7 @@ | |||
* https://docs.aws.amazon.com/iot/latest/developerguide/client-authentication.html | |||
* | |||
* @note This certificate should be PEM-encoded. | |||
* | |||
*m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove any and all changes made in the demo_config.h files unless it is related to the MQTTv5 upgrade.
@@ -17,6 +17,8 @@ add_executable( | |||
${BACKOFF_ALGORITHM_SOURCES} | |||
) | |||
|
|||
target_sources(${DEMO_NAME} PRIVATE ${ROOT_DIR}/libraries/standard/coreMQTT/source/core_mqtt_utils.c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding this file to the cmake files of all the demos, we should add it to the MQTT_SOURCES
cmake variable defined in the coreMQTT repository in the file: /mqttFilePaths.cmake
@@ -66,7 +66,6 @@ | |||
* | |||
* In general, port 1883 is for unsecured MQTT connections. | |||
*/ | |||
#define BROKER_PORT 1883 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these demo_config.h files should contain these port numbers by default. Hence we should keep them as they are.
{ | ||
assert( pMqttContext != NULL ); | ||
assert( pPacketInfo != NULL ); | ||
assert( pDeserializedInfo != NULL ); | ||
assert( pDeserializedInfo->packetIdentifier != MQTT_PACKET_ID_INVALID ); | ||
// assert( pDeserializedInfo->packetIdentifier != MQTT_PACKET_ID_INVALID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this assert removed?
Thanks @adituc for this PR. The changes look good to me. We will merge this PR once the coreMQTT release is made and we update the submodule pointer here to the latest release of coreMQTT. |
@@ -343,7 +343,10 @@ static void cleanupOutgoingPublishWithPacketID( uint16_t packetId ); | |||
*/ | |||
static void mqttCallback( MQTTContext_t * pMqttContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am aware that you are making these updates but just putting this here so that we do not miss it. We would need to update the event callback signature to the updated one.
@@ -85,6 +85,7 @@ | |||
* @note This path is relative from the demo binary created. Update | |||
* ROOT_CA_CERT_PATH to the absolute path if this demo is executed from elsewhere. | |||
*/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes in the demo_config.h files.
@@ -99,7 +99,7 @@ openssl x509 -req \ | |||
|
|||
Deploy the following components to your Greengrass core: | |||
- aws.greengrass.clientdevices.Auth | |||
- aws.greengrass.clientdevices.mqtt.Moquette | |||
- aws.greengrass.clientdevices.mqtt.EMQX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here that this update is made because the Moquette broker does not support MQTTv5.
* @brief The application callback function for getting the incoming publish | ||
* and incoming acks reported from MQTT library. | ||
* @brief The application callback function for handling MQTT events, including incoming publish | ||
* messages and acknowledgments reported from the MQTT library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well need to update the eventcall back to handle incoming disconnects. This callback is written for the v3 code and it did not have incoming disconnects.
@@ -86,7 +86,7 @@ | |||
* ROOT_CA_CERT_PATH to the absolute path if this demo is executed from elsewhere. | |||
*/ | |||
#ifndef ROOT_CA_CERT_PATH | |||
#define ROOT_CA_CERT_PATH "certificates/AmazonRootCA1.crt" | |||
#define ROOT_CA_CERT_PATH "build/bin/certificates/AmazonRootCA1.crt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the changes done to all demo_config.h files.
@@ -516,7 +522,7 @@ static int createMQTTConnectionWithBroker( NetworkContext_t * pNetworkContext, | |||
Clock_SleepMs( MQTT_RESPONSE_WAIT_TIME_MS ); | |||
/* Since TCP socket has timeout, retry until the data is available */ | |||
result = MQTT_GetIncomingPacketTypeAndLength( Plaintext_Recv, pNetworkContext, &incomingPacket ); | |||
LogInfo( ( "MQTT_GetIncomingPacketTypeAndLength returned: %d\n", result ) ); | |||
// LogInfo( ( "MQTT_GetIncomingPacketTypeAndLength returned: %d\n", result ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this log statement, please uncomment if needed or remove if not needed.
connackProperties.maxPacketSize = MQTT_MAX_PACKET_SIZE; | ||
|
||
MQTTPropBuilder_t propBuffer = {0} ; | ||
result = MQTT_DeserializeAck( &incomingPacket, NULL, &sessionPresent, NULL, 0, MQTT_MAX_PACKET_SIZE, NULL, &connackProperties ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature of this function has also been updated. Please update it here as well.
@@ -66,7 +66,6 @@ | |||
* | |||
* In general, port 8883 is for secured MQTT connections. | |||
*/ | |||
#define BROKER_PORT ( 8883 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change from the demo_config.h file.
{ | ||
globalSubAckStatus = ( result == MQTTSuccess ); | ||
assert( result == MQTTSuccess || result == MQTTServerRefused ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check removed? would we update the globalSubackStatus on receiving a puback as well?
Upgrading MQTT Library to support v5 features
Description of changes:
This PR updates all demo applications in the repository that use MQTT to use MQTT v5.0 instead of MQTT v3.1.1. The goal is to align the demo code with the newer version of the MQTT protocol.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.