Skip to content

Commit b8bb2df

Browse files
committed
Styling changes and removing esp_driver_tsens dependency to fix the failing demo builds
1 parent c98dbc1 commit b8bb2df

File tree

6 files changed

+29
-38
lines changed

6 files changed

+29
-38
lines changed

main/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ endif()
1515

1616
# QuickConnect V2 demo
1717
if(CONFIG_GRI_ENABLE_QUICKCONNECT_V2_DEMO)
18-
list(APPEND MAIN_SRCS
18+
list(APPEND MAIN_SRCS
1919
"demo_tasks/quickconnect_v2_demo/quickconnect_v2_demo.c"
20+
"demo_tasks/temp_sub_pub_and_led_control_demo/hardware_drivers/app_driver.c"
2021
)
2122
endif()
2223

@@ -64,7 +65,6 @@ set(MAIN_REQUIRES
6465
FreeRTOS-Libraries-Integration-Tests
6566
unity
6667
driver
67-
esp_driver_tsens
6868
)
6969

7070
idf_component_register(

main/demo_tasks/quickconnect_v2_demo/GettingStarted.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ To get credentials for your device (Thing), visit [Quick Connect Credentials](ht
2828

2929
### 2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint
3030

31-
The **AWS device Endpoint** is provided on the [Quick Connect Examples](https://quickconnect.freertos.aws.com/examples) page.
31+
The **AWS device Endpoint** is provided on the [Quick Connect Examples](https://quickconnect.freertos.aws.com/examples) page in the sample program code under the ENDPOINT variable.
3232

3333
Follow the [2.2 Configure the project](../../../GettingStartedGuide.md#22-configure-the-project-with-the-aws-iot-thing-name-and-aws-device-endpoint) section in the [Getting Started Guide](../../../GettingStartedGuide.md) to configure your project.
3434

35+
Select `Enable QuickConnect V2 demo` in the `Featured FreeRTOS IoT Integration` to activate the demo.
36+
3537

3638
### 2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode
3739

main/demo_tasks/quickconnect_v2_demo/quickconnect_v2_demo.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,17 @@
7575

7676
/* Hardware drivers include. */
7777
#include "app_driver.h"
78-
#include "driver/temperature_sensor.h"
7978

8079
/* coreMQTT-Agent manager configurations include. */
8180
#include "core_mqtt_agent_manager_config.h"
8281

8382
/* Preprocessor definitions ***************************************************/
8483

8584
/* coreMQTT-Agent event group bit definitions */
86-
#define CORE_MQTT_AGENT_CONNECTED_BIT ( 1 << 0 )
85+
#define CORE_MQTT_AGENT_CONNECTED_BIT ( 1 << 0 )
8786

8887
/* MQTT event group bit definitions. */
89-
#define MQTT_PUBLISH_COMMAND_COMPLETED_BIT ( 1 << 1 )
88+
#define MQTT_PUBLISH_COMMAND_COMPLETED_BIT ( 1 << 1 )
9089

9190
/* Struct definitions *********************************************************/
9291

@@ -115,10 +114,10 @@ extern MQTTAgentContext_t xGlobalMqttAgentContext;
115114

116115
/**
117116
* @brief The buffer to hold the topic filter.
118-
Topic filter value will be the Thing-Name.
117+
* Topic filter value will be the Thing-Name.
119118
*
120119
*/
121-
static char topicBuf[ quickconnectv2configSTRING_BUFFER_LENGTH ];
120+
static char topicBuf[ quickconnectconfigSTRING_BUFFER_LENGTH ];
122121

123122
/**
124123
* @brief The event group used to manage coreMQTT-Agent events.
@@ -130,11 +129,6 @@ static EventGroupHandle_t xNetworkEventGroup;
130129
*/
131130
static uint32_t ulMessageId = 0;
132131

133-
/**
134-
* @brief Temperature sensor handle.
135-
*/
136-
static temperature_sensor_handle_t temp_sensor = NULL;
137-
138132
/* Static function declarations ***********************************************/
139133

140134
/**
@@ -177,7 +171,7 @@ static void prvPublishCommandCallback( MQTTAgentCommandContext_t * pxCommandCont
177171
*/
178172
static EventBits_t prvWaitForEvent( EventGroupHandle_t xMqttEventGroup,
179173
EventBits_t uxBitsToWaitFor );
180-
174+
181175
/**
182176
* @brief The function that implements the task demonstrated by this file.
183177
*/
@@ -278,7 +272,7 @@ static void prvPublishToTopic( MQTTQoS_t xQoS,
278272
* until the callback executes. */
279273
xCommandContext.xMqttEventGroup = xMqttEventGroup;
280274

281-
xCommandParams.blockTimeMs = quickconnectv2configMAX_COMMAND_SEND_BLOCK_TIME_MS;
275+
xCommandParams.blockTimeMs = quickconnectconfigMAX_COMMAND_SEND_BLOCK_TIME_MS;
282276
xCommandParams.cmdCompleteCallback = prvPublishCommandCallback;
283277
xCommandParams.pCmdCompleteCallbackContext = &xCommandContext;
284278

@@ -346,7 +340,7 @@ static void prvQuickConnectV2Task( void * pvParameters )
346340
EventGroupHandle_t xMqttEventGroup;
347341

348342
MQTTQoS_t xQoS;
349-
char pcPayload[ quickconnectv2configSTRING_BUFFER_LENGTH ];
343+
char pcPayload[ quickconnectconfigSTRING_BUFFER_LENGTH ];
350344
float temperatureValue;
351345

352346
xMqttEventGroup = xEventGroupCreate();
@@ -356,26 +350,21 @@ static void prvQuickConnectV2Task( void * pvParameters )
356350

357351
/* Take the topic name from thing name. */
358352
snprintf( topicBuf,
359-
quickconnectv2configSTRING_BUFFER_LENGTH,
353+
quickconnectconfigSTRING_BUFFER_LENGTH,
360354
"%s",
361355
configCLIENT_IDENTIFIER );
362356

363-
/* Initialize temperature sensor */
364-
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
365-
ESP_ERROR_CHECK(temperature_sensor_install(&temp_sensor_config, &temp_sensor));
366-
ESP_ERROR_CHECK(temperature_sensor_enable(temp_sensor));
357+
/* Initialize hardware drivers */
358+
app_driver_init();
367359

368360
while( 1 )
369361
{
370-
esp_err_t ret = temperature_sensor_get_celsius(temp_sensor, &temperatureValue);
371-
if (ret != ESP_OK) {
372-
ESP_LOGE(TAG, "Failed to read temperature: %s", esp_err_to_name(ret));
373-
temperatureValue = 25.0; /* Default fallback value */
374-
}
362+
/* Read temperature from sensor */
363+
temperatureValue = app_driver_temp_sensor_read_celsius();
375364

376365
/* Create Payload in an Array format */
377366
snprintf( pcPayload,
378-
quickconnectv2configSTRING_BUFFER_LENGTH,
367+
quickconnectconfigSTRING_BUFFER_LENGTH,
379368
"[{\"label\":\"ESP32 MCU Temperature\",\"display_type\":\"line_graph\",\"unit\":\"C\",\"values\":[{\"value\":%.1f,\"label\":\"temp\"}]}]",
380369
temperatureValue );
381370

@@ -393,7 +382,7 @@ static void prvQuickConnectV2Task( void * pvParameters )
393382
"Task \"%s\" completed a loop. Delaying before next loop.",
394383
pcTaskGetName( NULL ) );
395384

396-
vTaskDelay( pdMS_TO_TICKS( quickconnectv2configDELAY_BETWEEN_LOOPS_MS ) );
385+
vTaskDelay( pdMS_TO_TICKS( quickconnectconfigDELAY_BETWEEN_LOOPS_MS ) );
397386
}
398387

399388
vEventGroupDelete( xMqttEventGroup );
@@ -403,7 +392,7 @@ static void prvQuickConnectV2Task( void * pvParameters )
403392
/* Public function definitions ************************************************/
404393

405394
void vStartQuickConnectV2Demo( void )
406-
{ /* This is a single task demo*/
395+
{ /* This is a single task demo*/
407396
char pcTaskNameBuf[ 15 ];
408397
uint32_t ulTaskNumber;
409398

@@ -419,11 +408,11 @@ void vStartQuickConnectV2Demo( void )
419408

420409
snprintf( pcTaskNameBuf,
421410
10,
422-
"DemoTask");
411+
"DemoTask" );
423412

424413
xTaskCreate( prvQuickConnectV2Task,
425414
pcTaskNameBuf,
426-
quickconnectv2configTASK_STACK_SIZE,
415+
quickconnectconfigTASK_STACK_SIZE,
427416
NULL,
428417
1, /* Task Priority */
429418
NULL );

main/demo_tasks/quickconnect_v2_demo/quickconnect_v2_demo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
*/
3636
void vStartQuickConnectV2Demo( void );
3737

38-
#endif /* QUICKCONNECT_V2_DEMO_H */
38+
#endif /* QUICKCONNECT_V2_DEMO_H */

main/demo_tasks/quickconnect_v2_demo/quickconnect_v2_demo_config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,24 @@
4040
* @brief Size of statically allocated buffers for holding topic names and
4141
* payloads.
4242
*/
43-
#define quickconnectv2configSTRING_BUFFER_LENGTH ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_STRING_BUFFER_LENGTH ) )
43+
#define quickconnectconfigSTRING_BUFFER_LENGTH ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_STRING_BUFFER_LENGTH ) )
4444

4545
/**
4646
* @brief Delay for each task between each publish.
4747
*/
48-
#define quickconnectv2configDELAY_BETWEEN_LOOPS_MS ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_DELAY_BETWEEN_PUB_LOOPS_MS ) )
48+
#define quickconnectconfigDELAY_BETWEEN_LOOPS_MS ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_DELAY_BETWEEN_PUB_LOOPS_MS ) )
4949

5050
/**
5151
* @brief The maximum amount of time in milliseconds to wait for the commands
5252
* to be posted to the MQTT agent should the MQTT agent's command queue be full.
5353
* Tasks wait in the Blocked state, so don't use any CPU time.
5454
*/
55-
#define quickconnectv2configMAX_COMMAND_SEND_BLOCK_TIME_MS ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS ) )
55+
#define quickconnectconfigMAX_COMMAND_SEND_BLOCK_TIME_MS ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS ) )
5656

5757
/**
5858
* @brief The task stack size for each of the Quick Connect Demo tasks.
5959
*/
60-
#define quickconnectv2configTASK_STACK_SIZE ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_TASK_STACK_SIZE ) )
60+
#define quickconnectconfigTASK_STACK_SIZE ( ( unsigned int ) ( CONFIG_GRI_QUICKCONNECT_V2_DEMO_TASK_STACK_SIZE ) )
6161

6262
/* *INDENT-OFF* */
6363
#ifdef __cplusplus

main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ static void prvStartEnabledDemos( void )
257257
BaseType_t xResult;
258258

259259
#if ( CONFIG_GRI_RUN_QUALIFICATION_TEST == 0 )
260-
#if CONFIG_GRI_ENABLE_QUICKCONNECT_V2_DEMO
260+
#if CONFIG_GRI_ENABLE_QUICKCONNECT_V2_DEMO
261261
vStartQuickConnectV2Demo();
262262
#endif /* CONFIG_GRI_ENABLE_QUICKCONNECT_V2_DEMO */
263-
263+
264264
#if CONFIG_GRI_ENABLE_SUB_PUB_UNSUB_DEMO
265265
vStartSubscribePublishUnsubscribeDemo();
266266
#endif /* CONFIG_GRI_ENABLE_SIMPLE_PUB_SUB_DEMO */

0 commit comments

Comments
 (0)