diff --git a/.gitignore b/.gitignore index bdb6e847..7f4d8622 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ releases/ main/assets/lang_config.h main/mmap_generate_emoji.h .DS_Store -.cache \ No newline at end of file +.cache +main/mmap_generate_emoji.h \ No newline at end of file diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 1b6c65d8..ca87ebc9 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -283,12 +283,18 @@ list(APPEND FILES_TO_DOWNLOAD "panic_return.aaf" "wake.aaf") foreach(FILENAME IN LISTS FILES_TO_DOWNLOAD) set(REMOTE_FILE "${URL}/${FILENAME}") set(LOCAL_FILE "${SPIFFS_DIR}/${FILENAME}") - message(STATUS "Downloading ${FILENAME}") - file(DOWNLOAD ${REMOTE_FILE} ${LOCAL_FILE} - STATUS DOWNLOAD_STATUS) - list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - if(NOT STATUS_CODE EQUAL 0) - message(FATAL_ERROR "Failed to download ${FILENAME} from ${URL}") + + # 检查本地文件是否存在 + if(EXISTS ${LOCAL_FILE}) + message(STATUS "File ${FILENAME} already exists, skipping download") + else() + message(STATUS "Downloading ${FILENAME}") + file(DOWNLOAD ${REMOTE_FILE} ${LOCAL_FILE} + STATUS DOWNLOAD_STATUS) + list(GET DOWNLOAD_STATUS 0 STATUS_CODE) + if(NOT STATUS_CODE EQUAL 0) + message(FATAL_ERROR "Failed to download ${FILENAME} from ${URL}") + endif() endif() endforeach() diff --git a/main/boards/esp-hi/esp_hi.cc b/main/boards/esp-hi/esp_hi.cc index 6c8d0a5b..c6bb75b8 100644 --- a/main/boards/esp-hi/esp_hi.cc +++ b/main/boards/esp-hi/esp_hi.cc @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "display/lcd_display.h" #include @@ -20,6 +22,8 @@ #include "emoji_display.h" #include "servo_dog_ctrl.h" +#include "esp_hi_web_control.h" + #define TAG "ESP_HI" static const ili9341_lcd_init_cmd_t vendor_specific_init[] = { @@ -49,6 +53,25 @@ private: Button audio_wake_button_; Button move_wake_button_; anim::EmojiWidget* display_ = nullptr; + bool web_server_initialized_ = false; + + static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) + { + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED) { + EspHi* instance = static_cast(arg); + if (!instance->web_server_initialized_) { + ESP_LOGI(TAG, "WiFi connected, init web control server"); + esp_err_t err = esp_hi_web_control_server_init(); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize web control server: %d", err); + } else { + ESP_LOGI(TAG, "Web control server initialized"); + instance->web_server_initialized_ = true; + } + } + } + } void HandleMoveWakePressDown(int64_t current_time, int64_t &last_trigger_time, int &gesture_state) { @@ -139,6 +162,9 @@ private: thing_manager.AddThing(iot::CreateThing("DogLight")); thing_manager.AddThing(iot::CreateThing("DogAction_basic")); thing_manager.AddThing(iot::CreateThing("DogAction_extra")); + + ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, + &wifi_event_handler, this)); } void InitializeSpi() @@ -214,7 +240,6 @@ public: audio_wake_button_(AUDIO_WAKE_BUTTON_GPIO), move_wake_button_(MOVE_WAKE_BUTTON_GPIO) { - InitializeButtons(); InitializeIot(); InitializeSpi(); diff --git a/main/idf_component.yml b/main/idf_component.yml index ec53dfe1..d6f5abf2 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -54,7 +54,7 @@ dependencies: rules: - if: target in [esp32p4] lijunru-hub/servo_dog_ctrl: - version: '^0.1' + version: '^0.1.4' rules: - if: target in [esp32c3]