108 lines
4.5 KiB
C++
108 lines
4.5 KiB
C++
#include <esp_log.h>
|
||
#include <esp_err.h>
|
||
#include <nvs.h>
|
||
#include <nvs_flash.h>
|
||
#include <driver/gpio.h>
|
||
#include <esp_event.h>
|
||
#include <esp_netif.h>
|
||
#include <esp_spiffs.h>
|
||
#include <esp_system.h>
|
||
|
||
#include "application.h"
|
||
#include "system_info.h"
|
||
#include "settings.h"
|
||
|
||
#define TAG "main"
|
||
|
||
// // 新增禁用日志配置(生产环境)
|
||
// // 重定向printf到空函数,彻底禁用所有输出 新增禁用日志配置
|
||
// // ================================================================
|
||
// extern "C" {
|
||
// int printf(const char* format, ...) { return 0; }
|
||
// int puts(const char* s) { return 0; }
|
||
// int putchar(int c) { return c; }
|
||
// size_t fwrite(const void* ptr, size_t size, size_t count, FILE* stream) { return size * count; }
|
||
// }
|
||
// // ================================================================
|
||
|
||
extern "C" void app_main(void)
|
||
{
|
||
// // // ====================================================================================================
|
||
// //全局禁用所有日志输出 - 必须在最开始就设置
|
||
// esp_log_level_set("*", ESP_LOG_NONE); // 全局禁用所有日志
|
||
// //特别禁用可能的残留日志组件
|
||
// esp_log_level_set("coexist", ESP_LOG_NONE);
|
||
// esp_log_level_set("main_task", ESP_LOG_NONE);
|
||
// esp_log_level_set("MC Quantized wakenet9", ESP_LOG_NONE);
|
||
// esp_log_level_set("wakenet", ESP_LOG_NONE);
|
||
// esp_log_level_set("esp_netif_lwip", ESP_LOG_NONE);
|
||
// esp_log_level_set("wifi", ESP_LOG_NONE);
|
||
// esp_log_level_set("phy_init", ESP_LOG_NONE);
|
||
// esp_log_level_set("system_api", ESP_LOG_NONE);
|
||
// esp_log_level_set("MovecallMojiESP32S3", ESP_LOG_NONE); // 生产环境:屏蔽MovecallMojiESP32S3板级日志
|
||
// //esp_log_level_set("MovecallMojiESP32S3", ESP_LOG_INFO); // 启用MovecallMojiESP32S3板级日志以支持触摸检测
|
||
// esp_log_level_set("WiFiMAC", ESP_LOG_INFO); // 仅允许WiFiMAC组件的INFO级别日志(Wi-Fi MAC地址)
|
||
// //esp_log_level_set("Airhub", ESP_LOG_INFO); // 仅允许Airhub组件的INFO级别日志(生产测试日志)
|
||
// // =======================================================================================================
|
||
|
||
// 增加姿态传感器日志打印
|
||
esp_log_level_set("Airhub", ESP_LOG_DEBUG); // 看到运动检测日志
|
||
esp_log_level_set("Airhub", ESP_LOG_VERBOSE); // 看到详细数据日志
|
||
|
||
// 屏蔽AFE模块的警告日志
|
||
esp_log_level_set("AFE", ESP_LOG_ERROR);
|
||
|
||
// 开启VolcRtcProtocol调试日志,便于观察上行G711A帧打印
|
||
esp_log_level_set("VolcRtcProtocol", ESP_LOG_DEBUG);
|
||
|
||
// Initialize the default event loop
|
||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||
|
||
// Initialize network interface (必须在WiFi初始化之前)
|
||
ESP_ERROR_CHECK(esp_netif_init());
|
||
|
||
// Initialize NVS flash for WiFi configuration
|
||
esp_err_t ret = nvs_flash_init();
|
||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||
ESP_LOGW(TAG, "Erasing NVS flash to fix corruption");
|
||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||
ret = nvs_flash_init();
|
||
}
|
||
ESP_ERROR_CHECK(ret);
|
||
|
||
// Initialize SPIFFS filesystem - Temporarily disabled to reduce resource usage
|
||
// ESP_LOGI(TAG, "Initializing SPIFFS...");
|
||
// esp_vfs_spiffs_conf_t conf = {
|
||
// .base_path = "/spiffs",
|
||
// .partition_label = "model",
|
||
// .max_files = 5,
|
||
// .format_if_mount_failed = true
|
||
// };
|
||
|
||
// // Register and mount SPIFFS filesystem
|
||
// ret = esp_vfs_spiffs_register(&conf);
|
||
// if (ret != ESP_OK) {
|
||
// if (ret == ESP_FAIL) {
|
||
// ESP_LOGE(TAG, "Failed to mount or format filesystem");
|
||
// } else if (ret == ESP_ERR_NOT_FOUND) {
|
||
// ESP_LOGE(TAG, "Failed to find SPIFFS partition");
|
||
// } else {
|
||
// ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
|
||
// }
|
||
// } else {
|
||
// ESP_LOGI(TAG, "SPIFFS initialized successfully");
|
||
// // Check SPIFFS space
|
||
// size_t total = 0, used = 0;
|
||
// ret = esp_spiffs_info(conf.partition_label, &total, &used);
|
||
// if (ret != ESP_OK) {
|
||
// ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
|
||
// } else {
|
||
// ESP_LOGI(TAG, "SPIFFS: total: %d bytes, used: %d bytes", total, used);
|
||
// }
|
||
// }
|
||
|
||
// Launch the application
|
||
Application::GetInstance().Start();
|
||
// The main thread will exit and release the stack memory
|
||
}
|