Merge branch 'managed_esp_mqtt' into 'master'

ci: Adds documentation build

See merge request espressif/esp-mqtt!252
This commit is contained in:
Rocha Euripedes
2025-09-25 00:09:12 +08:00
61 changed files with 834 additions and 347 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

82
.gitignore vendored
View File

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

View File

@@ -1,136 +1,11 @@
stages:
- build
- test
- 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
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
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"

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}

82
.gitlab/ci/docs.yml Normal file
View File

@@ -0,0 +1,82 @@
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
.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"

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

26
.gitlab/ci/utils.sh Normal file
View File

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

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
[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: <https://docs.espressif.com/projects/esp-idf/>
- Documentation of ESP-MQTT API: <https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/protocols/mqtt.html>
- Documentation of ESP-MQTT API: <https://docs.espressif.com/projects/esp-mqtt/en/master/esp32/index.html>
## 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):

View File

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

View File

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

View File

@@ -1,2 +0,0 @@
build_dir = "$GITHUB_WORKSPACE/build_@t_@n"
config="sdkconfig.ci"

View File

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

View File

@@ -1,7 +0,0 @@
CaseConfig:
- name: test_app_protocol_mqtt_publish_connect
overwrite:
dut:
class: ESP32QEMUDUT
package: ttfw_idf

View File

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

View File

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

57
docs/Doxyfile Normal file
View File

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

39
docs/conf_common.py Normal file
View File

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

View File

@@ -0,0 +1,2 @@
# Known doxygen warnings for ESP-MQTT documentation build
# Currently no known doxygen warnings expected

27
docs/en/conf.py Normal file
View File

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

View File

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

View File

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

27
docs/zh_CN/conf.py Normal file
View File

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

View File

@@ -21,23 +21,23 @@ ESP-MQTT 是 `MQTT <https://mqtt.org/>`__ 协议客户端的实现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

View File

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

View File

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

View File

@@ -1,3 +1,6 @@
dependencies:
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"
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,
nvs,data,nvs,,24K,
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:
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:
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:
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]

View File

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

View File

@@ -1,3 +1,6 @@
dependencies:
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"
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:
idf:
version: ">=5.0"
idf:
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)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(MINIMAL_BUILD ON)
project(mqtt_tcp)

View File

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

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

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

View File

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

View File

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

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

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

View File

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

View File

@@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <algorithm>
#include <memory>
#include <net/if.h>
#include <random>
@@ -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);

View File

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