From 9f6437ca6a44bde9d902efc3b7b93fe3bfffd5b5 Mon Sep 17 00:00:00 2001
From: Monika Singh <moninom@amazon.com>
Date: Tue, 18 Jul 2023 12:48:12 +0530
Subject: [PATCH] Update MQTT demo timeout and record length (#1030)

* Update MQTT plain text demo timeout and record length

* Update Helper functions

* Update timeout comment

* Update Readme with more details
---
 .../AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c |  9 +-
 .../mqtt_pkcs11_demo_helpers.c                |  9 +-
 .../Common/MutualAuthMQTTExample.c            | 11 ++-
 .../DemoTasks/BasicTLSMQTTExample.c           | 11 ++-
 .../DemoTasks/MutualAuthMQTTExample.c         | 11 ++-
 .../DemoTasks/MutualAuthMQTTExample.c         | 11 ++-
 .../DemoTasks/PlaintextMQTTExample.c          | 11 ++-
 .../coreMQTT_Windows_Simulator/readme.txt     | 88 +++++++++++++++++++
 .../PKCS11_Mqtt_MutualAuthDemo.c              | 11 ++-
 lexicon.txt                                   |  1 +
 10 files changed, 149 insertions(+), 24 deletions(-)

diff --git a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c
index a3f33275ee..ac01e5e70e 100644
--- a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c
+++ b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c
@@ -118,8 +118,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS           ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS           ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing an MQTT connection.
@@ -145,14 +146,16 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * This length depends on the Number of publishes & can be updated accordingly.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN       ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN       ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * This length depends on the Number of publishes & can be updated accordingly.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN       ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN       ( 15U )
 
 /**
  * @brief Maximum number of outgoing publishes maintained in the application
diff --git a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c
index e179e2e17a..ae213665e2 100644
--- a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c
+++ b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c
@@ -111,8 +111,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS           ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS           ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing an MQTT connection.
@@ -138,14 +139,16 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * This length depends on the Number of publishes & can be updated accordingly.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN       ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN       ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * This length depends on the Number of publishes & can be updated accordingly.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN       ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN       ( 15U )
 
 /**
  * @brief Maximum number of outgoing publishes maintained in the application
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/MutualAuthMQTTExample.c
index fd5d9e1c18..a072b753b0 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/MutualAuthMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/MutualAuthMQTTExample.c
@@ -184,8 +184,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 5000U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing
@@ -220,14 +221,18 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * Provide default values for undefined configuration settings.
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c
index 0c8c2b80f4..e6dd537706 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c
@@ -158,8 +158,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief The keep-alive timeout period reported to the broker while establishing
@@ -189,14 +190,18 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleINCOMING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief Milliseconds per second.
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c
index 69fe8a675e..eb2b01a77b 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c
@@ -211,8 +211,9 @@ extern void vLoggingPrintf( const char * pcFormatString,
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing
@@ -242,14 +243,18 @@ extern void vLoggingPrintf( const char * pcFormatString,
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleINCOMING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * Provide default values for undefined configuration settings.
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/DemoTasks/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/DemoTasks/MutualAuthMQTTExample.c
index 3e3c2216c8..c2affeda91 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/DemoTasks/MutualAuthMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/DemoTasks/MutualAuthMQTTExample.c
@@ -127,8 +127,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing
@@ -158,14 +159,18 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * Number of topic subscribed
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * Number of topic subscribed
+ * Update in ulMaxPublishCount needs updating mqttexampleINCOMING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief Milliseconds per second.
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c
index 2435a572c2..2ab7cb992f 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c
@@ -151,8 +151,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief The keep-alive timeout period reported to the broker while establishing
@@ -182,14 +183,18 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * mqttexampleTOPIC_COUNT
+ * Update in ulMaxPublishCount needs updating mqttexampleINCOMING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief Milliseconds per second.
diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt
index 58d3f05ff9..f0acf850d1 100644
--- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt
+++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt
@@ -13,3 +13,91 @@ a re-usable agent component.
 ! always use authenticated and encrypted communication.  Never send private or
 ! sensitive data on an unencrypted connection.
 
+
+In MQTT demos, for each iteration we send 3 QoS2 MQTT Publish messages and receive
+3 QoS2 MQTT Publish messages because we are subscribed to the same topics we
+publish on. Each QoS2 MQTT publish message results in total 4 MQTT packets
+being exchanged between the device and the broker. For example, the following
+MQTT packets are exchanged between the device and the broker when the device
+sends a QoS2 MQTT Publish message:
+
+   Device                   Broker
+      |                         |
+      |      Publish QoS2       |
+      +------------------------>|
+      |        PUBREC           |
+      |<------------------------+
+      |        PUBREL           |
+      +------------------------>|
+      |       PUBCOMP           |
+      |<------------------------+
+      |                         |
+
+The coreMQTT library keeps track of the in-flight publish messages (i.e. the
+publish messages for which the above 4 packets sequence is not complete) in 2
+application supplied arrays - pOutgoingPublishRecords and pIncomingPublishRecords
+in this demo. We need to set the value of mqttexamplePROCESS_LOOP_TIMEOUT_MS to
+ensure that we can keep up with the incoming MQTT packets. We did some experiments
+to find the optimal value of mqttexamplePROCESS_LOOP_TIMEOUT_MS. The following
+table lists the results of our experiments:
+
+ +------------------------------------+-------------+----------------------------------------------------+
+  | mqttexamplePROCESS_LOOP_TIMEOUT_MS | Iteration # | No. of pending messages in pOutgoingPublishRecords |
+  +------------------------------------+-------------+----------------------------------------------------+
+  |               500                  | 0           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 1           | 3                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 2           | 3                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 3           | 6                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 4           | 9                                                  |
+  +------------------------------------+-------------+----------------------------------------------------+
+  |              1000                  | 0           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 1           | 1                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 2           | 3                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 3           | 4                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 4           | 6                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 5           | 7                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 6           | 7                                                  |
+  +------------------------------------+-------------+----------------------------------------------------+
+  |              1500                  | 0           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 1           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 2           | 1                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 3           | 2                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 4           | 3                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 5           | 3                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 6           | 0                                                  |
+  +------------------------------------+-------------+----------------------------------------------------+
+  |              2000                  | 0           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 1           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 2           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 3           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 4           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 5           | 0                                                  |
+  +                                    +-------------+----------------------------------------------------+
+  |                                    | 6           | 0                                                  |
+  +------------------------------------+-------------+----------------------------------------------------+
+
+As clear from the above table, with the value of mqttexamplePROCESS_LOOP_TIMEOUT_MS
+set to 2000, we are able to keep up with the incoming MQTT packets every iteration.
+mqttexamplePROCESS_LOOP_TIMEOUT_MS can be updated according to the requirements.
+
diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/PKCS11_Mqtt_MutualAuthDemo.c b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/PKCS11_Mqtt_MutualAuthDemo.c
index fec70954f1..001da9a21b 100644
--- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/PKCS11_Mqtt_MutualAuthDemo.c
+++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/PKCS11_Mqtt_MutualAuthDemo.c
@@ -130,8 +130,9 @@
 
 /**
  * @brief Timeout for MQTT_ProcessLoop in milliseconds.
+ * Refer to FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/readme.txt for more details.
  */
-#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 500U )
+#define mqttexamplePROCESS_LOOP_TIMEOUT_MS                ( 2000U )
 
 /**
  * @brief Keep alive time reported to the broker while establishing
@@ -161,14 +162,18 @@
 /**
  * @brief The length of the outgoing publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for outgoing publishes.
+ * Number of publishes = ulMaxPublishCount * Number of topic subscribed
+ * Update in ulMaxPublishCount needs updating mqttexampleOUTGOING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleOUTGOING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief The length of the incoming publish records array used by the coreMQTT
  * library to track QoS > 0 packet ACKS for incoming publishes.
+ * Number of publishes = ulMaxPublishCount * Number of topic subscribed
+ * Update in ulMaxPublishCount needs updating mqttexampleINCOMING_PUBLISH_RECORD_LEN.
  */
-#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 10U )
+#define mqttexampleINCOMING_PUBLISH_RECORD_LEN            ( 15U )
 
 /**
  * @brief Milliseconds per second.
diff --git a/lexicon.txt b/lexicon.txt
index 07008c0031..2471d8b7ba 100644
--- a/lexicon.txt
+++ b/lexicon.txt
@@ -2928,6 +2928,7 @@ ulmaxfpuinterruptnesting
 ulmaxjitter
 ulmaxloop
 ulmaxloopcount
+ulmaxpublishcount
 ulmemchecktaskrunningcount
 ulmessagevalue
 ulminorreportversion