Skip to content

Commit 533039e

Browse files
authored
Merge pull request #51 from FreeRTOS/reversion
Reverts Process Loop breaking change
2 parents d25036b + f4fe11e commit 533039e

File tree

4 files changed

+30
-101
lines changed

4 files changed

+30
-101
lines changed

main/Kconfig.projbuild

+28-33
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ menu "Featured FreeRTOS IoT Integration"
6262
config GRI_QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR
6363
bool "Generate a key pair."
6464
default n
65-
65+
6666
config GRI_QUALIFICATION_MQTT_ENDPOINT
6767
string "Endpoint for MQTT Broker to use"
6868
default "PLACE_HOLDER"
@@ -72,19 +72,19 @@ menu "Featured FreeRTOS IoT Integration"
7272
config GRI_QUALIFICATION_MQTT_PORT
7373
int "Port for MQTT Broker to use"
7474
default 8883
75-
75+
7676
config GRI_QUALIFICATION_CLIENT_IDENTIFIER
7777
string "Client Identifier for MQTT Test"
7878
default "PLACE_HOLDER"
79-
79+
8080
config GRI_QUALIFICATION_NETWORK_BUFFER_SIZE
8181
int "Network Buffer Size for MQTT Test"
8282
default 5000
83-
83+
8484
config GRI_QUALIFICATION_PROCESS_LOOP_TIMEOUT_MS
8585
int "Timeout to run MQTT process loop for MQTT Test"
8686
default 700
87-
87+
8888
config GRI_QUALIFICATION_ECHO_SERVER
8989
string "Echo Server Domain Name/IP for Transport Interface Test"
9090
default "PLACE_HOLDER"
@@ -94,36 +94,36 @@ menu "Featured FreeRTOS IoT Integration"
9494
config GRI_QUALIFICATION_ECHO_SERVER_PORT
9595
int "Port for Echo Server to use"
9696
default 9000
97-
97+
9898
config GRI_QUALIFICATION_OTA_PAL_CERTIFICATE_FILE
9999
string "Path to cert for OTA PAL Test."
100100
default ""
101-
101+
102102
config GRI_QUALIFICATION_OTA_PAL_FIRMWARE_FILE
103103
string "Path to store firmware for OTA PAL Test."
104104
default "/"
105-
105+
106106
config GRI_QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM
107107
bool "Use File System for OTA PAL Test."
108108
default n
109-
109+
110110
config GRI_QUALIFICATION_THING_NAME
111111
string "Thing Name for Device Advisor Test/OTA end-to-end Test"
112112
default "PLACE_HOLDER"
113-
113+
114114
config GRI_QUALIFICATION_OTA_APP_VERSION_MAJOR
115115
int "Application version major for OTA end-to-end Test."
116116
default 0
117-
117+
118118
config GRI_QUALIFICATION_OTA_APP_VERSION_MINOR
119119
int "Application version minor for OTA end-to-end Test."
120120
default 9
121-
121+
122122
config GRI_QUALIFICATION_OTA_APP_VERSION_BUILD
123123
int "Application version build for OTA end-to-end Test."
124124
default 0
125125
endmenu # "Qualification Parameter Configurations"
126-
126+
127127
menu "Sub pub unsub demo configurations"
128128
config GRI_SUB_PUB_UNSUB_DEMO_STRING_BUFFER_LENGTH
129129
int "Topic name and payload buffer length"
@@ -142,14 +142,14 @@ menu "Featured FreeRTOS IoT Integration"
142142
default 500
143143
help
144144
The maximum amount of time in milliseconds to wait for the commands to be posted to the MQTT agent should the MQTT agent's command queue be full. Tasks wait in the Blocked state, so don't use any CPU time.
145-
145+
146146
config GRI_SUB_PUB_UNSUB_DEMO_QOS_LEVEL
147147
int "QoS level of MQTT operations"
148148
default 1
149149
range 0 2
150150
help
151151
The QoS level of MQTT messages sent by this demo. This must be 0 or 1 if using AWS as AWS only supports levels 0 or 1. If using another MQTT broker, that supports QoS level 2, this can be set to 2.
152-
152+
153153
config GRI_SUB_PUB_UNSUB_DEMO_NUM_TASKS_TO_CREATE
154154
int "Number of SubPubUnsub tasks to create"
155155
default 1
@@ -167,7 +167,7 @@ menu "Featured FreeRTOS IoT Integration"
167167
default 3072
168168
help
169169
The task stack size for each of the SubPubUnsub tasks.
170-
170+
171171
endmenu # Sub pub unsub demo configurations
172172

173173
menu "OTA demo configurations"
@@ -182,7 +182,7 @@ menu "Featured FreeRTOS IoT Integration"
182182
default 128
183183
help
184184
The maximum size of the stream name required for downloading update file from streaming service.
185-
185+
186186
config GRI_OTA_DEMO_TASK_DELAY_MS
187187
int "OTA statistic output delay milliseconds."
188188
default 1000
@@ -206,7 +206,7 @@ menu "Featured FreeRTOS IoT Integration"
206206
config GRI_OTA_DEMO_DEMO_TASK_PRIORITY
207207
int "OTA demo task priority."
208208
default 1
209-
209+
210210
config GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE
211211
int "OTA demo task stack size."
212212
default 3072
@@ -233,11 +233,6 @@ menu "Featured FreeRTOS IoT Integration"
233233
bool "Output provisioned certificates and keys."
234234
default y
235235

236-
config GRI_TRANSPORT_TIMEOUT_MS
237-
int "TLS Transport Send / Receive timeout in milliseconds"
238-
default 1000
239-
240-
241236
menu "coreMQTT-Agent Manager Configurations"
242237

243238
config GRI_MQTT_AGENT_TASK_STACK_SIZE
@@ -282,7 +277,7 @@ menu "Featured FreeRTOS IoT Integration"
282277
int "Timeout for receiving CONNACK in milliseconds"
283278
default 1000
284279

285-
280+
286281
endmenu # coreMQTT-Agent Manager Configurations
287282

288283
config GRI_ENABLE_SUB_PUB_UNSUB_DEMO
@@ -310,14 +305,14 @@ menu "Featured FreeRTOS IoT Integration"
310305
default 500
311306
help
312307
The maximum amount of time in milliseconds to wait for the commands to be posted to the MQTT agent should the MQTT agent's command queue be full. Tasks wait in the Blocked state, so don't use any CPU time.
313-
308+
314309
config GRI_SUB_PUB_UNSUB_DEMO_QOS_LEVEL
315310
int "QoS level of MQTT operations"
316311
default 1
317312
range 0 2
318313
help
319314
The QoS level of MQTT messages sent by this demo. This must be 0 or 1 if using AWS as AWS only supports levels 0 or 1. If using another MQTT broker, that supports QoS level 2, this can be set to 2.
320-
315+
321316
config GRI_SUB_PUB_UNSUB_DEMO_NUM_TASKS_TO_CREATE
322317
int "Number of SubPubUnsub tasks to create"
323318
default 1
@@ -335,9 +330,9 @@ menu "Featured FreeRTOS IoT Integration"
335330
default 3072
336331
help
337332
The task stack size for each of the SubPubUnsub tasks.
338-
333+
339334
endmenu # Sub pub unsub demo configurations
340-
335+
341336
config GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO
342337
bool "Enable temperature sensor pub sub and LED control demo"
343338
depends on !GRI_RUN_QUALIFICATION_TEST
@@ -386,7 +381,7 @@ menu "Featured FreeRTOS IoT Integration"
386381
default 500
387382
help
388383
The maximum amount of time in milliseconds to wait for the commands to be posted to the MQTT agent should the MQTT agent's command queue be full. Tasks wait in the Blocked state, so don't use any CPU time.
389-
384+
390385
config GRI_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO_QOS_LEVEL
391386
int "QoS level of MQTT operations"
392387
default 1
@@ -412,7 +407,7 @@ menu "Featured FreeRTOS IoT Integration"
412407
bool "Enable OTA demo"
413408
depends on !GRI_RUN_QUALIFICATION_TEST
414409
default y
415-
410+
416411
menu "OTA demo configurations"
417412
depends on GRI_ENABLE_OTA_DEMO
418413

@@ -427,7 +422,7 @@ menu "Featured FreeRTOS IoT Integration"
427422
default 128
428423
help
429424
The maximum size of the stream name required for downloading update file from streaming service.
430-
425+
431426
config GRI_OTA_DEMO_TASK_DELAY_MS
432427
int "OTA statistic output delay milliseconds."
433428
default 1000
@@ -451,7 +446,7 @@ menu "Featured FreeRTOS IoT Integration"
451446
config GRI_OTA_DEMO_DEMO_TASK_PRIORITY
452447
int "OTA demo task priority."
453448
default 1
454-
449+
455450
config GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE
456451
int "OTA demo task stack size."
457452
default 3072
@@ -470,6 +465,6 @@ menu "Featured FreeRTOS IoT Integration"
470465

471466
endmenu # OTA demo configurations
472467

473-
endmenu # Golden Reference Integration
468+
endmenu # Golden Reference Integration
474469

475470

main/main.c

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ static BaseType_t prvInitializeNetworkContext( void )
152152

153153
xNetworkContext.pcHostname = CONFIG_GRI_MQTT_ENDPOINT;
154154
xNetworkContext.xPort = CONFIG_GRI_MQTT_PORT;
155-
xNetworkContext.xTimeout = pdMS_TO_TICKS( CONFIG_GRI_TRANSPORT_TIMEOUT_MS );
156155

157156
/* Get the device certificate from esp_secure_crt_mgr and put into network
158157
* context. */

main/networking/mqtt/core_mqtt_agent_manager.c

+1-66
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "core_mqtt_agent.h"
5454

5555
/* coreMQTT-Agent port include. */
56-
#include "esp_tls.h"
5756
#include "freertos_agent_message.h"
5857
#include "freertos_command_pool.h"
5958

@@ -633,7 +632,6 @@ static MQTTStatus_t prvCoreMqttAgentConnect( bool xCleanSession )
633632
configMQTT_AGENT_CONNACK_RECV_TIMEOUT_MS,
634633
&xSessionPresent );
635634

636-
637635
ESP_LOGI( TAG,
638636
"Session present: %d\n",
639637
xSessionPresent );
@@ -686,12 +684,6 @@ static BaseType_t prvBackoffForRetry( BackoffAlgorithmContext_t * pxRetryParams
686684
return xReturnStatus;
687685
}
688686

689-
static void processLoopCompleteCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
690-
MQTTAgentReturnInfo_t * pReturnInfo )
691-
{
692-
xTaskNotifyGive( ( void * ) pCmdCallbackContext );
693-
}
694-
695687
static void prvCoreMqttAgentConnectionTask( void * pvParameters )
696688
{
697689
( void ) pvParameters;
@@ -704,8 +696,6 @@ static void prvCoreMqttAgentConnectionTask( void * pvParameters )
704696

705697
while( 1 )
706698
{
707-
int lSockFd = -1;
708-
709699
/* Wait for the device to be connected to WiFi and be disconnected from
710700
* MQTT broker. */
711701
xEventGroupWaitBits( xNetworkEventGroup,
@@ -736,14 +726,7 @@ static void prvCoreMqttAgentConnectionTask( void * pvParameters )
736726

737727
if( xTlsRet == TLS_TRANSPORT_SUCCESS )
738728
{
739-
if( esp_tls_get_conn_sockfd( pxNetworkContext->pxTls, &lSockFd ) == ESP_OK )
740-
{
741-
eMqttRet = prvCoreMqttAgentConnect( xCleanSession );
742-
}
743-
else
744-
{
745-
eMqttRet = MQTTBadParameter;
746-
}
729+
eMqttRet = prvCoreMqttAgentConnect( xCleanSession );
747730

748731
if( eMqttRet != MQTTSuccess )
749732
{
@@ -758,8 +741,6 @@ static void prvCoreMqttAgentConnectionTask( void * pvParameters )
758741
xTlsDisconnect( pxNetworkContext );
759742
xBackoffRet = prvBackoffForRetry( &xReconnectParams );
760743
}
761-
762-
763744
} while( ( eMqttRet != MQTTSuccess ) && ( xBackoffRet == pdPASS ) );
764745

765746
if( eMqttRet == MQTTSuccess )
@@ -772,57 +753,11 @@ static void prvCoreMqttAgentConnectionTask( void * pvParameters )
772753
CORE_MQTT_AGENT_CONNECTED_BIT );
773754
xCoreMqttAgentManagerPost( CORE_MQTT_AGENT_CONNECTED_EVENT );
774755
}
775-
776-
if( eMqttRet == MQTTSuccess )
777-
{
778-
while( xEventGroupWaitBits( xNetworkEventGroup, CORE_MQTT_AGENT_DISCONNECTED_BIT, pdFALSE, pdFALSE, 0 ) != CORE_MQTT_AGENT_DISCONNECTED_BIT )
779-
{
780-
fd_set readSet;
781-
fd_set errorSet;
782-
783-
FD_ZERO( &readSet );
784-
FD_SET( lSockFd, &readSet );
785-
786-
FD_ZERO( &errorSet );
787-
FD_SET( lSockFd, &errorSet );
788-
789-
struct timeval timeout = { .tv_usec = 10000, .tv_sec = 0 };
790-
791-
if( select( lSockFd + 1, &readSet, NULL, &errorSet, &timeout ) > 0 )
792-
{
793-
if( FD_ISSET( lSockFd, &readSet ) )
794-
{
795-
MQTTAgentCommandInfo_t xCommandInfo =
796-
{
797-
.blockTimeMs = 0,
798-
.cmdCompleteCallback = processLoopCompleteCallback,
799-
.pCmdCompleteCallbackContext = ( void * ) xTaskGetCurrentTaskHandle(),
800-
};
801-
ESP_LOGI( TAG, "Sending ProcessLoop request." );
802-
803-
( void ) MQTTAgent_ProcessLoop( &xGlobalMqttAgentContext, &xCommandInfo );
804-
( void ) ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( 10000 ) );
805-
ESP_LOGI( TAG, "ProcessLoop complete." );
806-
807-
}
808-
else if ( FD_ISSET( lSockFd, &errorSet ) )
809-
{
810-
xEventGroupClearBits( xNetworkEventGroup,
811-
CORE_MQTT_AGENT_CONNECTED_BIT );
812-
xEventGroupSetBits( xNetworkEventGroup,
813-
CORE_MQTT_AGENT_DISCONNECTED_BIT );
814-
xCoreMqttAgentManagerPost( CORE_MQTT_AGENT_DISCONNECTED_EVENT );
815-
}
816-
}
817-
vTaskDelay( 1 );
818-
}
819-
}
820756
}
821757

822758
vTaskDelete( NULL );
823759
}
824760

825-
826761
static void prvWifiEventHandler( void * pvHandlerArg,
827762
esp_event_base_t xEventBase,
828763
int32_t lEventId,

0 commit comments

Comments
 (0)