feat: 实现时间同步、NVS稳定性修复和ESP-IDF v6.0兼容性改进

This commit is contained in:
2026-04-01 18:58:20 +08:00
parent 540bfe825f
commit 9815ab8df0
17 changed files with 942 additions and 31 deletions

View File

@@ -80,3 +80,91 @@ idf.py -p COMx flash monitor
-**USB 口**(标记为 `USB`),不是 UART 口
- 如遇连接失败,按住 **BOOT** 键再插线进入下载模式
---
## ESP-IDF v6.0 API 变更与修复2026-04-01
### 5. SNTP API 弃用问题
**错误信息:**
```
warning: 'sntp_setoperatingmode' is deprecated: use esp_sntp_setoperatingmode() instead
warning: 'sntp_setservername' is deprecated: use esp_sntp_setservername() instead
warning: 'sntp_init' is deprecated: use esp_sntp_init() instead
```
**修复:** `main/time_sync/time_sync.c`
- 将所有 `sntp_*` 函数调用替换为 `esp_sntp_*` 函数
- 示例:`sntp_init()``esp_sntp_init()`
**注意:** `esp_sntp` 组件在 v6.0 中不存在,`esp_sntp_*` 函数属于 `lwip` 组件,会被 `esp_netif``esp_wifi` 自动包含。
### 6. NVS API 兼容性变化
**错误信息:**
```
error: too few arguments to function 'nvs_entry_find'; expected 4, have 3
error: passing argument 1 of 'nvs_entry_next' from incompatible pointer type
```
**修复:** `main/nvs_safety/nvs_safety.c`
- `nvs_entry_find()` 现在需要 4 个参数:`nvs_entry_find(part_name, namespace, type, &iterator)`
- `nvs_entry_next()` 需要指向迭代器的指针:`nvs_entry_next(&iterator)`
- 新增 `nvs_release_iterator()` 调用释放迭代器
**建议:** 使用 `nvs_entry_find_in_handle()` 替代 `nvs_entry_find()`,更简洁。
### 7. 结构体类型错误
**错误信息:**
```
error: expected specifier-qualifier-list before 'arg_str1'
```
**修复:** `main/cli/serial_cli.c`
- `arg_str1 *server;``struct arg_str *server;`
- `arg_end *end;``struct arg_end *end;`
**原因:** `arg_str1` 是函数名,不是类型。结构体成员应使用 `struct arg_str` 类型。
### 8. 未使用的函数警告
**错误信息:**
```
warning: 'provider_is_openai' defined but not used
```
**修复:** `main/llm/llm_proxy.c`
- 删除未使用的 `provider_is_openai()` 函数
- 该函数只是调用 `llm_provider_is_openai_compatible()`,可直接使用原函数
### 9. 组件依赖问题
**错误信息:**
```
Failed to resolve component 'esp_sntp' required by component 'main': unknown name.
```
**修复:** `main/CMakeLists.txt`
-`REQUIRES` 列表中移除 `esp_sntp` 组件
- `esp_sntp_*` 函数属于 `lwip` 组件,会被其他网络组件自动包含
---
## API 兼容性总结
### 已验证的 APIv6.0 中仍然可用)
| API | 状态 |
|-----|------|
| `esp_http_client_set_header()` | ✅ 未弃用 |
| `esp_crt_bundle_attach()` | ✅ 未弃用 |
| `esp_netif_create_default_wifi_sta()` | ✅ 未弃用 |
| `WIFI_INIT_CONFIG_DEFAULT()` | ✅ 未弃用 |
### 已弃用的 API需要替换
| 旧 API | 新 API | 文件 |
|--------|--------|------|
| `sntp_*()` | `esp_sntp_*()` | `time_sync.c` |
| `nvs_entry_find(part, ns, type)` | `nvs_entry_find(part, ns, type, &it)` | `nvs_safety.c` |
| `nvs_entry_next(it)` | `nvs_entry_next(&it)` | `nvs_safety.c` |

View File

@@ -94,10 +94,9 @@
- **MimiClaw**: Not implemented
- **Recommendation**: Simple FreeRTOS timer that periodically checks HEARTBEAT.md
### [ ] Multi-LLM Provider Support
### [x] ~~Multi-LLM Provider Support~~
- **nanobot**: `providers/litellm_provider.py` — supports OpenRouter, Anthropic, OpenAI, Gemini, DeepSeek, Groq, Zhipu, vLLM via LiteLLM
- **MimiClaw**: Hardcoded to Anthropic Messages API
- **Recommendation**: Abstract LLM interface, support OpenAI-compatible API (most providers are compatible)
- **MimiClaw**: Supports Anthropic, OpenAI, SiliconFlow (硅基流动), Volcengine (火山方舟) — abstracted via `llm_provider.c`
### [ ] Voice Transcription
- **nanobot**: `providers/transcription.py` — Groq Whisper API