MCUXpresso_MIMXRT1021xxxxx/boards/evkmimxrt1020/aws_examples/shadow_enet
Yilin Sun 763d32be90
Updated SDK to v2.15.000
Signed-off-by: Yilin Sun <imi415@imi.moe>
2024-03-15 22:23:36 +08:00
..
armgcc Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
config_files Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
linkscripts Update to SDK_2_12_1. 2022-12-02 19:44:05 +08:00
aws_clientcredential.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
aws_clientcredential_keys.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
aws_dev_mode_key_provisioning.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
aws_dev_mode_key_provisioning.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
aws_shadow_enet_v3_14.xml Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
board.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
board.h Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
clock_config.c Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
clock_config.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
dcd.c Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
dcd.h Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
evkmimxrt1020_sdram_init.jlinkscript Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
freertos_tasks_c_additions.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
iot_pkcs11_pal.c Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
lwipopts.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
main_enet.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
pin_mux.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
pin_mux.h Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
readme.md Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00

readme.md

Overview

Demo for showing how to use the Device Shadow library's API.

SDK version

  • Version: 2.15.000

Toolchain supported

  • IAR embedded Workbench 9.40.1
  • Keil MDK 5.38.1
  • GCC ARM Embedded 12.2
  • MCUXpresso 11.8.0

Hardware requirements

  • Mini/micro USB cable
  • EVK-MIMXRT1020 board
  • Personal Computer
  • Network cable RJ45 standard (Network with Internet access)

Board settings

No special settings are required.

Note: To debug in qspiflash, following steps are needed:

  1. Select the flash target and compile.

  2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.

  3. Start debugging in IDE.

    • Keil: Click "Download (F8)" to program the image to qspiflash first then clicking "Start/Stop Debug Session (Ctrl+F5)" to start debugging. Prepare the Demo ================ Before running the demo it is need to configure AWS IoT Console and update some of project files:
  4. Create AWS Account: https://console.aws.amazon.com/console/home

  5. Configure device in the AWS IoT Console base on this guide: https://docs.aws.amazon.com/iot/latest/developerguide/create-iot-resources.html

    Make note of example's "Thing name" and "REST API endpoint". These strings need to be set in the "aws_clientcredential.h". Example: #define clientcredentialMQTT_BROKER_ENDPOINT "abcdefgh123456.iot.us-west-2.amazonaws.com" #define clientcredentialIOT_THING_NAME "MyExample"

    Device certificate and private key needs to be opened in text editor and its content copied into the "aws_clientcredential_keys.h". Note: be sure to add " at the beginning of a line and \n"\ on every line break. Example: #define keyCLIENT_CERTIFICATE_PEM NULL

    Needs to be changed to:
    
    #define keyCLIENT_CERTIFICATE_PEM "-----BEGIN CERTIFICATE-----\n"\
    "MIIDWTCCAkGgAwIBAgIUfmv3zA+JULlMOxmz+upkAzhEkQ0wDQYJKoZIhvcNAQEL\n"\
    .
    .
    .
    "mepuT3lKmD0jZupsQ9vLQOA09rMjVMd0YPmI9ozvvWqLpjVvNTKVhsf/3slM\n"\
    "-----END CERTIFICATE-----\n"
    

    In the same way update "keyCLIENT_PRIVATE_KEY_PEM" with content of private key file.

    Files "aws_clientcredential.h" and "aws_clientcredential_keys.h" are located in project folder.

  6. This demo doesn't need Wi-Fi network, you can leave the following macros from "aws_clientcredential.h" unmodified. #define clientcredentialWIFI_SSID "Paste Wi-Fi SSID here." #define clientcredentialWIFI_PASSWORD "Paste Wi-Fi password here."

  7. Make sure you have Internet access.

  8. Open example's project and build it.

  9. Connect a USB cable between the PC host and the OpenSDA port on the target board.

  10. Download the program to the target board with the CMSIS-DAP or J-Link debugger.

  11. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

  12. Open a serial terminal on PC for serial device with these settings:

    • 115200 baud rate
    • 8 data bits
    • No parity
    • One stop bit
    • No flow control

Running the demo

The log below shows the output of the demo in the terminal window. The log can be different based on your local network configuration.

.
.
.
6 13045 [MQTT] [INFO] Creating a TLS connection to a2zcot8a2tqh6c-ats.iot.us-east-2.amazonaws.com:8883.
7 14120 [MQTT] [INFO] (Network connection 2022b20c) TLS handshake successful.
8 14120 [MQTT] [INFO] (Network connection 2022b20c) Connection to a2zcot8a2tqh6c-ats.iot.us-east-2.amazonaws.com established.
9 14120 [MQTT] [INFO] Creating an MQTT connection to the broker.
10 14316 [MQTT] [INFO] MQTT connection established with the broker.
11 14316 [MQTT] [INFO] Successfully connected to MQTT broker.
12 14316 [SHADOW_APP] [INFO] MQTT Agent is connected. Initializing shadow update task.
13 14316 [SHADOW_APP] [INFO] Sending subscribe request to agent for shadow topics.
14 14317 [SHADOW_DEV] [INFO] MQTT Agent is connected. Initializing shadow device task.
15 14318 [SHADOW_DEV] [INFO] Sending subscribe request to agent for shadow topics.
16 14518 [SHADOW_APP] [INFO] Received subscribe ack for shadow update topics.
17 14668 [SHADOW_DEV] [INFO] Successfully subscribed to shadow update topics.
18 14668 [SHADOW_DEV] [INFO] Publishing to /get message using client token 14668.
19 14668 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/get.

20 14669 [SHADOW_DEV] [INFO] Successfully sent a publish message to /get topic.
21 14819 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
22 14819 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
23 14869 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
24 14869 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
25 14870 [MQTT] [INFO] Ignoring GET accepted response without a delta field.
26 14871 [SHADOW_DEV] [INFO] Received an accepted response for shadow GET request. 
27 54518 [SHADOW_APP] [INFO] Publishing to /update with following client token 54518.
28 54518 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

29 54769 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
30 54769 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
31 54819 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
32 54819 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
33 54819 [MQTT] [INFO] Received accepted response for update with token 54518. 
34 94820 [SHADOW_APP] [INFO] Publishing to /update with following client token 94820.
35 94820 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

36 95071 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
37 95071 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
38 95121 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
39 95121 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
40 95121 [MQTT] [INFO] Received accepted response for update with token 94820. 
41 95172 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
42 95173 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
43 95173 [MQTT] [INFO] Received delta update with version 86.
44 95173 [MQTT] [INFO] Setting device state to 1.
45 95174 [SHADOW_DEV] [INFO] Publishing to /update with following client token 95173.
46 95174 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

47 95174 [SHADOW_DEV] [INFO] Successfully sent a publish message to /update topic.
48 95524 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
49 95524 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
50 95524 [MQTT] [INFO] Received accepted response for update with token 95173. 
51 95525 [SHADOW_DEV] [INFO] Successfully received a shadow update accepted message from cloud. 
52 135123 [SHADOW_APP] [INFO] Publishing to /update with following client token 135123.
53 135123 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

54 135424 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
55 135424 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
56 135475 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
57 135475 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
58 135475 [MQTT] [INFO] Received accepted response for update with token 135123. 
59 135477 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
60 135477 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
61 135477 [MQTT] [INFO] Received delta update with version 88.
62 135477 [MQTT] [INFO] Setting device state to 0.
63 135518 [SHADOW_DEV] [INFO] Publishing to /update with following client token 135518.
64 135518 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

65 135519 [SHADOW_DEV] [INFO] Successfully sent a publish message to /update topic.
66 135819 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
67 135819 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
68 135820 [MQTT] [INFO] Received accepted response for update with token 135518. 
69 135820 [SHADOW_DEV] [INFO] Successfully received a shadow update accepted message from cloud. 
70 175477 [SHADOW_APP] [INFO] Publishing to /update with following client token 175477.
71 175477 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

72 175728 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
73 175728 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
74 175828 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
75 175828 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
76 175828 [MQTT] [INFO] Received accepted response for update with token 175477. 
77 175830 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
78 175830 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
79 175830 [MQTT] [INFO] Received delta update with version 90.
80 175830 [MQTT] [INFO] Setting device state to 1.
81 175871 [SHADOW_DEV] [INFO] Publishing to /update with following client token 175871.
82 175871 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

83 175872 [SHADOW_DEV] [INFO] Successfully sent a publish message to /update topic.
84 176222 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
85 176223 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
86 176223 [MQTT] [INFO] Received accepted response for update with token 175871. 
87 176224 [SHADOW_DEV] [INFO] Successfully received a shadow update accepted message from cloud. 
88 215830 [SHADOW_APP] [INFO] Publishing to /update with following client token 215830.
89 215830 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.

90 216081 [MQTT] [INFO] Ack packet deserialized with result: MQTTSuccess.
91 216081 [MQTT] [INFO] State record updated. New state=MQTTPublishDone.
92 216131 [MQTT] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess.
93 216131 [MQTT] [INFO] State record updated. New state=MQTTPubAckSend.
94 216131 [MQTT] [INFO] Received delta update with version 92.
95 216131 [MQTT] [INFO] Setting device state to 0.
96 216132 [SHADOW_DEV] [INFO] Publishing to /update with following client token 216132.
97 216133 [MQTT] [INFO] Publishing message to $aws/things/aws_rpr_michal/shadow/update.
.
.
.