Compare commits
2 Commits
e8df6e6e9c
...
2894acb43b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2894acb43b | ||
|
|
d8e03be71f |
42
.trae/rules/project_rules.md
Normal file
42
.trae/rules/project_rules.md
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
description: esp32嵌入式开发生效
|
||||
---
|
||||
# ESP32-C3 ESP-IDF 开发规则
|
||||
|
||||
仅在 ESP32 / ESP-IDF 相关开发中参考,保留关键结论如下:
|
||||
|
||||
## 1. HTTP Server
|
||||
|
||||
- `sdkconfig.defaults` 至少包含:
|
||||
- `CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024`
|
||||
- `CONFIG_HTTPD_MAX_URI_LEN=512`
|
||||
- 修改 `sdkconfig.defaults` 后,如已有 `sdkconfig`,需同步处理并重新编译。
|
||||
- `httpd` 任务栈建议设为 `8192`。
|
||||
- `httpd_req_recv()` 读取 POST 数据必须循环收完,按 `content_len` 分配缓冲区,并在结束后释放内存。
|
||||
|
||||
## 2. 表单处理
|
||||
|
||||
- 所有 `application/x-www-form-urlencoded` 表单参数必须先做 URL 解码再使用。
|
||||
- 应封装统一的 `url_decode()` / `get_param()` 工具函数。
|
||||
- 禁止直接用 `strstr` + `strchr` 手动截取参数值。
|
||||
|
||||
## 3. WiFi 连接
|
||||
|
||||
- 不要硬编码 `WIFI_AUTH_WPA2_PSK`,优先使用兼容性更好的认证模式。
|
||||
- 空密码时使用 `WIFI_AUTH_OPEN`。
|
||||
- 启动时仅在 SSID 和密码都有效时尝试连接,否则进入配网模式。
|
||||
- 日志中输出断开原因和密码长度,不输出密码明文。
|
||||
|
||||
## 4. 初始化顺序
|
||||
|
||||
- 必须按以下顺序初始化:
|
||||
1. `nvs_flash_init()`
|
||||
2. `esp_netif_init()`
|
||||
3. `esp_event_loop_create_default()`
|
||||
4. `esp_wifi_init()`
|
||||
- 禁止在 `esp_wifi_init()` 之后再初始化 NVS。
|
||||
|
||||
## 5. 配网模式
|
||||
|
||||
- 配网阶段使用 `WIFI_MODE_AP`,不要使用 `WIFI_MODE_APSTA`。
|
||||
@@ -1455,7 +1455,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 67.5,
|
||||
"y": -40.44800000000001,
|
||||
"y": -57,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -1548,7 +1548,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 125,
|
||||
"width": 115,
|
||||
"height": 25
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -1968,7 +1968,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 125,
|
||||
"width": 115,
|
||||
"height": 25
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -2041,10 +2041,10 @@
|
||||
},
|
||||
"_alignFlags": 44,
|
||||
"_target": null,
|
||||
"_left": 5,
|
||||
"_right": 5,
|
||||
"_left": 10,
|
||||
"_right": 10,
|
||||
"_top": 0,
|
||||
"_bottom": 22.051999999999996,
|
||||
"_bottom": 5.5000000000000036,
|
||||
"_horizontalCenter": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
@@ -2113,7 +2113,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 67.5,
|
||||
"y": -62.56900000000002,
|
||||
"y": -79.12100000000001,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -2206,7 +2206,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 125,
|
||||
"width": 115,
|
||||
"height": 25
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -2626,7 +2626,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 125,
|
||||
"width": 115,
|
||||
"height": 25
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -2699,10 +2699,10 @@
|
||||
},
|
||||
"_alignFlags": 44,
|
||||
"_target": null,
|
||||
"_left": 5,
|
||||
"_right": 5,
|
||||
"_left": 10,
|
||||
"_right": 10,
|
||||
"_top": 0,
|
||||
"_bottom": -0.06900000000000972,
|
||||
"_bottom": -16.621000000000002,
|
||||
"_horizontalCenter": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
@@ -4834,7 +4834,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 67.5,
|
||||
"y": -96.599,
|
||||
"y": -116.59899999999999,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -4846,8 +4846,8 @@
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"x": 0.5,
|
||||
"y": 0.5,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
@@ -5033,8 +5033,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 135,
|
||||
"height": 40
|
||||
"width": 230,
|
||||
"height": 80
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -5070,7 +5070,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@4a554",
|
||||
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73@abf7b",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 1,
|
||||
@@ -5086,7 +5086,7 @@
|
||||
"_isTrimmedMode": true,
|
||||
"_useGrayscale": false,
|
||||
"_atlas": {
|
||||
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4",
|
||||
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73",
|
||||
"__expectedType__": "cc.SpriteAtlas"
|
||||
},
|
||||
"_id": ""
|
||||
@@ -5181,10 +5181,10 @@
|
||||
},
|
||||
"_alignFlags": 44,
|
||||
"_target": null,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_left": 10,
|
||||
"_right": 10,
|
||||
"_top": 0,
|
||||
"_bottom": -41.599000000000004,
|
||||
"_bottom": -61.599000000000004,
|
||||
"_horizontalCenter": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1358,10 +1358,10 @@
|
||||
"height": 48,
|
||||
"rawWidth": 40,
|
||||
"rawHeight": 48,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"borderTop": 21,
|
||||
"borderBottom": 27,
|
||||
"borderLeft": 19,
|
||||
"borderRight": 17,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
|
||||
Reference in New Issue
Block a user