Skip to content

Commit 9270e29

Browse files
Add Quick Connect V2 Demo (#137)
* Add Quick Connect V2 Demo * simplified Quick Connect demo by removing semaphores and adding temperature sensors * decreased topic buffer to 1D and commenting changes * Fixed the AWSsetup.md link in Quick connect GettingStarted.md * Styling changes and removing esp_driver_tsens dependency to fix the failing demo builds * formating changes to fix CI Checks / formatting in PR * Switch from 'latest' which is 6.x to v5.5.1 ESP-IDF 6.x no longer supports vends the wifi provisioning component, instead titling it as 'network provisioning'. This is backwards incompatible. We should update to IDF 6+ once it is released. It is currently in beta. * Drop support for ESP-IDF 5.0. 5.0 does not support network provisioning. * update: updated code to use network prov from wifi prov * fix: network_prov not found issue * fix: removed wifi prov for latest CI test * fix: added mbedtls for latest CI test * removed latest CI test as it fails due to mbedtls 4.0 support in corePKCS11 and v5.1.2 as it does not support network prov * refactor: updated CI tests to use v5.5.2 --------- Co-authored-by: Kody Stribrny <kstribrn@amazon.com>
1 parent 5694f12 commit 9270e29

11 files changed

Lines changed: 697 additions & 30 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
esp_idf_version:
23-
- v5.0
24-
- v5.1.2
2523
- release-v5.2
26-
- latest
24+
- v5.5.2
2725
esp_target:
2826
- esp32
2927
- esp32s2

GettingStartedGuide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Once completed, one can progress to the
1616
&emsp;[2.1 Setup AWS IoT Core](#21-setup-aws-iot-core)<br>
1717
&emsp;[2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint](#22-configure-the-project-with-the-aws-iot-thing-name-and-aws-device-endpoint)<br>
1818
&emsp;[2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode](#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode)<br>
19+
&emsp;[2.4 Quick Connect demo](#24-quick-connect-demo)<br>
1920

2021
[3 Build and flash the demo project](#3-build-and-flash-the-demo-project)<br>
2122

@@ -154,6 +155,11 @@ python managed_components/espressif__esp_secure_cert_mgr/tools/configure_esp_sec
154155

155156
> **NOTE:** For convenience sake, you could place your key and certificate files under the `main/certs` directory.
156157
158+
### 2.4 Quick Connect demo
159+
160+
The Quick Connect demo differs from other demos as it does not require an AWS account. Refer to the [Getting Started Guide](./main/demo_tasks/quickconnect_v2_demo/GettingStarted.md)
161+
162+
157163
## 3 Build and flash the demo project
158164

159165
Before you build and flash the demo project, if you are setting up the ESP32-C3

main/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ if(CONFIG_GRI_ENABLE_SUB_PUB_UNSUB_DEMO)
1313
list(APPEND MAIN_SRCS "demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo.c")
1414
endif()
1515

16+
# QuickConnect V2 demo
17+
if(CONFIG_GRI_ENABLE_QUICKCONNECT_V2_DEMO)
18+
list(APPEND MAIN_SRCS
19+
"demo_tasks/quickconnect_v2_demo/quickconnect_v2_demo.c"
20+
"demo_tasks/temp_sub_pub_and_led_control_demo/hardware_drivers/app_driver.c"
21+
)
22+
endif()
23+
1624
# Temperature Sub Pub and LED control demo
1725
if(CONFIG_GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO)
1826
list(APPEND MAIN_SRCS
@@ -37,6 +45,7 @@ set(MAIN_INCLUDE_DIRS
3745
"."
3846
"demo_tasks/ota_over_mqtt_demo"
3947
"demo_tasks/sub_pub_unsub_demo"
48+
"demo_tasks/quickconnect_v2_demo"
4049
"demo_tasks/temp_sub_pub_and_led_control_demo"
4150
"demo_tasks/temp_sub_pub_and_led_control_demo/hardware_drivers"
4251
"networking/wifi"
@@ -45,7 +54,6 @@ set(MAIN_INCLUDE_DIRS
4554

4655
set(MAIN_REQUIRES
4756
qrcode
48-
wifi_provisioning
4957
coreMQTT
5058
coreMQTT-Agent
5159
corePKCS11
@@ -58,6 +66,10 @@ set(MAIN_REQUIRES
5866
driver
5967
)
6068

69+
# Exclude wifi_provisioning component to avoid conflicts with network_provisioning
70+
# See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-6.x/6.0/provisioning.html
71+
set(EXCLUDE_COMPONENTS wifi_provisioning)
72+
6173
idf_component_register(
6274
SRCS
6375
${MAIN_SRCS}

main/Kconfig.projbuild

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,43 @@ menu "Featured FreeRTOS IoT Integration"
253253

254254
endmenu # coreMQTT-Agent Manager Configurations
255255

256+
config GRI_ENABLE_QUICKCONNECT_V2_DEMO
257+
bool "Enable QuickConnect V2 demo"
258+
depends on !GRI_RUN_QUALIFICATION_TEST
259+
default n
260+
261+
menu "Quick connect V2 demo configurations"
262+
depends on GRI_ENABLE_QUICKCONNECT_V2_DEMO
263+
264+
config GRI_QUICKCONNECT_V2_DEMO_STRING_BUFFER_LENGTH
265+
int "Topic name and payload buffer length"
266+
default 700
267+
help
268+
Size of statically allocated buffers for holding topic names and payloads.
269+
270+
config GRI_QUICKCONNECT_V2_DEMO_DELAY_BETWEEN_PUB_LOOPS_MS
271+
int "Delay between publish loops in milliseconds"
272+
default 1000
273+
help
274+
Delay for each task between publish loops.
275+
276+
config GRI_QUICKCONNECT_V2_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS
277+
int "coreMQTT-Agent command post block time in milliseconds."
278+
default 500
279+
help
280+
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.
281+
282+
config GRI_QUICKCONNECT_V2_DEMO_TASK_STACK_SIZE
283+
int "Quick connect task stack size."
284+
default 3072
285+
help
286+
The task stack size for each of the Quick Connect tasks.
287+
288+
endmenu # Quick connect V2 demo configurations
289+
256290
config GRI_ENABLE_SUB_PUB_UNSUB_DEMO
257291
bool "Enable pub sub unsub demo"
258-
depends on !GRI_RUN_QUALIFICATION_TEST
292+
depends on !GRI_RUN_QUALIFICATION_TEST && !GRI_ENABLE_QUICKCONNECT_V2_DEMO
259293
default y
260294

261295
menu "Sub pub unsub demo configurations"
@@ -308,7 +342,7 @@ menu "Featured FreeRTOS IoT Integration"
308342

309343
config GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO
310344
bool "Enable temperature sensor pub sub and LED control demo"
311-
depends on !GRI_RUN_QUALIFICATION_TEST
345+
depends on !GRI_RUN_QUALIFICATION_TEST && !GRI_ENABLE_QUICKCONNECT_V2_DEMO
312346
default y
313347

314348
menu "Temperature pub sub and LED control demo configurations"
@@ -378,7 +412,7 @@ menu "Featured FreeRTOS IoT Integration"
378412

379413
config GRI_ENABLE_OTA_DEMO
380414
bool "Enable OTA demo"
381-
depends on !GRI_RUN_QUALIFICATION_TEST
415+
depends on !GRI_RUN_QUALIFICATION_TEST && !GRI_ENABLE_QUICKCONNECT_V2_DEMO
382416
default y
383417

384418
menu "OTA demo configurations"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Getting Started With Quick Connect V2 Guide
2+
3+
**_NOTE:_** This guide covers only Quick Connect V2. For all other demos, please refer to the [Getting Started Guide](../../../GettingStartedGuide.md).
4+
5+
This guide contains instructions on how to setup, build and run only the Quick Connect V2 demo
6+
without use of the security features of the ESP32-C3 i.e. without enabling the
7+
DS peripheral, flash encryption and Secure Boot. The guide is meant to provide the
8+
user with a friendly first-use experience.
9+
10+
[1 Pre-requisites](#1-pre-requisites)<br>
11+
12+
[2 Demo setup](#2-demo-setup)<br>
13+
14+
[3 Build and flash the demo project](#3-build-and-flash-the-demo-project)<br>
15+
16+
[4 Monitoring the demo](#4-monitoring-the-demo)<br>
17+
18+
19+
## 1 Pre-requisites
20+
21+
For hardware and software requirements, refer to sections [1.1 Hardware Requirements](../../../GettingStartedGuide.md#11-hardware-requirements) and [1.2 Software Requirements](../../../GettingStartedGuide.md#12-software-requirements) in the [Getting Started Guide](../../../GettingStartedGuide.md)
22+
23+
## 2 Demo setup
24+
25+
### 2.1 Get credentials from Quick Connect V2
26+
27+
To get credentials for your device (Thing), visit [Quick Connect Credentials](https://quickconnect.freertos.aws.com/credentials) page and enter a desired device name (Thing Name) in the `Vend Credentials` section, and click the Vend button. Download both the `.crt` and `.key` files. These are your **PEM-encoded device certificate** and **PEM-encoded private key**. (An explanation of these entities is given in the [AWS IoT Core Setup Guide](../../../AWSSetup.md).)
28+
29+
### 2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint
30+
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.
32+
33+
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.
34+
35+
Select `Enable QuickConnect V2 demo` in the `Featured FreeRTOS IoT Integration` to activate the demo.
36+
37+
38+
### 2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode
39+
40+
For Quick Connect, use the following specific values:
41+
42+
- `CA_CERT_FILEPATH`: Use the file in the `main/certs` directory, or download the AWS Root CA certificate from [here](https://www.amazontrust.com/repository/AmazonRootCA1.pem).
43+
- `DEVICE_CERT_FILEPATH`: The file path to the PEM-encoded device certificate (`.crt` file downloaded from the Quick Connect Website)
44+
- `PRIVATE_KEY_FILEPATH`: The file path to the PEM-encoded private key (`.key` file downloaded from the Quick Connect Website)
45+
- `KEY_ALG_INFO`: Use `RSA 2048`
46+
47+
For complete provisioning instructions, follow the [2.3 Provision the ESP32-C3](../../../GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode) section in the [Getting Started Guide](../../../GettingStartedGuide.md).
48+
49+
50+
## 3 Build and flash the demo project
51+
52+
For build and flash instructions, follow [3 Build and flash](../../../GettingStartedGuide.md#3-build-and-flash-the-demo-project) section of the [Getting Started Guide](../../../GettingStartedGuide.md).
53+
54+
**NOTE:** If you encounter a ***stack overflow in task CoreMqttAgentCo has been detected*** <br>
55+
run `idf.py menuconfig`. navigate to Featured FreeRTOS IoT Integration → coreMQTT-Agent Manager Configurations, and increse the `coreMQTT-Agent task stack size` and `Connection handling task stack size` from their default values.
56+
57+
## 4 Monitoring the demo
58+
59+
1. On the serial terminal console, confirm that the TLS connection was
60+
successful and that MQTT messages are published.
61+
62+
```c
63+
I (4115) core_mqtt_agent_manager: WiFi connected.
64+
I (4115) app_wifi: Connected with IP Address:10.0.0.9
65+
I (4115) esp_netif_handlers: sta ip: 10.0.0.9, mask: 255.255.255.0, gw: 10.0.0.1
66+
I (4115) main_task: Returned from app_main()
67+
I (4685) core_mqtt_agent_manager: TLS connection established.
68+
I (5025) coreMQTT: MQTT connection established with the broker.
69+
I (5025) core_mqtt_agent_manager: Session present: 0
70+
71+
I (5025) quickconnect_v2_demo: coreMQTT-Agent connected.
72+
I (5025) core_mqtt_agent_manager: coreMQTT-Agent connected.
73+
I (5025) quickconnect_v2_demo: Task "DemoTask" sending publish request to coreMQTT-Agent with message [{"label":"ESP32-S3 MCU Temperature","display_type":"line_graph","unit":"C","values":[{"value":0.0,"label":"temp"}]}] on topic "Thing-name" with ID 1.
74+
I (5055) quickconnect_v2_demo: Task "DemoTask" waiting for publish 1 to complete.
75+
I (5175) coreMQTT: Ack packet deserialized with result: MQTTSuccess.
76+
I (5175) coreMQTT: State record updated. New state=MQTTPublishDone.
77+
78+
```
79+
80+
2. On the [Quick Connect Visualizer](https://quickconnect.freertos.aws.com/visualizer) page, enter your device name (Thing name) in the `Visualizing device data` section, then confirm that the MQTT messages from the device are being received and a graph is being displayed.
81+
82+
**Note**: This demo sends data in line graph format only. For other data visualization formats, refer to the [Quick Connect](https://quickconnect.freertos.aws.com/examples) documentation.

0 commit comments

Comments
 (0)