mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-16 09:47:44 -04:00
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
This commit is contained in:
parent
6682dbbc5b
commit
9f6437ca6a
10 changed files with 149 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -2928,6 +2928,7 @@ ulmaxfpuinterruptnesting
|
|||
ulmaxjitter
|
||||
ulmaxloop
|
||||
ulmaxloopcount
|
||||
ulmaxpublishcount
|
||||
ulmemchecktaskrunningcount
|
||||
ulmessagevalue
|
||||
ulminorreportversion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue