From 2b33476c3f0af5671efd1ee41efea3b517a80c3c Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Filho Date: Tue, 23 Sep 2025 15:17:59 +0200 Subject: [PATCH 1/2] ci: Adds documentation build - Adds documentation build and deploy - Removes QEMU test as it is outdated --- .gitignore | 82 ++++++++++++++++++++++++++++-- .gitlab-ci.yml | 38 ++------------ .gitlab/ci/docs.yml | 85 ++++++++++++++++++++++++++++++++ .gitlab/ci/utils.sh | 26 ++++++++++ ci/build-test-rules.yml | 11 ----- ci/build_examples.sh | 22 --------- ci/idf_build_apps.toml | 2 - ci/modify_for_legacy_idf.sh | 33 ------------- ci/publish_connect_mqtt_qemu.yml | 7 --- ci/set_idf.sh | 19 ------- ci/set_mqtt.sh | 16 ------ docs/Doxyfile | 57 +++++++++++++++++++++ docs/conf_common.py | 39 +++++++++++++++ docs/doxygen-known-warnings.txt | 2 + docs/en/conf.py | 27 ++++++++++ docs/en/index.rst | 20 ++++---- docs/sphinx-known-warnings.txt | 37 ++++++++++++++ docs/zh_CN/conf.py | 27 ++++++++++ docs/zh_CN/index.rst | 20 ++++---- 19 files changed, 404 insertions(+), 166 deletions(-) create mode 100644 .gitlab/ci/docs.yml create mode 100644 .gitlab/ci/utils.sh delete mode 100644 ci/build-test-rules.yml delete mode 100755 ci/build_examples.sh delete mode 100644 ci/idf_build_apps.toml delete mode 100755 ci/modify_for_legacy_idf.sh delete mode 100644 ci/publish_connect_mqtt_qemu.yml delete mode 100755 ci/set_idf.sh delete mode 100755 ci/set_mqtt.sh create mode 100644 docs/Doxyfile create mode 100644 docs/conf_common.py create mode 100644 docs/doxygen-known-warnings.txt create mode 100644 docs/en/conf.py create mode 100644 docs/sphinx-known-warnings.txt create mode 100644 docs/zh_CN/conf.py diff --git a/.gitignore b/.gitignore index 2c4b72c..119e9fa 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,82 @@ # Debug files *.dSYM/ *.su -build -examples/**/build -examples/**/sdkconfig* + +# ESP-IDF Build System +build/ +sdkconfig +sdkconfig.old +dependencies.lock +managed_components/ + +# ESP-IDF build directories (but not source directories like build_test) +**/build/ +**/build_esp32*/ +**/build_esp32c*/ +**/build_esp32s*/ +**/build_esp32h*/ +**/build_esp32p*/ +**/build_linux*/ + +# Examples and test app builds +examples/**/build/ +examples/**/build_esp32*/ +examples/**/build_esp32c*/ +examples/**/build_esp32s*/ +examples/**/build_esp32h*/ +examples/**/build_esp32p*/ +examples/**/sdkconfig +examples/**/sdkconfig.old +examples/**/dependencies.lock +examples/**/managed_components/ + +# Test application builds (specific build directories, not source) +test/apps/**/build/ +test/apps/**/build_esp32*/ +test/apps/**/build_esp32c*/ +test/apps/**/build_esp32s*/ +test/apps/**/build_esp32h*/ +test/apps/**/build_esp32p*/ +test/apps/**/sdkconfig +test/apps/**/sdkconfig.old +test/apps/**/dependencies.lock +test/apps/**/managed_components/ + +# Host test builds +test/host/build/ +test/host/sdkconfig +test/host/sdkconfig.old +test/host/dependencies.lock +test/host/managed_components/ + +# idf-ci generated files +app_info_*.txt +size_info_*.txt +compile_commands.json +*.log + +# Python cache and environments +__pycache__/ +*.pyc +*.pyo +.venv/ +.cache/ + +# Coverage and test results +**/coverage.xml +**/coverage.html +**/junit.xml +**/pytest_*.xml +**/test_results_*.xml + +# Documentation builds +docs/_build/ +docs/build/ + +# Distribution/packaging +dist/ +build/ +*.egg-info/ + +# CI/CD artifacts +build_child_pipeline.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aadcf47..ae6eabf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - test + - test_deploy - deploy variables: @@ -73,40 +74,8 @@ build_and_host_test: - idf.py build - build/host_mqtt_client_test.elf -build_and_test_qemu: - stage: build - image: ${CI_DOCKER_REGISTRY}/qemu-v5.1:1-20220802 - tags: - - build - - internet - dependencies: [] - script: - - export IDF_PATH=$CI_PROJECT_DIR/esp-idf - - git clone "${IDF_REPO}" - # switch to IDF and setup the tools - - $MQTT_PATH/ci/set_idf.sh release/v5.1 - - $IDF_PATH/tools/idf_tools.py install-python-env - - cd $IDF_PATH && tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" - # Remove `debug_backend` and Add `paho-mqtt` to the required packages - - sed '/debug_backend/d;/pygobject/d' $IDF_PATH/tools/requirements/requirements.ttfw.txt > requirements.txt - - python -m pip install -r requirements.txt - - python -m pip install paho-mqtt - - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA - # build publish-connect stress test, setup test parameters - - cd tools/test_apps/protocols/mqtt/publish_connect_test && cat sdkconfig.qemu | $IDF_PATH/tools/ci/envsubst.py > sdkconfig.defaults && idf.py build - - export TEST_PATH=`pwd` && export MQTT_PUBLISH_TEST=1 - - export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages" - # run test (with environment->qemu) - - cd $IDF_PATH/tools/ci/python_packages/tiny_test_fw/bin - # use more relaxed criteria with QEMU tests - - export MQTT_PUBLISH_MSG_len_0=0 MQTT_PUBLISH_MSG_repeat_0=5 - - export MQTT_PUBLISH_MSG_len_1=2 MQTT_PUBLISH_MSG_repeat_1=50 - - export MQTT_PUBLISH_MSG_len_2=128 MQTT_PUBLISH_MSG_repeat_2=2 - - export MQTT_PUBLISH_MSG_len_3=20 MQTT_PUBLISH_MSG_repeat_3=20 - - python Runner.py $TEST_PATH -c $MQTT_PATH/ci/publish_connect_mqtt_qemu.yml -e $TEST_PATH/env.yml - check_remotes_sync: - stage: test + stage: test_deploy image: espressif/idf:latest tags: - build @@ -134,3 +103,6 @@ push_master_to_github: script: - *add_gh_key_remote - git push github HEAD:${CI_COMMIT_REF_NAME} + +include: + - local: ".gitlab/ci/docs.yml" diff --git a/.gitlab/ci/docs.yml b/.gitlab/ci/docs.yml new file mode 100644 index 0000000..d7b24dc --- /dev/null +++ b/.gitlab/ci/docs.yml @@ -0,0 +1,85 @@ +variables: + # System environment + ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" + ESP_DOCS_PATH: "$CI_PROJECT_DIR" + +docs_build: + stage: build + image: $ESP_DOCS_ENV_IMAGE + tags: + - build_docs + variables: + # Set Python buffering for better CI output + PYTHONUNBUFFERED: 1 + TYPE: "preview" + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + artifacts: + when: always + paths: + - docs/_build/*/*/*.txt + - docs/_build/*/*/html/* + expire_in: 4 days + before_script: + # Install ESP-IDF documentation build tool + - pip install -U pip + - pip install esp-docs linuxdoc + script: + - cd docs + - build-docs -t esp32 -l en + rules: + - if: $CI_COMMIT_REF_NAME == "master" + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + +.deploy_docs_template: + image: $ESP_DOCS_ENV_IMAGE + variables: + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + PYTHONUNBUFFERED: 1 + # ensure all tags are fetched, need to know the latest/stable tag for the docs + GIT_STRATEGY: clone + GIT_DEPTH: 0 + stage: test_deploy + tags: + - brew + - amd64 + script: + - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh + # ensure all tags are fetched, need to know the latest/stable tag for the docs + - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER + - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) + - pip install esp-docs + - deploy-docs + +deploy_docs_preview: + extends: + - .deploy_docs_template + except: + refs: + - master + needs: + - docs_build + variables: + TYPE: "preview" + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" + +deploy_docs_prod: + extends: + - .deploy_docs_template + stage: deploy + only: + refs: + - master + needs: + - docs_build + variables: + TYPE: "production" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" diff --git a/.gitlab/ci/utils.sh b/.gitlab/ci/utils.sh new file mode 100644 index 0000000..2676b09 --- /dev/null +++ b/.gitlab/ci/utils.sh @@ -0,0 +1,26 @@ +function add_ssh_keys() { + local key_string="${1}" + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo -n "${key_string}" >~/.ssh/id_rsa_base64 + base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 >~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa +} +function add_doc_server_ssh_keys() { + local key_string="${1}" + local server_url="${2}" + local server_user="${3}" + add_ssh_keys "${key_string}" + echo -e "Host ${server_url}\n\tStrictHostKeyChecking no\n\tUser ${server_user}\n" >>~/.ssh/config +} + +function add_github_remote() { + local key_string="${1}" + local remote_url="${2}" + add_ssh_keys "${key_string}" + if ! grep -q "Host github.com" ~/.ssh/config 2>/dev/null; then + printf "Host github.com\n\tStrictHostKeyChecking no\n" >>~/.ssh/config + fi + git remote remove github || true + git remote add github "${remote_url}" +} diff --git a/ci/build-test-rules.yml b/ci/build-test-rules.yml deleted file mode 100644 index ebc2ec3..0000000 --- a/ci/build-test-rules.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -examples/protocols: - enable: - - if: IDF_TARGET in ["esp32"] - -examples/protocols/mqtt/ssl_ds: - disable: - - if: SOC_DIG_SIGN_SUPPORTED != 1 - temporary: false - reason: DS not present diff --git a/ci/build_examples.sh b/ci/build_examples.sh deleted file mode 100755 index 9643ea2..0000000 --- a/ci/build_examples.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# build mqtt examples with make if $1=="make", with cmake otherwise -set -o errexit # Exit if command failed. - -if [ -z $IDF_PATH ] ; then - echo "Mandatory variables undefined" - exit 1; -fi; - -examples="tcp ssl ssl_mutual_auth ws wss" -for i in $examples; do - echo "Building MQTT example $i" - cd $IDF_PATH/examples/protocols/mqtt/$i - if [[ "$1" = "make" ]]; then - make defconfig - make -j 4 - else - rm -rf build sdkconfig - idf.py build - fi; -done diff --git a/ci/idf_build_apps.toml b/ci/idf_build_apps.toml deleted file mode 100644 index c93a728..0000000 --- a/ci/idf_build_apps.toml +++ /dev/null @@ -1,2 +0,0 @@ -build_dir = "$GITHUB_WORKSPACE/build_@t_@n" -config="sdkconfig.ci" diff --git a/ci/modify_for_legacy_idf.sh b/ci/modify_for_legacy_idf.sh deleted file mode 100755 index 8ea7e2b..0000000 --- a/ci/modify_for_legacy_idf.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z $1 ]]; then - LATEST_IDF=master -else - LATEST_IDF=$1 -fi - -# This snipped prepares environment for using esp-mqtt repository separately from idf -- legacy use before IDFv3.2 -# -esp_mqtt_path=`pwd` -mkdir -p ${esp_mqtt_path}/examples -pushd -cd $IDF_PATH -former_commit_id=`git rev-parse HEAD` -git checkout ${LATEST_IDF} - -for example in tcp; do - cp -r $IDF_PATH/examples/protocols/mqtt/${example} ${esp_mqtt_path}/examples - echo 'EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/../../../' > ${esp_mqtt_path}/examples/${example}/Makefile - cat $IDF_PATH/examples/protocols/mqtt/${example}/Makefile >> ${esp_mqtt_path}/examples/${example}/Makefile - echo "CONFIG_MQTT_TRANSPORT_SSL=" >> ${esp_mqtt_path}/examples/${example}/sdkconfig.defaults - echo "CONFIG_MQTT_TRANSPORT_WEBSOCKET=" >> ${esp_mqtt_path}/examples/${example}/sdkconfig.defaults -done - -cp -r $IDF_PATH/components/tcp_transport ${esp_mqtt_path}/.. -rm ${esp_mqtt_path}/../tcp_transport/transport_ssl.c -echo -e "#include \"esp_transport.h\"\nvoid esp_transport_ws_set_path(esp_transport_handle_t t, const char *path) {}" > ${esp_mqtt_path}/../tcp_transport/transport_ws.c - -cp $IDF_PATH/components/mqtt/Kconfig ${esp_mqtt_path} -sed 's/esp-mqtt/\./g' $IDF_PATH/components/mqtt/component.mk > ${esp_mqtt_path}/component.mk -git checkout $former_commit_id -popd \ No newline at end of file diff --git a/ci/publish_connect_mqtt_qemu.yml b/ci/publish_connect_mqtt_qemu.yml deleted file mode 100644 index 1a8cd50..0000000 --- a/ci/publish_connect_mqtt_qemu.yml +++ /dev/null @@ -1,7 +0,0 @@ -CaseConfig: -- name: test_app_protocol_mqtt_publish_connect - overwrite: - dut: - class: ESP32QEMUDUT - package: ttfw_idf - diff --git a/ci/set_idf.sh b/ci/set_idf.sh deleted file mode 100755 index 1bd7ab8..0000000 --- a/ci/set_idf.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# sets up the IDF repo incl submodules with specified version as $1 -set -o errexit # Exit if command failed. - -if [ -z $IDF_PATH ] || [ -z $MQTT_PATH ] || [ -z $1 ] ; then - echo "Mandatory variables undefined" - exit 1; -fi; - -echo "Checking out IDF version $1" -cd $IDF_PATH -# Cleans out the untracked files in the repo, so the next "git checkout" doesn't fail -git clean -f -git checkout $1 -# Removes the mqtt submodule, so the next submodule update doesn't fail -rm -rf $IDF_PATH/components/mqtt/esp-mqtt -git submodule update --init --recursive - diff --git a/ci/set_mqtt.sh b/ci/set_mqtt.sh deleted file mode 100755 index 8c70b66..0000000 --- a/ci/set_mqtt.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -# sets the mqtt in IDF tree as a submodule with the version specified as $1 -set -o errexit # Exit if command failed. - -if [ -z $IDF_PATH ] || [ -z $MQTT_PATH ] || [ -z $1 ] ; then - echo "Mandatory variables undefined" - exit 1; -fi; - -echo "Checking out MQTT version to $1" -# exchange remotes of mqtt submodules with plain copy -cd $IDF_PATH/components/mqtt/esp-mqtt -rm -rf .git # removes the actual IDF referenced version -cp -r $MQTT_PATH/.git . # replaces with the MQTT_PATH (CI checked tree) -git reset --hard $1 # sets the requested version diff --git a/docs/Doxyfile b/docs/Doxyfile new file mode 100644 index 0000000..35dabbc --- /dev/null +++ b/docs/Doxyfile @@ -0,0 +1,57 @@ +# This is Doxygen configuration file +# +# Doxygen provides over 260 configuration statements +# To make this file easier to follow, +# it contains only statements that are non-default +# +# NOTE: +# It is recommended not to change defaults unless specifically required +# Test any changes how they affect generated documentation +# Make sure that correct warnings are generated to flag issues with documented code +# +# For the complete list of configuration statements see: +# http://doxygen.nl/manual/config.html + + +PROJECT_NAME = "ESP-MQTT Programming Guide" + +## The 'INPUT' statement below is used as input by script 'gen-df-input.py' +## to automatically generate API reference list files heder_file.inc +## These files are placed in '_inc' directory +## and used to include in API reference documentation + +INPUT = \ + $(PROJECT_PATH)/include/mqtt_client.h \ + $(PROJECT_PATH)/include/mqtt5_client.h \ + $(PROJECT_PATH)/include/mqtt_supported_features.h + +## Get warnings for functions that have no documentation for their parameters or return value +## +WARN_NO_PARAMDOC = YES + +## Enable preprocessing and remove __attribute__(...) expressions from the INPUT files +## +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +PREDEFINED = \ + $(ENV_DOXYGEN_DEFINES) \ + +## Do not complain about not having dot +## +HAVE_DOT = NO + +## Generate XML that is required for Breathe +## +GENERATE_XML = YES +XML_OUTPUT = xml + +GENERATE_HTML = NO +HAVE_DOT = NO +GENERATE_LATEX = NO +GENERATE_MAN = YES +GENERATE_RTF = NO + +## Skip distracting progress messages +## +QUIET = YES diff --git a/docs/conf_common.py b/docs/conf_common.py new file mode 100644 index 0000000..7e21f29 --- /dev/null +++ b/docs/conf_common.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +# Common (non-language-specific) configuration for Sphinx +# + +# type: ignore +# pylint: disable=wildcard-import +# pylint: disable=undefined-variable + +from __future__ import print_function, unicode_literals + +from esp_docs.conf_docs import * # noqa: F403,F401 + +# IDF_PATH validation removed - not needed for standalone component docs +# Only required when using ESP-IDF extensions that depend on IDF environment + + +extensions += ['sphinx_copybutton', + # Needed as a trigger for running doxygen + 'esp_docs.esp_extensions.dummy_build_system', + 'esp_docs.esp_extensions.run_doxygen' + ] + +# link roles config +github_repo = 'espressif/esp-mqtt' + +# context used by sphinx_idf_theme +html_context['github_user'] = 'espressif' +html_context['github_repo'] = 'esp-mqtt' + +# Extra options required by sphinx_idf_theme +project_slug = 'esp-mqtt' +versions_url = './_static/mqtt_docs_versions.js' + +idf_targets = [ 'esp32' ] +languages = ['en'] + + + diff --git a/docs/doxygen-known-warnings.txt b/docs/doxygen-known-warnings.txt new file mode 100644 index 0000000..1ad7d8a --- /dev/null +++ b/docs/doxygen-known-warnings.txt @@ -0,0 +1,2 @@ +# Known doxygen warnings for ESP-MQTT documentation build +# Currently no known doxygen warnings expected \ No newline at end of file diff --git a/docs/en/conf.py b/docs/en/conf.py new file mode 100644 index 0000000..be95ec8 --- /dev/null +++ b/docs/en/conf.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# English Language RTD & Sphinx config file +# +# Uses ../conf_common.py for most non-language-specific settings. + +# Importing conf_common adds all the non-language-specific +# parts to this conf module +try: + from conf_common import * # noqa: F403,F401 +except ImportError: + import os + import sys + sys.path.insert(0, os.path.abspath('../')) + from conf_common import * # noqa: F403,F401 + +import datetime + +current_year = datetime.datetime.now().year + +# General information about the project. +project = u'ESP-MQTT Programming Guide' +copyright = u'2019 - {}, Espressif Systems (Shanghai) Co., Ltd'.format(current_year) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +language = 'en' diff --git a/docs/en/index.rst b/docs/en/index.rst index cde304e..52e1a91 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -21,23 +21,23 @@ Features Application Examples -------------------- - - :example:`protocols/mqtt/tcp` demonstrates how to implement MQTT communication over TCP (default port 1883). + - :example:`tcp` demonstrates how to implement MQTT communication over TCP (default port 1883). - - :example:`protocols/mqtt/ssl` demonstrates how to use SSL transport to implement MQTT communication over TLS (default port 8883). + - :example:`ssl` demonstrates how to use SSL transport to implement MQTT communication over TLS (default port 8883). - - :example:`protocols/mqtt/ssl_ds` demonstrates how to use digital signature peripheral for authentication to implement MQTT communication over TLS (default port 8883). + - :example:`ssl_ds` demonstrates how to use digital signature peripheral for authentication to implement MQTT communication over TLS (default port 8883). - - :example:`protocols/mqtt/ssl_mutual_auth` demonstrates how to use certificates for authentication to implement MQTT communication (default port 8883). + - :example:`ssl_mutual_auth` demonstrates how to use certificates for authentication to implement MQTT communication (default port 8883). - - :example:`protocols/mqtt/ssl_psk` demonstrates how to use pre-shared keys for authentication to implement MQTT communication over TLS (default port 8883). + - :example:`ssl_psk` demonstrates how to use pre-shared keys for authentication to implement MQTT communication over TLS (default port 8883). - - :example:`protocols/mqtt/ws` demonstrates how to implement MQTT communication over WebSocket (default port 80). + - :example:`ws` demonstrates how to implement MQTT communication over WebSocket (default port 80). - - :example:`protocols/mqtt/wss` demonstrates how to implement MQTT communication over WebSocket Secure (default port 443). + - :example:`wss` demonstrates how to implement MQTT communication over WebSocket Secure (default port 443). - - :example:`protocols/mqtt5` demonstrates how to use ESP-MQTT library to connect to broker with MQTT v5.0. + - :example:`mqtt5` demonstrates how to use ESP-MQTT library to connect to broker with MQTT v5.0. - - :example:`protocols/mqtt/custom_outbox` demonstrates how to customize the outbox in the ESP-MQTT library. + - :example:`custom_outbox` demonstrates how to customize the outbox in the ESP-MQTT library. MQTT Message Retransmission --------------------------- @@ -124,7 +124,7 @@ The broker certificate may be set in PEM or DER format. To select DER, the equiv openssl s_client -showcerts -connect mqtt.eclipseprojects.io:8883 < /dev/null \ 2> /dev/null | openssl x509 -outform PEM > mqtt_eclipse_org.pem -- Check the sample application: :example:`protocols/mqtt/ssl` +- Check the sample application: :example:`ssl` - Configuration: .. code:: c diff --git a/docs/sphinx-known-warnings.txt b/docs/sphinx-known-warnings.txt new file mode 100644 index 0000000..1746fa1 --- /dev/null +++ b/docs/sphinx-known-warnings.txt @@ -0,0 +1,37 @@ +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:type:: struct esp_mqtt_event_t esp_mqtt_event_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:type:: struct esp_mqtt_client_config_t esp_mqtt_client_config_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enum:: esp_mqtt_event_id_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enum:: esp_mqtt_connect_return_code_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enum:: esp_mqtt_error_type_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enum:: esp_mqtt_transport_t'. +mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enum:: esp_mqtt_protocol_ver_t'. +mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enumerator:: __attribute__'. +index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enumerator:: __attribute__'. +index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enumerator:: __attribute__'. +index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. +Declaration is '.. cpp:enumerator:: __attribute__'. +index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' +index.rst:line: WARNING: undefined label: 'config_mqtt_report_deleted_messages' +index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' +index.rst:line: WARNING: undefined label: 'config_mqtt_protocol_311' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_websocket' +index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' diff --git a/docs/zh_CN/conf.py b/docs/zh_CN/conf.py new file mode 100644 index 0000000..0eadade --- /dev/null +++ b/docs/zh_CN/conf.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# English Language RTD & Sphinx config file +# +# Uses ../conf_common.py for most non-language-specific settings. + +# Importing conf_common adds all the non-language-specific +# parts to this conf module +try: + from conf_common import * # noqa: F403,F401 +except ImportError: + import os + import sys + sys.path.insert(0, os.path.abspath('../')) + from conf_common import * # noqa: F403,F401 + +import datetime + +current_year = datetime.datetime.now().year + +# General information about the project. +project = u'ESP-MQTT Programming Guide' +copyright = u'2019 - {}, Espressif Systems (Shanghai) Co., Ltd'.format(current_year) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +language = 'zh_CN' diff --git a/docs/zh_CN/index.rst b/docs/zh_CN/index.rst index 27d3641..eca9217 100644 --- a/docs/zh_CN/index.rst +++ b/docs/zh_CN/index.rst @@ -21,23 +21,23 @@ ESP-MQTT 是 `MQTT `__ 协议客户端的实现,MQTT 是一 应用示例 ------------------- - - :example:`protocols/mqtt/tcp` 演示了如何通过 TCP 实现 MQTT 通信(默认端口 1883)。 + - :example:`tcp` 演示了如何通过 TCP 实现 MQTT 通信(默认端口 1883)。 - - :example:`protocols/mqtt/ssl` 演示了如何使用 SSL 传输来实现基于 TLS 的 MQTT 通信(默认端口 8883)。 + - :example:`ssl` 演示了如何使用 SSL 传输来实现基于 TLS 的 MQTT 通信(默认端口 8883)。 - - :example:`protocols/mqtt/ssl_ds` 演示了如何使用数字签名外设进行身份验证,以实现基于 TLS 的 MQTT 通信(默认端口 8883)。 + - :example:`ssl_ds` 演示了如何使用数字签名外设进行身份验证,以实现基于 TLS 的 MQTT 通信(默认端口 8883)。 - - :example:`protocols/mqtt/ssl_mutual_auth` 演示了如何使用证书进行身份验证实现 MQTT 通信(默认端口 8883)。 + - :example:`ssl_mutual_auth` 演示了如何使用证书进行身份验证实现 MQTT 通信(默认端口 8883)。 - - :example:`protocols/mqtt/ssl_psk` 演示了如何使用预共享密钥进行身份验证,以实现基于 TLS 的 MQTT 通信(默认端口 8883)。 + - :example:`ssl_psk` 演示了如何使用预共享密钥进行身份验证,以实现基于 TLS 的 MQTT 通信(默认端口 8883)。 - - :example:`protocols/mqtt/ws` 演示了如何通过 WebSocket 实现 MQTT 通信(默认端口 80)。 + - :example:`ws` 演示了如何通过 WebSocket 实现 MQTT 通信(默认端口 80)。 - - :example:`protocols/mqtt/wss` 演示了如何通过 WebSocket Secure 实现 MQTT 通信(默认端口 443)。 + - :example:`wss` 演示了如何通过 WebSocket Secure 实现 MQTT 通信(默认端口 443)。 - - :example:`protocols/mqtt5` 演示了如何使用 ESP-MQTT 库通过 MQTT v5.0 连接到代理。 + - :example:`mqtt5` 演示了如何使用 ESP-MQTT 库通过 MQTT v5.0 连接到代理。 - - :example:`protocols/mqtt/custom_outbox` 演示了如何自定义 ESP-MQTT 库中的 outbox。 + - :example:`custom_outbox` 演示了如何自定义 ESP-MQTT 库中的 outbox。 MQTT 消息重传 -------------------------- @@ -124,7 +124,7 @@ ESP-MQTT 库将始终重新传输未确认的 QoS 1 和 2 发布消息,以避 openssl s_client -showcerts -connect mqtt.eclipseprojects.io:8883 < /dev/null \ 2> /dev/null | openssl x509 -outform PEM > mqtt_eclipse_org.pem -- 检查示例应用程序::example:`protocols/mqtt/ssl` +- 检查示例应用程序::example:`ssl` - 配置: .. code:: c From 169e1ee88d329f5106ece29871f20f9781463795 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Filho Date: Tue, 23 Sep 2025 15:26:40 +0200 Subject: [PATCH 2/2] fix: Adjust all examples and test to use local component - Makes the name of component mqtt - Updates README - Adjust CI to build for supported idf versions - Removes qemu job --- .build-test-rules.yml | 106 ++++++++++++++++++ .gitlab-ci.yml | 103 +---------------- .gitlab/ci/build.yml | 27 +++++ .gitlab/ci/deploy.yml | 29 +++++ .gitlab/ci/docs.yml | 105 +++++++++-------- .gitlab/ci/ignore_build_warnings.txt | 5 + .gitlab/ci/test.yml | 50 +++++++++ .idf_build_apps.toml | 18 +++ .idf_ci.toml | 21 ++++ README.md | 29 +++-- docs/sphinx-known-warnings.txt | 44 ++++---- examples/custom_outbox/main/idf_component.yml | 3 + examples/mqtt5/main/idf_component.yml | 3 + examples/ssl/main/idf_component.yml | 3 + examples/ssl_ds/main/idf_component.yml | 3 + examples/ssl_ds/partitions.csv | 2 +- .../ssl_mutual_auth/main/idf_component.yml | 3 + examples/ssl_mutual_auth/sdkconfig.defaults | 1 + .../sdkconfig.defaults.esp32c5 | 1 + .../sdkconfig.defaults.esp32c6 | 1 + .../sdkconfig.defaults.esp32c61 | 1 + examples/ssl_psk/main/idf_component.yml | 3 + examples/ssl_psk/sdkconfig.defaults.esp32c5 | 1 + examples/ssl_psk/sdkconfig.defaults.esp32c6 | 1 + examples/ssl_psk/sdkconfig.defaults.esp32c61 | 1 + examples/tcp/main/idf_component.yml | 19 +++- examples/ws/main/idf_component.yml | 3 + examples/wss/main/idf_component.yml | 3 + idf_component.yml | 24 +++- pytest.ini | 28 +++++ test/.build-test-rules.yml | 19 ---- test/apps/build_test/CMakeLists.txt | 1 + test/apps/build_test/main/CMakeLists.txt | 3 +- test/apps/build_test/main/idf_component.yml | 4 + test/apps/mqtt/CMakeLists.txt | 15 ++- test/apps/mqtt/main/idf_component.yml | 5 + test/apps/mqtt5/CMakeLists.txt | 15 ++- test/apps/mqtt5/main/idf_component.yml | 4 + .../main/idf_component.yml | 3 + test/apps/publish_connect_test/sdkconfig.qemu | 23 ---- test/host/CMakeLists.txt | 20 ++-- test/host/main/CMakeLists.txt | 4 +- test/host/main/idf_component.yml | 3 + test/host/main/test_mqtt_client.cpp | 5 +- test/host/sdkconfig.defaults | 2 +- 45 files changed, 508 insertions(+), 259 deletions(-) create mode 100644 .build-test-rules.yml create mode 100644 .gitlab/ci/build.yml create mode 100644 .gitlab/ci/deploy.yml create mode 100644 .gitlab/ci/ignore_build_warnings.txt create mode 100644 .gitlab/ci/test.yml create mode 100644 .idf_build_apps.toml create mode 100644 .idf_ci.toml create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 create mode 100644 examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c5 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c6 create mode 100644 examples/ssl_psk/sdkconfig.defaults.esp32c61 create mode 100644 pytest.ini delete mode 100644 test/.build-test-rules.yml create mode 100644 test/apps/build_test/main/idf_component.yml create mode 100644 test/apps/mqtt/main/idf_component.yml create mode 100644 test/apps/mqtt5/main/idf_component.yml delete mode 100644 test/apps/publish_connect_test/sdkconfig.qemu diff --git a/.build-test-rules.yml b/.build-test-rules.yml new file mode 100644 index 0000000..a1929ad --- /dev/null +++ b/.build-test-rules.yml @@ -0,0 +1,106 @@ +# ESP-MQTT Build Test Rules +# Consolidated manifest covering all examples and test apps + +.default_rules: &default_rules + disable: + - if: IDF_TARGET in ["esp32h21", "esp32h4"] + temporary: true + reason: not supported yet + - if: IDF_TARGET in ["esp32p4", "esp32h2"] and IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 3 + temporary: true + reason: esp32p4/esp32h2 example dependencies require IDF versions other than 5.3 + disable_test: + - if: IDF_TARGET not in ["esp32"] + reason: Tests run only on ESP32 with ethernet runners + +# Basic TCP MQTT example +examples/tcp: + <<: *default_rules + +# SSL/TLS MQTT example +examples/ssl: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: CN verification enabled, tests disabled during server migration + +# WebSocket MQTT example +examples/ws: + <<: *default_rules + +# WebSocket Secure MQTT example +examples/wss: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: CN verification enabled, tests disabled during server migration + +# MQTT 5.0 protocol example +examples/mqtt5: + <<: *default_rules + +# SSL with mutual authentication +examples/ssl_mutual_auth: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# SSL with pre-shared keys +examples/ssl_psk: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# SSL with Digital Signature peripheral +examples/ssl_ds: + <<: *default_rules + disable: + - if: SOC_DIG_SIGN_SUPPORTED != 1 + reason: DS not present + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +# Custom outbox implementation example +examples/custom_outbox: + <<: *default_rules + disable_test: + - if: IDF_TARGET == IDF_TARGET + reason: Advanced feature demonstration, only build + +test/apps: + disable: + - if: IDF_TARGET not in ["esp32"] + reason: Test apps build only for esp32 + disable_test: + - if: IDF_TARGET != "esp32" + temporary: false + reason: Only esp32 target has ethernet runners for integration tests + +# C++ compatibility build test +test/apps/build_test: + enable: + - if: IDF_TARGET in ["esp32", "esp32c3"] + reason: C++ compatibility build test + disable_test: + - if: IDF_TARGET != IDF_TARGET + temporary: false + reason: Build only test + +# Publish/Connect integration test +test/apps/publish_connect_test: + enable: + - if: IDF_TARGET in ["esp32"] + reason: Integration test for publish/connect functionality + disable_test: + - if: IDF_TARGET != "esp32" + temporary: false + reason: Only esp32 target has ethernet runners for integration tests + +# Host tests (unit tests with mocks) +test/host: + enable: + - if: IDF_TARGET in ["linux"] + reason: Host-based unit tests with mocked ESP-IDF components diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae6eabf..6ccfe31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,105 +4,8 @@ stages: - test_deploy - deploy -variables: - IDF_REPO: ${GITLAB_SSH_SERVER}/idf/esp-idf.git - -.add_gh_key_remote: &add_gh_key_remote | - cit_add_ssh_key "${GH_PUSH_KEY}" - git remote remove github || true - git remote add github ${GH_PUSH_REPO} - -before_script: - # Use CI Tools - - curl -sSL ${CIT_LOADER_URL} | sh - - source citools/import_functions - # Add gitlab ssh key - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64 - - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - - chmod 600 ~/.ssh/id_rsa - - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - - PATH=$CI_PROJECT_DIR/esp-idf/tools:$PATH - - export MQTT_PATH=$CI_PROJECT_DIR - -.build_template: - stage: build - tags: - - build - - internet - script: - # Replace the IDF's default esp-mqtt with this version - - rm -rf $IDF_PATH/components/mqtt/esp-mqtt && cp -r $MQTT_PATH $IDF_PATH/components/mqtt/ - # Build the examples - - $MQTT_PATH/ci/build_examples.sh - -build_idf_v5.0: - extends: .build_template - image: espressif/idf:release-v5.0 - -build_idf_v5.1: - extends: .build_template - image: espressif/idf:release-v5.1 - -build_idf_v5.2: - extends: .build_template - image: espressif/idf:release-v5.2 - -build_idf_v5.3: - extends: .build_template - image: espressif/idf:release-v5.3 - -build_idf_v5.4: - extends: .build_template - image: espressif/idf:release-v5.4 - -build_idf_latest: - extends: .build_template - image: espressif/idf:latest - -build_and_host_test: - stage: build - image: espressif/idf:latest - tags: - - build - - internet - script: - # Replace the IDF's default esp-mqtt with this version - - rm -rf $IDF_PATH/components/mqtt/esp-mqtt && cp -r $MQTT_PATH $IDF_PATH/components/mqtt/ - - cd $IDF_PATH/components/mqtt/esp-mqtt/test/host - - idf.py build - - build/host_mqtt_client_test.elf - -check_remotes_sync: - stage: test_deploy - image: espressif/idf:latest - tags: - - build - - internet - except: - - master - - idf - script: - - *add_gh_key_remote - - git fetch --depth=1 origin master - - git fetch --depth=1 github master - - test "$(git rev-parse origin/master)" == "$(git rev-parse github/master)" - -push_master_to_github: - stage: deploy - image: ${CI_DOCKER_REGISTRY}/esp32-ci-env - tags: - - build - only: - - master - - idf - when: on_success - variables: - GIT_STRATEGY: clone - script: - - *add_gh_key_remote - - git push github HEAD:${CI_COMMIT_REF_NAME} - include: + - local: ".gitlab/ci/build.yml" + - local: ".gitlab/ci/test.yml" - local: ".gitlab/ci/docs.yml" + - local: ".gitlab/ci/deploy.yml" diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml new file mode 100644 index 0000000..84e536a --- /dev/null +++ b/.gitlab/ci/build.yml @@ -0,0 +1,27 @@ +# Note: No need to run build and test on master branch since we use FastForward merge strategy and so each merge request +# is tested and then merged onto top of master branch. + +.build_template: + stage: build + tags: + - build + - internet + script: + - pip install -U 'idf-ci<1' + - idf-ci build run + +build_idf_v5.3: + extends: .build_template + image: espressif/idf:release-v5.3 + +build_idf_v5.4: + extends: .build_template + image: espressif/idf:release-v5.4 + +build_idf_v5.5: + extends: .build_template + image: espressif/idf:release-v5.5 + +build_idf_latest: + extends: .build_template + image: espressif/idf:latest diff --git a/.gitlab/ci/deploy.yml b/.gitlab/ci/deploy.yml new file mode 100644 index 0000000..38920d1 --- /dev/null +++ b/.gitlab/ci/deploy.yml @@ -0,0 +1,29 @@ +push_master_to_github: + stage: deploy + image: ${CI_DOCKER_REGISTRY}/esp32-ci-env + tags: + - build + only: + refs: + - master + - idf + when: on_success + variables: + GIT_STRATEGY: clone + script: + - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh + - add_github_remote "$GH_PUSH_KEY" "$GH_PUSH_REPO" + - git push github HEAD:${CI_COMMIT_REF_NAME} + +upload_to_component_manager: + stage: deploy + image: python:3.10-alpine + tags: + - deploy + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + script: + - pip install idf-component-manager + - export IDF_COMPONENT_API_TOKEN=${MQTT_COMPONENT_API_KEY} + - export COMP_VERSION=$(grep 'version:' idf_component.yml | head -n 1 | awk '{print $2}' | tr -d '"') + - compote component upload --namespace=espressif --name=mqtt --allow-existing --version=${COMP_VERSION} diff --git a/.gitlab/ci/docs.yml b/.gitlab/ci/docs.yml index d7b24dc..5402d09 100644 --- a/.gitlab/ci/docs.yml +++ b/.gitlab/ci/docs.yml @@ -1,7 +1,7 @@ variables: - # System environment - ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" - ESP_DOCS_PATH: "$CI_PROJECT_DIR" + # System environment + ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" + ESP_DOCS_PATH: "$CI_PROJECT_DIR" docs_build: stage: build @@ -26,60 +26,57 @@ docs_build: script: - cd docs - build-docs -t esp32 -l en - rules: - - if: $CI_COMMIT_REF_NAME == "master" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" .deploy_docs_template: - image: $ESP_DOCS_ENV_IMAGE - variables: - DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" - PYTHONUNBUFFERED: 1 - # ensure all tags are fetched, need to know the latest/stable tag for the docs - GIT_STRATEGY: clone - GIT_DEPTH: 0 - stage: test_deploy - tags: - - brew - - amd64 - script: - - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh - # ensure all tags are fetched, need to know the latest/stable tag for the docs - - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER - - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) - - pip install esp-docs - - deploy-docs + image: $ESP_DOCS_ENV_IMAGE + variables: + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + PYTHONUNBUFFERED: 1 + # ensure all tags are fetched, need to know the latest/stable tag for the docs + GIT_STRATEGY: clone + GIT_DEPTH: 0 + stage: test_deploy + tags: + - brew + - amd64 + script: + - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh + # ensure all tags are fetched, need to know the latest/stable tag for the docs + - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER + - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) + - pip install esp-docs + - deploy-docs deploy_docs_preview: - extends: - - .deploy_docs_template - except: - refs: - - master - needs: - - docs_build - variables: - TYPE: "preview" - DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" - DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" - DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" - DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" - DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" - DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" + extends: + - .deploy_docs_template + except: + refs: + - master + needs: + - docs_build + variables: + TYPE: "preview" + DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" deploy_docs_prod: - extends: - - .deploy_docs_template - stage: deploy - only: - refs: - - master - needs: - - docs_build - variables: - TYPE: "production" - DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" - DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" - DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" - DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" - DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" + extends: + - .deploy_docs_template + stage: deploy + only: + refs: + - master + needs: + - docs_build + variables: + TYPE: "production" + DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" + DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" + DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" + DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" + DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" diff --git a/.gitlab/ci/ignore_build_warnings.txt b/.gitlab/ci/ignore_build_warnings.txt new file mode 100644 index 0000000..302920d --- /dev/null +++ b/.gitlab/ci/ignore_build_warnings.txt @@ -0,0 +1,5 @@ +Warning: Deprecated: Option '--flash_size' is deprecated. Use '--flash-size' instead. +Warning: Deprecated: Option '--flash_mode' is deprecated. Use '--flash-mode' instead. +Warning: Deprecated: Option '--flash_freq' is deprecated. Use '--flash-freq' instead. +Warning: Deprecated: Command 'sign_data' is deprecated. Use 'sign-data' instead. +Warning: Deprecated: Command 'extract_public_key' is deprecated. Use 'extract-public-key' instead. diff --git a/.gitlab/ci/test.yml b/.gitlab/ci/test.yml new file mode 100644 index 0000000..86725ab --- /dev/null +++ b/.gitlab/ci/test.yml @@ -0,0 +1,50 @@ +.add_gh_key_remote: &add_gh_key_remote | + curl -sSL ${CIT_LOADER_URL} | sh + source citools/import_functions + cit_add_ssh_key "${GH_PUSH_KEY}" + git remote remove github || true + git remote add github ${GH_PUSH_REPO} + +host_tests: + image: espressif/idf:latest + stage: test + tags: [build] + timeout: 1h + variables: + GIT_DEPTH: 1 + needs: [] + artifacts: + paths: + - "**/coverage.xml" + - "**/coverage.html" + expire_in: 1 week + when: always + reports: + junit: "**/junit.xml" + coverage_report: + coverage_format: cobertura + path: "**/coverage.xml" + before_script: + - pip install -U gcovr 'idf-ci<1' + script: + - idf-ci build run -t linux -p test/host + - cd test/host + - ./build_linux_coverage/host_mqtt_client_test.elf -r junit -o junit.xml + - cd ../.. + - gcovr --gcov-ignore-parse-errors -g -k -r . --html coverage.html -x coverage.xml + +check_remotes_sync: + stage: test_deploy + image: espressif/idf:latest + tags: + - build + - internet + needs: [] + except: + - master + - idf + script: + - *add_gh_key_remote + - git fetch --depth=1 origin master + - git fetch --depth=1 github master + - test "$(git rev-parse origin/master)" == "$(git rev-parse github/master)" diff --git a/.idf_build_apps.toml b/.idf_build_apps.toml new file mode 100644 index 0000000..3117396 --- /dev/null +++ b/.idf_build_apps.toml @@ -0,0 +1,18 @@ +# check the latest documentation at +# https://docs.espressif.com/projects/idf-build-apps/en/latest/references/config_file.html + +config_rules = ['sdkconfig.ci=default', 'sdkconfig.ci.*=', '=default'] + +recursive = true +check_warnings = true +keep_going = true + +build_dir = "build_@t_@w" +build_log_filename = "build.log" +size_json_filename = "size.json" + +collect_app_info_filename = "app_info_@p.txt" + +check_manifest_rules = true +manifest_filepatterns = ['**/.build-test-rules.yml'] +ignore_warning_files = ['.gitlab/ci/ignore_build_warnings.txt'] diff --git a/.idf_ci.toml b/.idf_ci.toml new file mode 100644 index 0000000..993c081 --- /dev/null +++ b/.idf_ci.toml @@ -0,0 +1,21 @@ +# ESP-MQTT idf-ci Configuration +[gitlab.artifacts] +build_job_filepatterns = [ + "**/build*/partition_table/*.bin", + "**/build*/bootloader/*.bin", + "**/build*/bootloader/*.map", + "**/build*/bootloader/*.elf", + "**/build*/config/sdkconfig.json", + "**/build*/*.map", + "**/build*/*.bin", + "**/build*/*.elf", + "**/build*/flasher_args.json", +] + +test_job_filepatterns = [ + "**/test_logs", + "**/XUNIT_RESULT_*.xml", +] + +[gitlab.build_pipeline] +runs_per_job = 15 diff --git a/README.md b/README.md index 1be44b6..f46f80b 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,33 @@ ## How to use -[ESP-MQTT](https://github.com/espressif/esp-mqtt) is a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. -Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf) +ESP-MQTT is available through the [ESP-IDF Component Manager](https://components.espressif.com/) and ships as a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. + +- To add it via the Component Manager (recommended), declare the dependency in your project's `idf_component.yml`, for example: + + ```yaml + dependencies: + espressif/mqtt: "*" + ``` + + Replace `*` with the version constraint you want to track, or run `idf.py add-dependency espressif/mqtt`. +- For local development, clone this repository as `mqtt` so the component name matches: + + ```bash + git clone https://github.com/espressif/esp-mqtt.git mqtt + ``` ## Documentation -- Please refer to the standard [ESP-IDF](https://github.com/espressif/esp-idf), documentation for the latest version: - -- Documentation of ESP-MQTT API: +- Documentation of ESP-MQTT API: ## License -- MQTT Package - [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt) -- Others [@tuanpmt](https://twitter.com/tuanpmt) -Apache License +- Apache License 2.0 +- MQTT package origin: [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt) +- Additional contributions by [@tuanpmt](https://twitter.com/tuanpmt) -## Older IDF verisons +## Older IDF versions For [ESP-IDF](https://github.com/espressif/esp-idf) versions prior to IDFv3.2, please clone as a component of [ESP-IDF](https://github.com/espressif/esp-idf): diff --git a/docs/sphinx-known-warnings.txt b/docs/sphinx-known-warnings.txt index 1746fa1..cff318d 100644 --- a/docs/sphinx-known-warnings.txt +++ b/docs/sphinx-known-warnings.txt @@ -1,37 +1,37 @@ mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:type:: struct esp_mqtt_event_t esp_mqtt_event_t'. +Declaration is '.. cpp:type:: struct esp_mqtt_event_t esp_mqtt_event_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:type:: struct esp_mqtt_client_config_t esp_mqtt_client_config_t'. +Declaration is '.. cpp:type:: struct esp_mqtt_client_config_t esp_mqtt_client_config_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_event_id_t'. +Declaration is '.. cpp:enum:: esp_mqtt_event_id_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_connect_return_code_t'. +Declaration is '.. cpp:enum:: esp_mqtt_connect_return_code_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_error_type_t'. +Declaration is '.. cpp:enum:: esp_mqtt_error_type_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_transport_t'. +Declaration is '.. cpp:enum:: esp_mqtt_transport_t'. mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enum:: esp_mqtt_protocol_ver_t'. +Declaration is '.. cpp:enum:: esp_mqtt_protocol_ver_t'. mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". mqtt5_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. -Declaration is '.. cpp:enumerator:: __attribute__'. +Declaration is '.. cpp:enumerator:: __attribute__'. index.rst:line: CRITICAL: Duplicate ID: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". -index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' -index.rst:line: WARNING: undefined label: 'config_mqtt_report_deleted_messages' -index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' -index.rst:line: WARNING: undefined label: 'config_mqtt_protocol_311' -index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' -index.rst:line: WARNING: undefined label: 'config_mqtt_transport_websocket' -index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' +index.rst:line: WARNING: Duplicate explicit target name: "mqtt5__client_8h_1a4504a6557b6b27d66613101e758693f4a8c1dfc1ccf00a08192611433ee7f17b4". +index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' +index.rst:line: WARNING: undefined label: 'config_mqtt_report_deleted_messages' +index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' +index.rst:line: WARNING: undefined label: 'config_mqtt_protocol_311' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' +index.rst:line: WARNING: undefined label: 'config_mqtt_transport_websocket' +index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' diff --git a/examples/custom_outbox/main/idf_component.yml b/examples/custom_outbox/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/custom_outbox/main/idf_component.yml +++ b/examples/custom_outbox/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/mqtt5/main/idf_component.yml b/examples/mqtt5/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/mqtt5/main/idf_component.yml +++ b/examples/mqtt5/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl/main/idf_component.yml b/examples/ssl/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl/main/idf_component.yml +++ b/examples/ssl/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_ds/main/idf_component.yml b/examples/ssl_ds/main/idf_component.yml index 947ec18..d6ee923 100644 --- a/examples/ssl_ds/main/idf_component.yml +++ b/examples/ssl_ds/main/idf_component.yml @@ -3,3 +3,6 @@ dependencies: espressif/esp_secure_cert_mgr: "^2.0.2" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_ds/partitions.csv b/examples/ssl_ds/partitions.csv index 0c4ad77..1423949 100644 --- a/examples/ssl_ds/partitions.csv +++ b/examples/ssl_ds/partitions.csv @@ -3,4 +3,4 @@ esp_secure_cert,0x3F,,,0x2000, nvs,data,nvs,,24K, phy_init,data,phy,,4K, -factory,app,factory,0x20000,1M, +factory,app,factory,0x20000,1500K, diff --git a/examples/ssl_mutual_auth/main/idf_component.yml b/examples/ssl_mutual_auth/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl_mutual_auth/main/idf_component.yml +++ b/examples/ssl_mutual_auth/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults b/examples/ssl_mutual_auth/sdkconfig.defaults new file mode 100644 index 0000000..99d3178 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults @@ -0,0 +1 @@ +# Empty file to trigger idf-ci to use esp32c6 specific file. diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c6 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_mutual_auth/sdkconfig.defaults.esp32c61 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/main/idf_component.yml b/examples/ssl_psk/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ssl_psk/main/idf_component.yml +++ b/examples/ssl_psk/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c5 b/examples/ssl_psk/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c6 b/examples/ssl_psk/sdkconfig.defaults.esp32c6 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c6 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/ssl_psk/sdkconfig.defaults.esp32c61 b/examples/ssl_psk/sdkconfig.defaults.esp32c61 new file mode 100644 index 0000000..1686559 --- /dev/null +++ b/examples/ssl_psk/sdkconfig.defaults.esp32c61 @@ -0,0 +1 @@ +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/tcp/main/idf_component.yml b/examples/tcp/main/idf_component.yml index 59805d8..c47068c 100644 --- a/examples/tcp/main/idf_component.yml +++ b/examples/tcp/main/idf_component.yml @@ -1,7 +1,14 @@ dependencies: - protocol_examples_common: - path: ${IDF_PATH}/examples/common_components/protocol_examples_common - espressif/esp_wifi_remote: - version: ">=0.10,<2.0" - rules: - - if: "target in [esp32p4, esp32h2]" + protocol_examples_common: + path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: ../../.. + espressif/esp_wifi_remote: + version: ">=0.10,<2.0" + rules: + - if: target in [esp32p4, esp32h2] + espressif/esp_hosted: + version: "2.5.1" + rules: + - if: target in [esp32p4, esp32h2] diff --git a/examples/ws/main/idf_component.yml b/examples/ws/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/ws/main/idf_component.yml +++ b/examples/ws/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/examples/wss/main/idf_component.yml b/examples/wss/main/idf_component.yml index 7181948..35d4f38 100644 --- a/examples/wss/main/idf_component.yml +++ b/examples/wss/main/idf_component.yml @@ -1,3 +1,6 @@ dependencies: protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../.." diff --git a/idf_component.yml b/idf_component.yml index 23cec31..adf10f4 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,5 +1,23 @@ +name: mqtt version: "1.0.0" -description: esp-mqtt +description: "ESP-MQTT - A robust MQTT client library for ESP32 microcontrollers supporting MQTT 3.1.1 and 5.0 protocols with multiple transport layers" +url: "https://github.com/espressif/esp-mqtt" +documentation: "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mqtt.html" +repository: "https://github.com/espressif/esp-mqtt" +issues: "https://github.com/espressif/esp-mqtt/issues" +license: "Apache-2.0" + +maintainers: + - "Espressif Systems " + +tags: + - mqtt + - mqtt5 + - protocol + - networking + dependencies: - idf: - version: ">=5.0" + idf: + version: ">=5.3" + + diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..3bbea53 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,28 @@ +[pytest] +python_files = pytest_*.py +addopts = + --embedded-services esp,idf + --ignore-no-tests-collected-error + --ignore-glob */managed_components/* + --ignore=examples/ssl + --ignore=examples/wss + --junitxml=junit.xml + --ignore-result-files .gitlab/ignored_cases.txt + --root-logdir=test_logs + +filterwarnings = + ignore::FutureWarning + +junit_family = xunit1 + +env_markers = + eth_ip101: Ethernet IP101 PHY required for test + eth_ip101_stress: Ethernet IP101 PHY required for stress test + generic: applicable to generic ESP devices + +# log related +log_cli = True +log_cli_level = INFO +log_cli_format = %(asctime)s %(levelname)s %(message)s +log_cli_date_format = %Y-%m-%d %H:%M:%S + diff --git a/test/.build-test-rules.yml b/test/.build-test-rules.yml deleted file mode 100644 index 2e58826..0000000 --- a/test/.build-test-rules.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -components/mqtt/test_apps: - disable: - - if: IDF_TARGET not in ["esp32", "esp32c3"] - reason: component test apps, needn't build all targets (chosen two, one for each architecture) - disable_test: - - if: IDF_TARGET != "esp32" - temporary: false - reason: Only esp32 target has ethernet runners - depends_components: - - mqtt - - tcp_transport - - app_update - - esp_eth - - esp_netif - - esp_event - depends_filepatterns: - - components/mqtt/test_apps/common/**/* diff --git a/test/apps/build_test/CMakeLists.txt b/test/apps/build_test/CMakeLists.txt index 7dd960d..8cf5bd5 100644 --- a/test/apps/build_test/CMakeLists.txt +++ b/test/apps/build_test/CMakeLists.txt @@ -7,4 +7,5 @@ cmake_minimum_required(VERSION 3.16) set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +idf_build_set_property(MINIMAL_BUILD ON) project(mqtt_tcp) diff --git a/test/apps/build_test/main/CMakeLists.txt b/test/apps/build_test/main/CMakeLists.txt index 2e8369c..b66769f 100644 --- a/test/apps/build_test/main/CMakeLists.txt +++ b/test/apps/build_test/main/CMakeLists.txt @@ -1,3 +1,4 @@ idf_component_register(SRCS "mqtt_app.cpp" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES nvs_flash esp_netif) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/test/apps/build_test/main/idf_component.yml b/test/apps/build_test/main/idf_component.yml new file mode 100644 index 0000000..1b39baa --- /dev/null +++ b/test/apps/build_test/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." \ No newline at end of file diff --git a/test/apps/mqtt/CMakeLists.txt b/test/apps/mqtt/CMakeLists.txt index bc86bdb..8a68117 100644 --- a/test/apps/mqtt/CMakeLists.txt +++ b/test/apps/mqtt/CMakeLists.txt @@ -1,9 +1,16 @@ #This is the project CMakeLists.txt file for the test subproject cmake_minimum_required(VERSION 3.16) -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components" - "../common") - -set(COMPONENTS main) include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +set(EXTRA_COMPONENT_DIRS "../common") + +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5") + list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components") +else() + list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +endif() + + +idf_build_set_property(MINIMAL_BUILD ON) project(esp_mqtt_client_test) diff --git a/test/apps/mqtt/main/idf_component.yml b/test/apps/mqtt/main/idf_component.yml new file mode 100644 index 0000000..30ca4ee --- /dev/null +++ b/test/apps/mqtt/main/idf_component.yml @@ -0,0 +1,5 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." + diff --git a/test/apps/mqtt5/CMakeLists.txt b/test/apps/mqtt5/CMakeLists.txt index 1c7881c..6b8e1e8 100644 --- a/test/apps/mqtt5/CMakeLists.txt +++ b/test/apps/mqtt5/CMakeLists.txt @@ -1,9 +1,16 @@ #This is the project CMakeLists.txt file for the test subproject cmake_minimum_required(VERSION 3.16) -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components" - "../common") - -set(COMPONENTS main) include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +set(EXTRA_COMPONENT_DIRS "../common") + +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "5.5") + list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/test_apps/components") +else() + list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") +endif() + + +idf_build_set_property(MINIMAL_BUILD ON) project(esp_mqtt5_client_test) diff --git a/test/apps/mqtt5/main/idf_component.yml b/test/apps/mqtt5/main/idf_component.yml new file mode 100644 index 0000000..1b39baa --- /dev/null +++ b/test/apps/mqtt5/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/mqtt: + version: "*" + override_path: "../../../.." \ No newline at end of file diff --git a/test/apps/publish_connect_test/main/idf_component.yml b/test/apps/publish_connect_test/main/idf_component.yml index 5d8a7d6..bbc39b0 100644 --- a/test/apps/publish_connect_test/main/idf_component.yml +++ b/test/apps/publish_connect_test/main/idf_component.yml @@ -4,5 +4,8 @@ dependencies: version: ">=2.0.20" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common + espressif/mqtt: + version: "*" + override_path: "../../../.." idf: version: ">=4.1.0" diff --git a/test/apps/publish_connect_test/sdkconfig.qemu b/test/apps/publish_connect_test/sdkconfig.qemu deleted file mode 100644 index 62d7f5b..0000000 --- a/test/apps/publish_connect_test/sdkconfig.qemu +++ /dev/null @@ -1,23 +0,0 @@ -CONFIG_IDF_TARGET_ESP32=y -CONFIG_EXAMPLE_USE_OPENETH=y -CONFIG_ETH_USE_OPENETH=y -CONFIG_ETH_OPENETH_DMA_RX_BUFFER_NUM=4 -CONFIG_ETH_OPENETH_DMA_TX_BUFFER_NUM=1 -CONFIG_EXAMPLE_CONNECT_ETHERNET=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y -CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=16384 -CONFIG_EXAMPLE_BROKER_SSL_URI="mqtts://${EXAMPLE_MQTT_BROKER_SSL}" -CONFIG_EXAMPLE_BROKER_TCP_URI="mqtt://${EXAMPLE_MQTT_BROKER_TCP}" -CONFIG_EXAMPLE_BROKER_WS_URI="ws://${EXAMPLE_MQTT_BROKER_WS}/ws" -CONFIG_EXAMPLE_BROKER_WSS_URI="wss://${EXAMPLE_MQTT_BROKER_WSS}/ws" -CONFIG_EXAMPLE_BROKER_CERTIFICATE_OVERRIDE="${EXAMPLE_MQTT_BROKER_CERTIFICATE}" -CONFIG_MBEDTLS_HARDWARE_AES=n -CONFIG_MBEDTLS_HARDWARE_MPI=n -CONFIG_MBEDTLS_HARDWARE_SHA=n -CONFIG_ETH_USE_SPI_ETHERNET=n -CONFIG_EXAMPLE_CONNECT_WIFI=n -CONFIG_ESP_TLS_INSECURE=y -CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y diff --git a/test/host/CMakeLists.txt b/test/host/CMakeLists.txt index b2b4aba..4b4b5d4 100644 --- a/test/host/CMakeLists.txt +++ b/test/host/CMakeLists.txt @@ -1,15 +1,17 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(COMPONENTS mqtt main) +idf_build_set_property(MINIMAL_BUILD ON) list(APPEND EXTRA_COMPONENT_DIRS - "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/" - "$ENV{IDF_PATH}/tools/mocks/freertos/" - "$ENV{IDF_PATH}/tools/mocks/esp_timer/" - "$ENV{IDF_PATH}/tools/mocks/esp_event/" - "$ENV{IDF_PATH}/tools/mocks/lwip/" - "$ENV{IDF_PATH}/tools/mocks/esp-tls/" - "$ENV{IDF_PATH}/tools/mocks/http_parser/" - "$ENV{IDF_PATH}/tools/mocks/tcp_transport/") + "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/" + "$ENV{IDF_PATH}/tools/mocks/freertos/" + "$ENV{IDF_PATH}/tools/mocks/esp_timer/" + "$ENV{IDF_PATH}/tools/mocks/esp_event/" + "$ENV{IDF_PATH}/tools/mocks/lwip/" + "$ENV{IDF_PATH}/tools/mocks/esp-tls/" + "$ENV{IDF_PATH}/tools/mocks/http_parser/" + "$ENV{IDF_PATH}/tools/mocks/tcp_transport/") project(host_mqtt_client_test) diff --git a/test/host/main/CMakeLists.txt b/test/host/main/CMakeLists.txt index 9e5347b..e258192 100644 --- a/test/host/main/CMakeLists.txt +++ b/test/host/main/CMakeLists.txt @@ -2,13 +2,13 @@ idf_component_register(SRCS "test_mqtt_client.cpp" REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log WHOLE_ARCHIVE) -target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -fconcepts) +target_compile_options(${COMPONENT_LIB} PUBLIC -fsanitize=address -Wno-missing-field-initializers) target_link_options(${COMPONENT_LIB} PUBLIC -fsanitize=address) target_link_libraries(${COMPONENT_LIB} PUBLIC Catch2::Catch2WithMain) idf_component_get_property(mqtt mqtt COMPONENT_LIB) target_compile_definitions(${mqtt} PRIVATE SOC_WIFI_SUPPORTED=1) -target_compile_options(${mqtt} PUBLIC -fsanitize=address -fconcepts) +target_compile_options(${mqtt} PUBLIC -fsanitize=address) target_link_options(${mqtt} PUBLIC -fsanitize=address) if(CONFIG_GCOV_ENABLED) diff --git a/test/host/main/idf_component.yml b/test/host/main/idf_component.yml index 6efd693..77d7483 100644 --- a/test/host/main/idf_component.yml +++ b/test/host/main/idf_component.yml @@ -1,6 +1,9 @@ ## IDF Component Manager Manifest File dependencies: espressif/catch2: "^3.5.2" + espressif/mqtt: + version: "*" + override_path: "../../.." ## Required IDF version idf: version: ">=5.0.0" diff --git a/test/host/main/test_mqtt_client.cpp b/test/host/main/test_mqtt_client.cpp index 8963df0..a5dc05c 100644 --- a/test/host/main/test_mqtt_client.cpp +++ b/test/host/main/test_mqtt_client.cpp @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include @@ -120,7 +121,9 @@ SCENARIO("MQTT Client Operation") SECTION("User set interface to use"){ http_parser_parse_url_ExpectAnyArgsAndReturn(0); http_parser_parse_url_ReturnThruPtr_u(&ret_uri); - struct ifreq if_name = {.ifr_ifrn = {"custom"}}; + struct ifreq if_name = {}; + strncpy(if_name.ifr_name, "custom", IFNAMSIZ - 1); + if_name.ifr_name[IFNAMSIZ - 1] = '\0';; config.network.if_name = &if_name; SECTION("Client is not started"){ REQUIRE(esp_mqtt_set_config(client.get(), &config)== ESP_OK); diff --git a/test/host/sdkconfig.defaults b/test/host/sdkconfig.defaults index c126429..d86d082 100644 --- a/test/host/sdkconfig.defaults +++ b/test/host/sdkconfig.defaults @@ -2,5 +2,5 @@ CONFIG_IDF_TARGET="linux" CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_COMPILER_CXX_RTTI=y CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 -CONFIG_COMPILER_STACK_CHECK_NONE=y +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n