From 78921451273a654b78057e9bcbbb283133294259 Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Tue, 6 Oct 2020 14:50:31 -0700 Subject: [PATCH 1/6] Allow PUBACK and PUBREC to be resent irrespective of the DUP flag --- source/core_mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 24439905f..e53610bd6 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1054,7 +1054,7 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, * state engine. This will be handled by ignoring the * #MQTTStateCollision status from the state engine. The publish * data is not passed to the application. */ - else if( ( status == MQTTStateCollision ) && ( publishInfo.dup == true ) ) + else if( status == MQTTStateCollision ) { status = MQTTSuccess; duplicatePublish = true; From 1fb2e9d00a38a9ce3dd9eedbfe83b465aa1acb1d Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Tue, 6 Oct 2020 15:30:33 -0700 Subject: [PATCH 2/6] Add log message when packet id already exists but DUP=0 --- source/core_mqtt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index e53610bd6..f8e90c827 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1063,8 +1063,17 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, * for the duplicate incoming publish. */ publishRecordState = MQTT_CalculateStatePublish( MQTT_RECEIVE, publishInfo.qos ); - LogDebug( ( "Incoming publish packet with packet id %u already exists.", - packetIdentifier ) ); + + if( publishInfo.dup ) + { + LogDebug( ( "Incoming publish packet with packet id %u already exists.", + packetIdentifier ) ); + } + else + { + LogError( ( "Incoming publish packet with packet id %u already exists, but DUP flag is 0.", + packetIdentifier ) ); + } } else { From 3247e0fdc243879c30f9414427a37366112de215 Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Tue, 6 Oct 2020 15:36:50 -0700 Subject: [PATCH 3/6] Update error log --- source/core_mqtt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index f8e90c827..559777593 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1064,15 +1064,12 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, publishRecordState = MQTT_CalculateStatePublish( MQTT_RECEIVE, publishInfo.qos ); - if( publishInfo.dup ) - { - LogDebug( ( "Incoming publish packet with packet id %u already exists.", - packetIdentifier ) ); - } - else + LogDebug( ( "Incoming publish packet with packet id %u already exists.", + packetIdentifier ) ); + + if( publishInfo.dup == false ) { - LogError( ( "Incoming publish packet with packet id %u already exists, but DUP flag is 0.", - packetIdentifier ) ); + LogError( ( "DUP flag is 0 for duplicate publish packet." ) ); } } else From fe324d992173dea037fa7742325ee220d2372cbd Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Tue, 6 Oct 2020 15:46:27 -0700 Subject: [PATCH 4/6] Name the publish packet as duplicate in the log --- source/core_mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 559777593..9f4e545b6 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1069,7 +1069,7 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, if( publishInfo.dup == false ) { - LogError( ( "DUP flag is 0 for duplicate publish packet." ) ); + LogError( ( "DUP flag is 0 for duplicate incoming publish packet." ) ); } } else From 0ff05212becb17463f558eef6d7bf08cfc2b1aa4 Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Tue, 6 Oct 2020 17:19:22 -0700 Subject: [PATCH 5/6] Change to LogInfo --- source/core_mqtt_serializer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core_mqtt_serializer.c b/source/core_mqtt_serializer.c index 2c25270b3..6c9b87098 100644 --- a/source/core_mqtt_serializer.c +++ b/source/core_mqtt_serializer.c @@ -955,7 +955,7 @@ static MQTTStatus_t deserializeConnack( const MQTTPacketInfo_t * pConnack, if( ( pRemainingData[ 0 ] & MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK ) == MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK ) { - LogWarn( ( "CONNACK session present bit set." ) ); + LogInfo( ( "CONNACK session present bit set." ) ); *pSessionPresent = true; /* MQTT 3.1.1 specifies that the fourth byte in CONNACK must be 0 if the From 53b61309c0d7ccd7abf440a4c58e17b044a21b61 Mon Sep 17 00:00:00 2001 From: Oscar Abrina Date: Wed, 7 Oct 2020 12:36:43 -0700 Subject: [PATCH 6/6] Change log message to specify the part of the specification --- source/core_mqtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 9f4e545b6..c29ef210c 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -1069,7 +1069,7 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, if( publishInfo.dup == false ) { - LogError( ( "DUP flag is 0 for duplicate incoming publish packet." ) ); + LogError( ( "DUP flag is 0 for duplicate packet (MQTT-3.3.1.-1)." ) ); } } else