File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 140140/**
141141 * @brief Timeout for MQTT_ProcessLoop function in milliseconds.
142142 */
143- #define MQTT_PROCESS_LOOP_TIMEOUT_MS ( 500U )
143+ #define MQTT_PROCESS_LOOP_TIMEOUT_MS ( 100U )
144+
145+ /**
146+ * @brief Period for demo loop sleep in milliseconds.
147+ */
148+ #define OTA_EXAMPLE_LOOP_SLEEP_PERIOD_MS ( 5000U )
144149
145150/**
146151 * @brief The delay used in the main OTA Demo task loop to periodically output the OTA
@@ -1979,7 +1984,7 @@ static int startOTADemo( void )
19791984 if ( pthread_mutex_lock ( & mqttMutex ) == 0 )
19801985 {
19811986 /* Loop to receive packet from transport interface. */
1982- mqttStatus = MQTT_ProcessLoop ( & mqttContext , 0 );
1987+ mqttStatus = MQTT_ProcessLoop ( & mqttContext , MQTT_PROCESS_LOOP_TIMEOUT_MS );
19831988
19841989 pthread_mutex_unlock ( & mqttMutex );
19851990 }
@@ -2000,6 +2005,12 @@ static int startOTADemo( void )
20002005 otaStatistics .otaPacketsQueued ,
20012006 otaStatistics .otaPacketsProcessed ,
20022007 otaStatistics .otaPacketsDropped ) );
2008+
2009+ /* Delay if mqtt process loop is set to zero.*/
2010+ if ( !( MQTT_PROCESS_LOOP_TIMEOUT_MS > 0 ) )
2011+ {
2012+ Clock_SleepMs ( OTA_EXAMPLE_LOOP_SLEEP_PERIOD_MS );
2013+ }
20032014 }
20042015 else
20052016 {
Original file line number Diff line number Diff line change 131131/**
132132 * @brief Timeout for MQTT_ProcessLoop function in milliseconds.
133133 */
134- #define MQTT_PROCESS_LOOP_TIMEOUT_MS ( 500U )
134+ #define MQTT_PROCESS_LOOP_TIMEOUT_MS ( 100U )
135+
136+ /**
137+ * @brief Period for demo loop sleep in milliseconds.
138+ */
139+ #define OTA_EXAMPLE_LOOP_SLEEP_PERIOD_MS ( 5000U )
135140
136141/**
137142 * @brief Size of the network buffer to receive the MQTT message.
@@ -1547,7 +1552,7 @@ static int startOTADemo( void )
15471552 if ( pthread_mutex_lock ( & mqttMutex ) == 0 )
15481553 {
15491554 /* Loop to receive packet from transport interface. */
1550- mqttStatus = MQTT_ProcessLoop ( & mqttContext , 0 );
1555+ mqttStatus = MQTT_ProcessLoop ( & mqttContext , MQTT_PROCESS_LOOP_TIMEOUT_MS );
15511556
15521557 pthread_mutex_unlock ( & mqttMutex );
15531558 }
@@ -1568,6 +1573,12 @@ static int startOTADemo( void )
15681573 otaStatistics .otaPacketsQueued ,
15691574 otaStatistics .otaPacketsProcessed ,
15701575 otaStatistics .otaPacketsDropped ) );
1576+
1577+ /* Delay if mqtt process loop is set to zero.*/
1578+ if ( !( MQTT_PROCESS_LOOP_TIMEOUT_MS > 0 ) )
1579+ {
1580+ Clock_SleepMs ( OTA_EXAMPLE_LOOP_SLEEP_PERIOD_MS );
1581+ }
15711582 }
15721583 else
15731584 {
You can’t perform that action at this time.
0 commit comments