AWS IoT Device Defender 演示 - FreeRTOS
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS IoT Device Defender 演示

FreeRTOS 包含一个单线程演示应用程序,该应用程序收集设备的一些 AWS IoT Device Defender 指标并将其发布到 MQTT 主题。此演示在 freertos/demos/defender/aws_iot_defender_demo.c 中定义。

您必须先完成入门初始步骤以设置 AWS IoT 和 FreeRTOS,使设备能够与 AWS 云进行通信,之后才能运行 Device Defender 演示。

打开 freertos/vendors/vendor/boards/board/aws_demos/config_files/aws_demo_config.h,注释掉 #define CONFIG_MQTT_DEMO_ENABLED 并定义 CONFIG_DEFENDER_DEMO_ENABLED

当您在启用了 Device Defender 的设备上生成、刷入并运行 FreeRTOS 时,应显示下列输出:

12 343 [iot_thread] [INFO ][DEMO][343] ----Device Defender Demo Start---- 13 343 [iot_thread] [INFO ][MQTT][343] MQTT library successfully initialized. 14 343 [iot_thread] [INFO ][Defender][343] Metrics are successfully updated. 15 343 [iot_thread] [INFO ][Defender][343] Period has been set to 300 seconds successfully. 16 343 [iot_thread] [INFO ][DEMO][343] Defender Thing Name is Thing-1 (length 7). 17 711 [iot_thread] [INFO ][MQTT][711] Establishing new MQTT connection. 18 711 [iot_thread] [INFO ][MQTT][711] Anonymous metrics (SDK language, SDK version) will be provided to AWS IoT. Recompile with AWS_IOT_MQTT_ENABLE_METRICS set to 0 to disable. 19 711 [iot_thread] [INFO ][MQTT][711] (MQTT connection 00530B30, CONNECT operation 00530CC0) Waiting for operation completion. 20 771 [iot_thread] [INFO ][MQTT][771] (MQTT connection 00530B30, CONNECT operation 00530CC0) Wait complete with result SUCCESS. 21 771 [iot_thread] [INFO ][MQTT][771] New MQTT connection 0203FA0C established. 22 771 [iot_thread] [INFO ][MQTT][771] (MQTT connection 00530B30) SUBSCRIBE operation scheduled. 23 771 [iot_thread] [INFO ][MQTT][771] (MQTT connection 00530B30, SUBSCRIBE operation 00530E30) Waiting for operation completion. 24 811 [iot_thread] [INFO ][MQTT][811] (MQTT connection 00530B30, SUBSCRIBE operation 00530E30) Wait complete with result SUCCESS. 25 811 [iot_thread] [INFO ][Defender][811] Defender agent has successfully started. 26 812 [iot_thread] [INFO ][MQTT][812] (MQTT connection 00530B30) MQTT PUBLISH operation queued. 27 932 [iot_thread] [INFO ][Defender][932] Metrics report was accepted by defender service. 28 932 [iot_thread] [INFO ][DEMO][932] User's callback is invoked on event: Defender Metrics accepted. 29 932 [iot_thread] [INFO ][DEMO][932] Published metrics report. 30 932 [iot_thread] [INFO ][DEMO][932] Received MQTT message. 31 8811 [iot_thread] [INFO ][Defender][8811] Unsubscribing from MQTT topics 32 8811 [iot_thread] [INFO ][MQTT][8811] (MQTT connection 00530B30) UNSUBSCRIBE operation scheduled. 33 8811 [iot_thread] [INFO ][MQTT][8811] (MQTT connection 00530B30, UNSUBSCRIBE operation 00530F40) Waiting for operation completion. 34 8891 [iot_thread] [INFO ][MQTT][8891] (MQTT connection 00530B30, UNSUBSCRIBE operation 00530F40) Wait complete with result SUCCESS. 35 8891 [iot_thread] [INFO ][Defender][8891] Defender agent has stopped. 35 8891 [iot_thread] [INFO ][MQTT][8891] (MQTT connection 00530B30) Disconnecting connection. 37 8892 [iot_thread] [INFO ][MQTT][8892] (MQTT connection 00530B30, DISCONNECT operation 00530CE0) Waiting for operation completion. 38 8892 [iot_thread] [INFO ][MQTT][8892] (MQTT connection 00530B30, DISCONNECT operation 00530CE0) Wait complete with result SUCCESS. 39 8892 [iot_thread] [INFO ][MQTT][8892] (MQTT connection 00530B30) Connection disconnected. 40 8893 [iot_thread] [INFO ][MQTT][8893] (MQTT connection 00530B30) Network connection closed. 41 8931 [iot_thread] [INFO ][MQTT][8931] (MQTT connection 00530B30) Network connection destroyed. 42 8931 [iot_thread] [INFO ][MQTT][8931] MQTT library cleanup done. 43 8931 [iot_thread] [INFO ][DEMO][8931] ----Device Defender Demo End. Status: SUCCESS----.