diff --git a/.github/workflows/publish-docs-component.yml b/.github/workflows/publish-docs-component.yml index f62c60b574..9b7634d3ac 100644 --- a/.github/workflows/publish-docs-component.yml +++ b/.github/workflows/publish-docs-component.yml @@ -17,7 +17,7 @@ jobs: name: Publish Tag, Release, Docs, Component runs-on: ubuntu-latest # Skip running on forks since it won't have access to secrets - if: github.repository == 'espressif/esp-protocols' + #if: github.repository == 'espressif/esp-protocols' steps: - name: Checkout esp-protocols uses: actions/checkout@v3 @@ -43,56 +43,57 @@ jobs: tag_name: ${{ env.BUMP_TAG }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Generate docs - shell: bash - run: | - sudo apt-get update - sudo apt-get -y install doxygen clang python3-pip - python -m pip install breathe recommonmark esp-docs==1.4.1 - for comp in `ls components`; do - if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then - cd $GITHUB_WORKSPACE/docs/${comp} - if [[ "${{ env.BUMP_COMPONENT }}" == "${comp}" ]]; then - echo "Building specific version of ${comp} (${{ env.BUMP_VERSION }})" - ./generate_docs ${{ env.BUMP_VERSION }} - else - echo "Building latest version of ${comp}" - ./generate_docs - fi - fi - done - - name: Deploying generated docs - shell: bash - run: | - source $GITHUB_WORKSPACE/docs/utils.sh - add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER - export GIT_VER=$(git describe --always) - export GITHUB_REF_NAME=latest - for comp in `ls components`; do - if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then - echo "Deploying latest of ${comp}" - export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs/${comp} - export DOCS_DEPLOY_PATH=$DOCS_DEPLOY_PATH_ORIG/${comp} - cd $GITHUB_WORKSPACE/docs/${comp} - deploy-docs - fi - done; - # Deploy docs with version path - if [[ "${{ env.BUMP_VERSION }}" != "" ]] && [[ -d $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} ]]; then - echo "Deploying specific version of ${{ env.BUMP_COMPONENT }} (${{ env.BUMP_VERSION }})" - cd $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} - export GITHUB_REF_NAME=${{ env.BUMP_VERSION }} - deploy-docs - fi - - name: Upload components to component service - uses: espressif/upload-components-ci-action@v1 - with: - directories: > - components/asio; - components/esp_modem; - components/esp_mqtt_cxx; - components/esp_websocket_client; - components/mdns; - components/console_simple_init; - namespace: "espressif" - api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} +# - name: Generate docs +# shell: bash +# run: | +# sudo apt-get update +# sudo apt-get -y install doxygen clang python3-pip +# python -m pip install breathe recommonmark esp-docs==1.4.1 +# for comp in `ls components`; do +# if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then +# cd $GITHUB_WORKSPACE/docs/${comp} +# if [[ "${{ env.BUMP_COMPONENT }}" == "${comp}" ]]; then +# echo "Building specific version of ${comp} (${{ env.BUMP_VERSION }})" +# ./generate_docs ${{ env.BUMP_VERSION }} +# else +# echo "Building latest version of ${comp}" +# ./generate_docs +# fi +# fi +# done +# - name: Deploying generated docs +# shell: bash +# run: | +# source $GITHUB_WORKSPACE/docs/utils.sh +# add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER +# export GIT_VER=$(git describe --always) +# export GITHUB_REF_NAME=latest +# for comp in `ls components`; do +# if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then +# echo "Deploying latest of ${comp}" +# export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs/${comp} +# export DOCS_DEPLOY_PATH=$DOCS_DEPLOY_PATH_ORIG/${comp} +# cd $GITHUB_WORKSPACE/docs/${comp} +# deploy-docs +# fi +# done; +# # Deploy docs with version path +# if [[ "${{ env.BUMP_VERSION }}" != "" ]] && [[ -d $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} ]]; then +# echo "Deploying specific version of ${{ env.BUMP_COMPONENT }} (${{ env.BUMP_VERSION }})" +# cd $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} +# export GITHUB_REF_NAME=${{ env.BUMP_VERSION }} +# deploy-docs +# fi +# - name: Upload components to component service +# uses: espressif/upload-components-ci-action@v1 +# with: +# directories: > +# components/asio; +# components/esp_modem; +# components/esp_mqtt_cxx; +# components/esp_websocket_client; +# components/mdns; +# components/console_simple_init; +# components/console_cmd_ifconfig; +# namespace: "espressif" +# api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} diff --git a/README.md b/README.md index 6aff976eba..a9ef2683ad 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,7 @@ Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf) ### console_simple_init * Brief introduction [README](components/console_simple_init/README.md) + +### console_cmd_ifconfig + +* Brief introduction [README](components/console_cmd_ifconfig/README.md) diff --git a/components/console_simple_init/examples/console_basic/main/idf_component.yml b/components/console_simple_init/examples/console_basic/main/idf_component.yml index a6027e49e6..a3d59b813f 100644 --- a/components/console_simple_init/examples/console_basic/main/idf_component.yml +++ b/components/console_simple_init/examples/console_basic/main/idf_component.yml @@ -1,6 +1,6 @@ dependencies: idf: - version: '*' + version: ">=5.0" console_simple_init: version: "*" override_path: '../../../' diff --git a/components/esp_modem/.gitignore b/components/esp_modem/.gitignore deleted file mode 100644 index 9cf987f7e2..0000000000 --- a/components/esp_modem/.gitignore +++ /dev/null @@ -1,96 +0,0 @@ -.config -*.o -*.pyc - -# gtags -GTAGS -GRTAGS -GPATH - -# emacs -.dir-locals.el - -# emacs temp file suffixes -*~ -.#* -\#*# - -# eclipse setting -.settings - -# MacOS directory files -.DS_Store - -# Components Unit Test Apps files -components/**/build -components/**/sdkconfig -components/**/sdkconfig.old - -# Example project files -examples/**/sdkconfig -examples/**/sdkconfig.old -examples/**/build - -# Doc build artifacts -docs/_build/ -docs/doxygen_sqlite3.db - -# Downloaded font files -docs/_static/DejaVuSans.ttf -docs/_static/NotoSansSC-Regular.otf - -# Unit test app files -tools/unit-test-app/sdkconfig -tools/unit-test-app/sdkconfig.old -tools/unit-test-app/build -tools/unit-test-app/builds -tools/unit-test-app/output -tools/unit-test-app/test_configs - -# Unit Test CMake compile log folder -log_ut_cmake - -# test application build files -test/**/build -test/**/sdkconfig -test/**/sdkconfig.old - -# IDF monitor test -tools/test_idf_monitor/outputs - -TEST_LOGS - -# gcov coverage reports -*.gcda -*.gcno -coverage.info -coverage_report/ - -test_multi_heap_host - -# VS Code Settings -.vscode/ - -# VIM files -*.swp -*.swo - -# Clion IDE CMake build & config -.idea/ -cmake-build-*/ - -# Results for the checking of the Python coding style and static analysis -.mypy_cache -flake8_output.txt - -# ESP-IDF default build directory name -build - -# lock files for examples and components -dependencies.lock - -# ignore generated docs -docs/html - -# esp-idf managed components -**/managed_components/** diff --git a/components/esp_modem/src/esp_modem_dte.cpp b/components/esp_modem/src/esp_modem_dte.cpp index 64bd510a31..89cf64af05 100644 --- a/components/esp_modem/src/esp_modem_dte.cpp +++ b/components/esp_modem/src/esp_modem_dte.cpp @@ -33,7 +33,7 @@ DTE::DTE(std::unique_ptr terminal): DTE::DTE(const esp_modem_dte_config *config, std::unique_ptr t, std::unique_ptr s): buffer(config->dte_buffer_size), cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)), - mode(modem_mode::UNDEF) + mode(modem_mode::DUAL_MODE) { set_command_callbacks(); } @@ -41,7 +41,7 @@ DTE::DTE(const esp_modem_dte_config *config, std::unique_ptr t, std::u DTE::DTE(std::unique_ptr t, std::unique_ptr s): buffer(dte_default_buffer_size), cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)), - mode(modem_mode::UNDEF) + mode(modem_mode::DUAL_MODE) { set_command_callbacks(); } diff --git a/components/esp_websocket_client/.gitignore b/components/esp_websocket_client/.gitignore deleted file mode 100644 index 8d681ae3ec..0000000000 --- a/components/esp_websocket_client/.gitignore +++ /dev/null @@ -1,93 +0,0 @@ -.config -*.o -*.pyc - -# gtags -GTAGS -GRTAGS -GPATH - -# emacs -.dir-locals.el - -# emacs temp file suffixes -*~ -.#* -\#*# - -# eclipse setting -.settings - -# MacOS directory files -.DS_Store - -# Components Unit Test Apps files -components/**/build -components/**/sdkconfig -components/**/sdkconfig.old - -# Example project files -examples/**/sdkconfig -examples/**/sdkconfig.old -examples/**/build - -# Doc build artifacts -docs/_build/ -docs/doxygen_sqlite3.db - -# Downloaded font files -docs/_static/DejaVuSans.ttf -docs/_static/NotoSansSC-Regular.otf - -# Unit test app files -tools/unit-test-app/sdkconfig -tools/unit-test-app/sdkconfig.old -tools/unit-test-app/build -tools/unit-test-app/builds -tools/unit-test-app/output -tools/unit-test-app/test_configs - -# Unit Test CMake compile log folder -log_ut_cmake - -# test application build files -test/**/build -test/**/sdkconfig -test/**/sdkconfig.old - -# IDF monitor test -tools/test_idf_monitor/outputs - -TEST_LOGS - -# gcov coverage reports -*.gcda -*.gcno -coverage.info -coverage_report/ - -test_multi_heap_host - -# VS Code Settings -.vscode/ - -# VIM files -*.swp -*.swo - -# Clion IDE CMake build & config -.idea/ -cmake-build-*/ - -# Results for the checking of the Python coding style and static analysis -.mypy_cache -flake8_output.txt - -# ESP-IDF default build directory name -build - -# lock files for examples and components -dependencies.lock - -# ignore generated docs -docs/html diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index 27adc5ce26..8c2b84eb90 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -792,6 +792,51 @@ esp_err_t esp_websocket_client_set_headers(esp_websocket_client_handle_t client, return ret; } +esp_err_t esp_websocket_client_append_header(esp_websocket_client_handle_t client, const char *key, const char *value) +{ + // Validate the input parameters + if (client == NULL || key == NULL || value == NULL) { + return ESP_ERR_INVALID_ARG; + } + + websocket_config_storage_t *cfg = client->config; + + // Calculate the length for "key: value\r\n" + size_t len = strlen(key) + strlen(value) + 5; // 5 accounts for ": \r\n" and null-terminator + + // If no previous headers exist + if (cfg->headers == NULL) { + cfg->headers = (char *)malloc(len); + if (cfg->headers == NULL) { + ESP_LOGE(TAG, "Failed to allocate..."); + return ESP_ERR_NO_MEM; + } + snprintf(cfg->headers, len, "%s: %s\r\n", key, value); + return ESP_OK; + } + + // Extend the current headers to accommodate the new key-value pair + size_t current_len = strlen(cfg->headers); + size_t new_len = current_len + len; + + // Allocate memory for new headers + char *new_headers = (char *)malloc(new_len); + if (new_headers == NULL) { + ESP_LOGE(TAG, "Failed to allocate..."); + return ESP_ERR_NO_MEM; + } + + // Copy old headers and append the new header + strcpy(new_headers, cfg->headers); + snprintf(new_headers + current_len, len, "%s: %s\r\n", key, value); + + // Free old headers and assign the new header pointer to cfg->headers + free(cfg->headers); + cfg->headers = new_headers; + + return ESP_OK; +} + static esp_err_t esp_websocket_client_recv(esp_websocket_client_handle_t client) { int rlen; diff --git a/components/esp_websocket_client/examples/linux/main/main.c b/components/esp_websocket_client/examples/linux/main/main.c index e89495bb64..e52dd42fd3 100644 --- a/components/esp_websocket_client/examples/linux/main/main.c +++ b/components/esp_websocket_client/examples/linux/main/main.c @@ -79,6 +79,9 @@ static void websocket_app_start(void) ESP_LOGI(TAG, "Connecting to %s...", websocket_cfg.uri); esp_websocket_client_handle_t client = esp_websocket_client_init(&websocket_cfg); + // This call demonstrates adding another header; it's called to increase code coverage + esp_websocket_client_append_header(client, "HeaderNewKey", "value"); + esp_websocket_register_events(client, WEBSOCKET_EVENT_ANY, websocket_event_handler, (void *)client); esp_websocket_client_start(client); @@ -93,6 +96,14 @@ static void websocket_app_start(void) vTaskDelay(1000 / portTICK_PERIOD_MS); } + ESP_LOGI(TAG, "Sending fragmented message"); + vTaskDelay(1000 / portTICK_PERIOD_MS); + memset(data, 'a', sizeof(data)); + esp_websocket_client_send_text_partial(client, data, sizeof(data), portMAX_DELAY); + memset(data, 'b', sizeof(data)); + esp_websocket_client_send_cont_msg(client, data, sizeof(data), portMAX_DELAY); + esp_websocket_client_send_fin(client, portMAX_DELAY); + esp_websocket_client_destroy(client); } diff --git a/components/esp_websocket_client/include/esp_websocket_client.h b/components/esp_websocket_client/include/esp_websocket_client.h index 0f7af07f44..db7e8cdb8a 100644 --- a/components/esp_websocket_client/include/esp_websocket_client.h +++ b/components/esp_websocket_client/include/esp_websocket_client.h @@ -158,13 +158,31 @@ esp_err_t esp_websocket_client_set_uri(esp_websocket_client_handle_t client, con * @brief Set additional websocket headers for the client, when performing this behavior, the headers will replace the old ones * @pre Must stop the WebSocket client before set headers if the client has been connected * - * @param[in] client The client - * @param headers additional header strings each terminated with \r\n + * - This API should be used after the WebSocket client connection has succeeded (i.e., once the transport layer is initialized). + * - If you wish to set or append headers before the WebSocket client connection is established(before handshake), consider the following options: + * 1. Input headers directly into the config options, terminating each item with [CR][LF]. This approach will replace any previous headers. + * Example: websocket_cfg.headers = "Sec-WebSocket-Key: my_key\r\nPassword: my_pass\r\n"; + * 2. Use the `esp_websocket_client_append_header` API to append a single header to the current set. + * + * @param[in] client The WebSocket client handle + * @param[in] headers Additional header strings each terminated with [CR][LF] * * @return esp_err_t */ esp_err_t esp_websocket_client_set_headers(esp_websocket_client_handle_t client, const char *headers); +/** + * @brief Appends a new key-value pair to the headers of a WebSocket client. + * @pre Ensure that this function is called before starting the WebSocket client. + * + * @param[in] client The WebSocket client handle + * @param[in] key The header key to append + * @param[in] value The associated value for the given key + * + * @return esp_err_t + */ +esp_err_t esp_websocket_client_append_header(esp_websocket_client_handle_t client, const char *key, const char *value); + /** * @brief Open the WebSocket connection * diff --git a/pytest.ini b/pytest.ini index 3705d704f8..7d368d6fdc 100644 --- a/pytest.ini +++ b/pytest.ini @@ -23,3 +23,6 @@ log_file = test.log log_file_level = INFO log_file_format = %(asctime)s %(levelname)s %(message)s log_file_date_format = %Y-%m-%d %H:%M:%S + +# Directory patterns to avoid for recursion +norecursedirs = "managed_components"