From f351ad4eb1d68bb6e220acc850ceefd48876f2b2 Mon Sep 17 00:00:00 2001 From: panweiji <406798106@qq.com> Date: Tue, 26 Dec 2023 14:38:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A2=9E=E5=BC=BA=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=E5=BC=8F=E4=BB=A3=E7=A0=81=E7=9A=84=E5=81=A5=E5=A3=AE=E6=80=A7?= =?UTF-8?q?=E5=92=8C=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../athena-common/mqtt/at_mqtt/at_mqtt.cpp | 2 ++ packages/athena-common/mqtt/mqtt.cpp | 1 + .../esp32-c3-demo/lib/LibDemo/README.md | 1 + .../esp32-c3-demo/lib/LibDemo/docs/README.md | 1 + .../lib/LibDemo/examples/README.md | 1 + .../esp32-c3-demo/lib/LibDemo/library.json | 10 +++++++++ .../esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp | 21 +++++++++++++++++++ .../esp32-c3-demo/lib/LibDemo/src/LibDemo.h | 8 +++++++ projects-demo/esp32-c3-demo/src/main.cpp | 5 +++++ 9 files changed, 50 insertions(+) create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/README.md create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/docs/README.md create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/examples/README.md create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/library.json create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp create mode 100644 projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.h diff --git a/packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp b/packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp index 334eb51..27b1cd2 100644 --- a/packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp +++ b/packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp @@ -437,6 +437,8 @@ void do_at_mqtt_subscribe(DynamicJsonDocument json, String topic) { if (command == "heartbeat") { // 心跳指令 do_at_mqtt_heart_beat(); } + + // 应该抽离出业务指令 单独维护代码 保证代码的通用性和易维护性 if (command == "raise") { // 电机升起指令 set_motor_up(); } diff --git a/packages/athena-common/mqtt/mqtt.cpp b/packages/athena-common/mqtt/mqtt.cpp index 6d31829..34a4428 100644 --- a/packages/athena-common/mqtt/mqtt.cpp +++ b/packages/athena-common/mqtt/mqtt.cpp @@ -257,6 +257,7 @@ void do_mqtt_subscribe(DynamicJsonDocument json, char *topic) { if (command == "heartbeat") { // 心跳指令 do_mqtt_heart_beat(); } + // 应该抽离出业务指令 单独维护代码 保证代码的通用性和易维护性 if (command == "raise") { set_motor_up(); } diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/README.md b/projects-demo/esp32-c3-demo/lib/LibDemo/README.md new file mode 100644 index 0000000..c505007 --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/README.md @@ -0,0 +1 @@ +### PlatformIO自定义库 用于项目应用示例 diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/docs/README.md b/projects-demo/esp32-c3-demo/lib/LibDemo/docs/README.md new file mode 100644 index 0000000..5732378 --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/docs/README.md @@ -0,0 +1 @@ +### PlatformIO库文档 diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/examples/README.md b/projects-demo/esp32-c3-demo/lib/LibDemo/examples/README.md new file mode 100644 index 0000000..5787aea --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/examples/README.md @@ -0,0 +1 @@ +### PlatformIO库文示例 \ No newline at end of file diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/library.json b/projects-demo/esp32-c3-demo/lib/LibDemo/library.json new file mode 100644 index 0000000..b0c66a1 --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/library.json @@ -0,0 +1,10 @@ +{ + "name": "lib_demo", + "version": "1.0.0", + "description": "PlatformIO自定义库 用于项目应用示例", + "authors": { + "name": "潘维吉", + "email": "406798106@qq.com", + "url": "https://github.com/DreamPWJ" + } +} \ No newline at end of file diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp b/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp new file mode 100644 index 0000000..efce754 --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp @@ -0,0 +1,21 @@ +#include "LibDemo.h" +#include + +using namespace std; + + +/** +* @author 潘维吉 +* @date 2023/12/25 15:51 +* @description PlatformIO自定义库 用于项目应用示例 +*/ + + +/** + * 初始化示例 + */ +void init_demo() { + + Serial.println("PlatformIO自定义库 用于项目应用示例测试"); + +} \ No newline at end of file diff --git a/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.h b/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.h new file mode 100644 index 0000000..a2d424e --- /dev/null +++ b/projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.h @@ -0,0 +1,8 @@ +#ifndef ESP32_C3_DEMO_LIBDEMO_H +#define ESP32_C3_DEMO_LIBDEMO_H + +#include + +void init_demo(); + +#endif diff --git a/projects-demo/esp32-c3-demo/src/main.cpp b/projects-demo/esp32-c3-demo/src/main.cpp index 43a38c4..125cf54 100644 --- a/projects-demo/esp32-c3-demo/src/main.cpp +++ b/projects-demo/esp32-c3-demo/src/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include // #include @@ -28,6 +29,10 @@ void setup() { Serial.begin(115200); Serial.println("ESP32 C3 MCU"); + + // PlatformIO自定义库 用于项目应用示例 + init_demo(); + String project_name = STR(PROJECT_NAME); Serial.println(project_name); String projectName = "esp32-c3-demo";