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
This commit is contained in:
Euripedes Rocha Filho
2025-09-23 15:26:40 +02:00
parent 2b33476c3f
commit 169e1ee88d
45 changed files with 508 additions and 259 deletions

106
.build-test-rules.yml Normal file
View File

@@ -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

View File

@@ -4,105 +4,8 @@ stages:
- test_deploy - test_deploy
- 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: include:
- local: ".gitlab/ci/build.yml"
- local: ".gitlab/ci/test.yml"
- local: ".gitlab/ci/docs.yml" - local: ".gitlab/ci/docs.yml"
- local: ".gitlab/ci/deploy.yml"

27
.gitlab/ci/build.yml Normal file
View File

@@ -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

29
.gitlab/ci/deploy.yml Normal file
View File

@@ -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}

View File

@@ -1,7 +1,7 @@
variables: variables:
# System environment # System environment
ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1" ESP_DOCS_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env-v5.4:1-1"
ESP_DOCS_PATH: "$CI_PROJECT_DIR" ESP_DOCS_PATH: "$CI_PROJECT_DIR"
docs_build: docs_build:
stage: build stage: build
@@ -26,60 +26,57 @@ docs_build:
script: script:
- cd docs - cd docs
- build-docs -t esp32 -l en - build-docs -t esp32 -l en
rules:
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
.deploy_docs_template: .deploy_docs_template:
image: $ESP_DOCS_ENV_IMAGE image: $ESP_DOCS_ENV_IMAGE
variables: variables:
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
PYTHONUNBUFFERED: 1 PYTHONUNBUFFERED: 1
# ensure all tags are fetched, need to know the latest/stable tag for the docs # ensure all tags are fetched, need to know the latest/stable tag for the docs
GIT_STRATEGY: clone GIT_STRATEGY: clone
GIT_DEPTH: 0 GIT_DEPTH: 0
stage: test_deploy stage: test_deploy
tags: tags:
- brew - brew
- amd64 - amd64
script: script:
- source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh - source ${CI_PROJECT_DIR}/.gitlab/ci/utils.sh
# ensure all tags are fetched, need to know the latest/stable tag for the docs # 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 - add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
- export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --) - export GIT_VER=$(git describe --always ${PIPELINE_COMMIT_SHA} --)
- pip install esp-docs - pip install esp-docs
- deploy-docs - deploy-docs
deploy_docs_preview: deploy_docs_preview:
extends: extends:
- .deploy_docs_template - .deploy_docs_template
except: except:
refs: refs:
- master - master
needs: needs:
- docs_build - docs_build
variables: variables:
TYPE: "preview" TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/" DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY" DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_PRIVATEKEY"
DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER" DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER" DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH" DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE" DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE"
deploy_docs_prod: deploy_docs_prod:
extends: extends:
- .deploy_docs_template - .deploy_docs_template
stage: deploy stage: deploy
only: only:
refs: refs:
- master - master
needs: needs:
- docs_build - docs_build
variables: variables:
TYPE: "production" TYPE: "production"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY" DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_PRIVATEKEY"
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER" DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER" DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH" DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE" DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE"

View File

@@ -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.

50
.gitlab/ci/test.yml Normal file
View File

@@ -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)"

18
.idf_build_apps.toml Normal file
View File

@@ -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']

21
.idf_ci.toml Normal file
View File

@@ -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

View File

@@ -15,22 +15,33 @@
## How to use ## How to use
[ESP-MQTT](https://github.com/espressif/esp-mqtt) is a standard [ESP-IDF](https://github.com/espressif/esp-idf) component. 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.
Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf)
- 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 ## Documentation
- Please refer to the standard [ESP-IDF](https://github.com/espressif/esp-idf), documentation for the latest version: <https://docs.espressif.com/projects/esp-idf/> - Documentation of ESP-MQTT API: <https://docs.espressif.com/projects/esp-mqtt/en/master/esp32/index.html>
- Documentation of ESP-MQTT API: <https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/protocols/mqtt.html>
## License ## License
- MQTT Package - [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt) - Apache License 2.0
- Others [@tuanpmt](https://twitter.com/tuanpmt) - MQTT package origin: [Stephen Robinson - contiki-mqtt](https://github.com/esar/contiki-mqtt)
Apache License - 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): 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):

View File

@@ -1,37 +1,37 @@
mqtt_client.inc:line: WARNING: Duplicate C++ declaration, also defined at index:line. 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. 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. 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. 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. 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. 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. 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. 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: 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. 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: 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. 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: 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. 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: 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".
index.rst:line: WARNING: undefined label: 'config_mqtt_outbox_expired_timeout_ms' 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: 'config_mqtt_report_deleted_messages'
index.rst:line: WARNING: undefined label: 'esp_tls_server_verification' 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_protocol_311'
index.rst:line: WARNING: undefined label: 'config_mqtt_transport_ssl' 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_transport_websocket'
index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox' index.rst:line: WARNING: undefined label: 'config_mqtt_custom_outbox'

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -3,3 +3,6 @@ dependencies:
espressif/esp_secure_cert_mgr: "^2.0.2" espressif/esp_secure_cert_mgr: "^2.0.2"
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -3,4 +3,4 @@
esp_secure_cert,0x3F,,,0x2000, esp_secure_cert,0x3F,,,0x2000,
nvs,data,nvs,,24K, nvs,data,nvs,,24K,
phy_init,data,phy,,4K, phy_init,data,phy,,4K,
factory,app,factory,0x20000,1M, factory,app,factory,0x20000,1500K,
1 # ESP-IDF Partition Table
3 esp_secure_cert,0x3F,,,0x2000,
4 nvs,data,nvs,,24K,
5 phy_init,data,phy,,4K,
6 factory,app,factory,0x20000,1M, factory,app,factory,0x20000,1500K,

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -0,0 +1 @@
# Empty file to trigger idf-ci to use esp32c6 specific file.

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

View File

@@ -1,7 +1,14 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/esp_wifi_remote: espressif/mqtt:
version: ">=0.10,<2.0" version: "*"
rules: override_path: ../../..
- if: "target in [esp32p4, esp32h2]" 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]

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -1,3 +1,6 @@
dependencies: dependencies:
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../.."

View File

@@ -1,5 +1,23 @@
name: mqtt
version: "1.0.0" 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 <support@espressif.com>"
tags:
- mqtt
- mqtt5
- protocol
- networking
dependencies: dependencies:
idf: idf:
version: ">=5.0" version: ">=5.3"

28
pytest.ini Normal file
View File

@@ -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

View File

@@ -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/**/*

View File

@@ -7,4 +7,5 @@ cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(MINIMAL_BUILD ON)
project(mqtt_tcp) project(mqtt_tcp)

View File

@@ -1,3 +1,4 @@
idf_component_register(SRCS "mqtt_app.cpp" 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") target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

View File

@@ -0,0 +1,4 @@
dependencies:
espressif/mqtt:
version: "*"
override_path: "../../../.."

View File

@@ -1,9 +1,16 @@
#This is the project CMakeLists.txt file for the test subproject #This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16) 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) 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) project(esp_mqtt_client_test)

View File

@@ -0,0 +1,5 @@
dependencies:
espressif/mqtt:
version: "*"
override_path: "../../../.."

View File

@@ -1,9 +1,16 @@
#This is the project CMakeLists.txt file for the test subproject #This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16) 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) 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) project(esp_mqtt5_client_test)

View File

@@ -0,0 +1,4 @@
dependencies:
espressif/mqtt:
version: "*"
override_path: "../../../.."

View File

@@ -4,5 +4,8 @@ dependencies:
version: ">=2.0.20" version: ">=2.0.20"
protocol_examples_common: protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common path: ${IDF_PATH}/examples/common_components/protocol_examples_common
espressif/mqtt:
version: "*"
override_path: "../../../.."
idf: idf:
version: ">=4.1.0" version: ">=4.1.0"

View File

@@ -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

View File

@@ -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) cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS mqtt main) idf_build_set_property(MINIMAL_BUILD ON)
list(APPEND EXTRA_COMPONENT_DIRS list(APPEND EXTRA_COMPONENT_DIRS
"$ENV{IDF_PATH}/tools/mocks/esp_hw_support/" "$ENV{IDF_PATH}/tools/mocks/esp_hw_support/"
"$ENV{IDF_PATH}/tools/mocks/freertos/" "$ENV{IDF_PATH}/tools/mocks/freertos/"
"$ENV{IDF_PATH}/tools/mocks/esp_timer/" "$ENV{IDF_PATH}/tools/mocks/esp_timer/"
"$ENV{IDF_PATH}/tools/mocks/esp_event/" "$ENV{IDF_PATH}/tools/mocks/esp_event/"
"$ENV{IDF_PATH}/tools/mocks/lwip/" "$ENV{IDF_PATH}/tools/mocks/lwip/"
"$ENV{IDF_PATH}/tools/mocks/esp-tls/" "$ENV{IDF_PATH}/tools/mocks/esp-tls/"
"$ENV{IDF_PATH}/tools/mocks/http_parser/" "$ENV{IDF_PATH}/tools/mocks/http_parser/"
"$ENV{IDF_PATH}/tools/mocks/tcp_transport/") "$ENV{IDF_PATH}/tools/mocks/tcp_transport/")
project(host_mqtt_client_test) project(host_mqtt_client_test)

View File

@@ -2,13 +2,13 @@ idf_component_register(SRCS "test_mqtt_client.cpp"
REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log
WHOLE_ARCHIVE) 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_options(${COMPONENT_LIB} PUBLIC -fsanitize=address)
target_link_libraries(${COMPONENT_LIB} PUBLIC Catch2::Catch2WithMain) target_link_libraries(${COMPONENT_LIB} PUBLIC Catch2::Catch2WithMain)
idf_component_get_property(mqtt mqtt COMPONENT_LIB) idf_component_get_property(mqtt mqtt COMPONENT_LIB)
target_compile_definitions(${mqtt} PRIVATE SOC_WIFI_SUPPORTED=1) 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) target_link_options(${mqtt} PUBLIC -fsanitize=address)
if(CONFIG_GCOV_ENABLED) if(CONFIG_GCOV_ENABLED)

View File

@@ -1,6 +1,9 @@
## IDF Component Manager Manifest File ## IDF Component Manager Manifest File
dependencies: dependencies:
espressif/catch2: "^3.5.2" espressif/catch2: "^3.5.2"
espressif/mqtt:
version: "*"
override_path: "../../.."
## Required IDF version ## Required IDF version
idf: idf:
version: ">=5.0.0" version: ">=5.0.0"

View File

@@ -3,6 +3,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <algorithm>
#include <memory> #include <memory>
#include <net/if.h> #include <net/if.h>
#include <random> #include <random>
@@ -120,7 +121,9 @@ SCENARIO("MQTT Client Operation")
SECTION("User set interface to use"){ SECTION("User set interface to use"){
http_parser_parse_url_ExpectAnyArgsAndReturn(0); http_parser_parse_url_ExpectAnyArgsAndReturn(0);
http_parser_parse_url_ReturnThruPtr_u(&ret_uri); 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; config.network.if_name = &if_name;
SECTION("Client is not started"){ SECTION("Client is not started"){
REQUIRE(esp_mqtt_set_config(client.get(), &config)== ESP_OK); REQUIRE(esp_mqtt_set_config(client.get(), &config)== ESP_OK);

View File

@@ -2,5 +2,5 @@ CONFIG_IDF_TARGET="linux"
CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_RTTI=y CONFIG_COMPILER_CXX_RTTI=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 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 CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n