Skip to content

Commit

Permalink
chore: 增强嵌入式代码的健壮性和可维护性
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamPWJ committed Dec 26, 2023
1 parent d64cdae commit f351ad4
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions packages/athena-common/mqtt/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### PlatformIO自定义库 用于项目应用示例
1 change: 1 addition & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### PlatformIO库文档
1 change: 1 addition & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### PlatformIO库文示例
10 changes: 10 additions & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "lib_demo",
"version": "1.0.0",
"description": "PlatformIO自定义库 用于项目应用示例",
"authors": {
"name": "潘维吉",
"email": "[email protected]",
"url": "https://github.com/DreamPWJ"
}
}
21 changes: 21 additions & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "LibDemo.h"
#include <Arduino.h>

using namespace std;


/**
* @author 潘维吉
* @date 2023/12/25 15:51
* @description PlatformIO自定义库 用于项目应用示例
*/


/**
* 初始化示例
*/
void init_demo() {

Serial.println("PlatformIO自定义库 用于项目应用示例测试");

}
8 changes: 8 additions & 0 deletions projects-demo/esp32-c3-demo/lib/LibDemo/src/LibDemo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef ESP32_C3_DEMO_LIBDEMO_H
#define ESP32_C3_DEMO_LIBDEMO_H

#include <Arduino.h>

void init_demo();

#endif
5 changes: 5 additions & 0 deletions projects-demo/esp32-c3-demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <wifi_network.h>
#include <mqtt.h>
#include <bluetooth_connect.h>
#include <LibDemo.h>
#include <ota.h>
// #include <log_insight.h>

Expand All @@ -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";
Expand Down

0 comments on commit f351ad4

Please sign in to comment.