diff --git a/.github/ISSUE_TEMPLATE/Issue-report.yml b/.github/ISSUE_TEMPLATE/Issue-report.yml index e3a4e92926e..a902184f06b 100644 --- a/.github/ISSUE_TEMPLATE/Issue-report.yml +++ b/.github/ISSUE_TEMPLATE/Issue-report.yml @@ -41,6 +41,8 @@ body: options: - latest master (checkout manually) - latest development Release Candidate (RC-X) + - v3.1.2 + - v3.1.1 - v3.1.0 - v3.0.7 - v3.0.6 diff --git a/.github/scripts/set_push_chunks.sh b/.github/scripts/set_push_chunks.sh index ff0af7da6e8..32c11976309 100644 --- a/.github/scripts/set_push_chunks.sh +++ b/.github/scripts/set_push_chunks.sh @@ -2,6 +2,78 @@ build_all=false chunks_count=0 +last_check_files="" + +# Define the file patterns +core_files=( + '\.github/.*' + 'cores/.*' + 'package/.*' + 'tools/.*' + 'platform\.txt' + 'programmers\.txt' + 'variants/esp32/.*' + 'variants/esp32c3/.*' + 'variants/esp32c6/.*' + 'variants/esp32h2/.*' + 'variants/esp32p4/.*' + 'variants/esp32s2/.*' + 'variants/esp32s3/.*' +) +library_files=( + 'libraries/.*/examples/.*' + 'libraries/.*/src/.*' +) +networking_files=( + 'libraries/Network/src/.*' +) +fs_files=( + 'libraries/FS/src/.*' +) +static_sketches_files=( + 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure\.ino' + 'libraries/BLE/examples/Server/Server\.ino' + 'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer\.ino' + 'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics\.ino' + 'libraries/NetworkClientSecure/src/.*' + 'libraries/BLE/src/.*' + 'libraries/Insights/src/.*' +) +idf_files=( + 'idf_component\.yml' + 'Kconfig\.projbuild' + 'CMakeLists\.txt' + 'variants/esp32c2/.*' +) + +# Function to check if any files match the patterns +check_files() { + local patterns=("$@") + local files_found="" + for pattern in "${patterns[@]}"; do + if [[ $IS_PR != 'true' ]]; then + files_found+="$(gh api repos/espressif/arduino-esp32/commits/"$GITHUB_SHA" --jq '.files[].filename' | grep -E "$pattern") " + else + files_found+="$(gh pr diff "$PR_NUM" --name-only | grep -E "$pattern") " + fi + done + + last_check_files=$(echo "$files_found" | xargs) + if [[ -n $last_check_files ]]; then + echo 'true' + else + echo 'false' + fi +} + +# Output the results +CORE_CHANGED=$(check_files "${core_files[@]}") +LIB_CHANGED=$(check_files "${library_files[@]}") +LIB_FILES=$last_check_files +NETWORKING_CHANGED=$(check_files "${networking_files[@]}") +FS_CHANGED=$(check_files "${fs_files[@]}") +STATIC_SKETCHES_CHANGED=$(check_files "${static_sketches_files[@]}") +IDF_CHANGED=$(check_files "${idf_files[@]}") if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then echo "Core files changed or not a PR. Building all." @@ -76,9 +148,9 @@ chunks+="]" { echo "build_all=$build_all" - echo "build_libraries=$BUILD_LIBRARIES" - echo "build_static_sketches=$BUILD_STATIC_SKETCHES" - echo "build_idf=$BUILD_IDF" + echo "build_libraries=$LIB_CHANGED" + echo "build_static_sketches=$STATIC_SKETCHES_CHANGED" + echo "build_idf=$IDF_CHANGED" echo "chunk_count=$chunks_count" echo "chunks=$chunks" } >> "$GITHUB_OUTPUT" diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index 00d7d1bc232..e536da50111 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -244,7 +244,7 @@ function build_sketch { # build_sketch [ext build_dir="$ARDUINO_BUILD_DIR" elif [ "$len" -eq 1 ]; then # build_dir="$sketchdir/build" - build_dir="$HOME/.arduino/tests/$sketchname/build.tmp" + build_dir="$HOME/.arduino/tests/$target/$sketchname/build.tmp" fi output_file="$HOME/.arduino/cli_compile_output.txt" @@ -254,7 +254,7 @@ function build_sketch { # build_sketch [ext for i in $(seq 0 $((len - 1))); do if [ "$len" -ne 1 ]; then # build_dir="$sketchdir/build$i" - build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp" + build_dir="$HOME/.arduino/tests/$target/$sketchname/build$i.tmp" fi rm -rf "$build_dir" mkdir -p "$build_dir" diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh index 513fd16b371..1c4bee79742 100755 --- a/.github/scripts/tests_run.sh +++ b/.github/scripts/tests_run.sh @@ -11,9 +11,11 @@ function run_test { local error=0 local sdkconfig_path local extra_args + local test_type sketchdir=$(dirname "$sketch") sketchname=$(basename "$sketchdir") + test_type=$(basename "$(dirname "$sketchdir")") if [ "$options" -eq 0 ] && [ -f "$sketchdir"/ci.json ]; then len=$(jq -r --arg target "$target" '.fqbn[$target] | length' "$sketchdir"/ci.json) @@ -25,9 +27,9 @@ function run_test { fi if [ "$len" -eq 1 ]; then - sdkconfig_path="$HOME/.arduino/tests/$sketchname/build.tmp/sdkconfig" + sdkconfig_path="$HOME/.arduino/tests/$target/$sketchname/build.tmp/sdkconfig" else - sdkconfig_path="$HOME/.arduino/tests/$sketchname/build0.tmp/sdkconfig" + sdkconfig_path="$HOME/.arduino/tests/$target/$sketchname/build0.tmp/sdkconfig" fi if [ -f "$sketchdir"/ci.json ]; then @@ -43,22 +45,22 @@ function run_test { fi if [ ! -f "$sdkconfig_path" ]; then - printf "\033[93mSketch %s not built\nMight be due to missing target requirements or build failure\033[0m\n" "$sketchname" + printf "\033[93mSketch %s build not found in %s\nMight be due to missing target requirements or build failure\033[0m\n" "$(dirname "$sdkconfig_path")" "$sketchname" printf "\n\n\n" return 0 fi - local right_target - right_target=$(grep -E "^CONFIG_IDF_TARGET=\"$target\"$" "$sdkconfig_path") - if [ -z "$right_target" ]; then - printf "\033[91mError: Sketch %s compiled for different target\n\033[0m\n" "$sketchname" + local compiled_target + compiled_target=$(grep -E "CONFIG_IDF_TARGET=" "$sdkconfig_path" | cut -d'"' -f2) + if [ "$compiled_target" != "$target" ]; then + printf "\033[91mError: Sketch %s compiled for %s, expected %s\033[0m\n" "$sketchname" "$compiled_target" "$target" printf "\n\n\n" return 1 fi if [ "$len" -eq 1 ]; then # build_dir="$sketchdir/build" - build_dir="$HOME/.arduino/tests/$sketchname/build.tmp" + build_dir="$HOME/.arduino/tests/$target/$sketchname/build.tmp" report_file="$sketchdir/$target/$sketchname.xml" fi @@ -81,7 +83,7 @@ function run_test { if [ "$len" -ne 1 ]; then # build_dir="$sketchdir/build$i" - build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp" + build_dir="$HOME/.arduino/tests/$target/$sketchname/build$i.tmp" report_file="$sketchdir/$target/$sketchname$i.xml" fi @@ -113,14 +115,14 @@ function run_test { rm "$sketchdir"/diagram.json 2>/dev/null || true result=0 - printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}" - bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$? + printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}" + bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$? printf "\n" if [ $result -ne 0 ]; then result=0 printf "\033[95mRetrying test: %s -- Config: %s\033[0m\n" "$sketchname" "$i" - printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "${extra_args[*]@Q}" - bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" ${extra_args[*]@Q}; exit \$?" || result=$? + printf "\033[95mpytest \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}" + bash -c "set +e; pytest \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$? printf "\n" if [ $result -ne 0 ]; then printf "\033[91mFailed test: %s -- Config: %s\033[0m\n\n" "$sketchname" "$i" diff --git a/.github/workflows/build_py_tools.yml b/.github/workflows/build_py_tools.yml index 48e7f2c82d3..0e785ad5b16 100644 --- a/.github/workflows/build_py_tools.yml +++ b/.github/workflows/build_py_tools.yml @@ -12,7 +12,7 @@ on: jobs: find-changed-tools: name: Check if tools have been changed - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: any_changed: ${{ steps.verify-changed-files.outputs.any_changed }} all_changed_files: ${{ steps.verify-changed-files.outputs.all_changed_files }} @@ -30,16 +30,17 @@ jobs: echo "Make sure you are using a branch inside the repository and not a fork." - name: Verify Python Tools Changed - uses: tj-actions/changed-files@v41 id: verify-changed-files - with: - fetch_depth: "2" - since_last_remote_commit: "true" - files: | - tools/get.py - tools/espota.py - tools/gen_esp32part.py - tools/gen_insights_package.py + run: | + CHANGED_FILES=$(git log -1 --name-only --pretty=format: -- tools/get.py tools/espota.py tools/gen_esp32part.py tools/gen_insights_package.py) + CHANGED_FILES=$(echo "$CHANGED_FILES" | tr '\n' ' ') + echo "all_changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT + if [ -n "$CHANGED_FILES" ]; then + echo "any_changed=true" >> $GITHUB_OUTPUT + else + echo "any_changed=false" >> $GITHUB_OUTPUT + fi + - name: List all changed files shell: bash run: | @@ -55,7 +56,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest, ubuntu-20.04, ARM] + os: [windows-latest, macos-latest, ubuntu-latest, ubuntu-24.04-arm] include: - os: windows-latest TARGET: win64 @@ -64,14 +65,12 @@ jobs: - os: macos-latest TARGET: macos SEPARATOR: ":" - - os: ubuntu-20.04 + - os: ubuntu-latest TARGET: linux-amd64 SEPARATOR: ":" - - os: ARM - CONTAINER: python:3.8-bullseye + - os: ubuntu-24.04-arm TARGET: arm SEPARATOR: ":" - container: ${{ matrix.CONTAINER }} # use python container on ARM env: DISTPATH: pytools-${{ matrix.TARGET }} PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" @@ -96,8 +95,6 @@ jobs: token: ${{ secrets.TOOLS_UPLOAD_PAT }} ref: ${{ github.event.pull_request.head.ref }} - name: Set up Python 3.8 - # Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108 - if: matrix.os != 'ARM' uses: actions/setup-python@master with: python-version: 3.8 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index dc009e445da..0a45adfc728 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -58,7 +58,19 @@ jobs: - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v42.0.2 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUM: ${{ github.event.pull_request.number }} + IS_PR: ${{ github.event_name == 'pull_request' }} + GITHUB_SHA: ${{ github.sha }} + run: | + if [[ $IS_PR != 'true' ]]; then + files_changed=$(gh api repos/espressif/arduino-esp32/commits/"$GITHUB_SHA" --jq '.files[].filename') + else + files_changed=$(gh pr diff "$PR_NUM" --name-only) + fi + echo "all_changed_files=$files_changed" >> $GITHUB_OUTPUT + echo "Changed files: $files_changed" - name: Run pre-commit hooks in changed files run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2ca9e52e48d..feb32f95d03 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -45,12 +45,13 @@ on: - "!.github/scripts/tests_*" - "!.github/scripts/upload_*" - "variants/esp32/**/*" - - "variants/esp32s2/**/*" - - "variants/esp32s3/**/*" - "variants/esp32c2/**/*" - "variants/esp32c3/**/*" - "variants/esp32c6/**/*" - "variants/esp32h2/**/*" + - "variants/esp32p4/**/*" + - "variants/esp32s2/**/*" + - "variants/esp32s3/**/*" concurrency: group: build-${{github.event.pull_request.number || github.ref}} @@ -85,58 +86,13 @@ jobs: with: fetch-depth: 2 - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v44 - with: - files_yaml: | - core: - - '.github/**' - - 'cores/**' - - 'package/**' - - 'tools/**' - - 'platform.txt' - - 'programmers.txt' - - "variants/esp32/**/*" - - "variants/esp32s2/**/*" - - "variants/esp32s3/**/*" - - "variants/esp32c3/**/*" - - "variants/esp32c6/**/*" - - "variants/esp32h2/**/*" - libraries: - - 'libraries/**/examples/**' - - 'libraries/**/src/**' - networking: - - 'libraries/Network/src/**' - fs: - - 'libraries/FS/src/**' - static_sketeches: - - 'libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino' - - 'libraries/BLE/examples/Server/Server.ino' - - 'libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino' - - 'libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino' - - 'libraries/NetworkClientSecure/src/**' - - 'libraries/BLE/src/**' - - 'libraries/Insights/src/**' - idf: - - 'idf_component.yml' - - 'Kconfig.projbuild' - - 'CMakeLists.txt' - - "variants/esp32c2/**/*" - - name: Set chunks id: set-chunks env: - LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }} IS_PR: ${{ github.event_name == 'pull_request' }} + PR_NUM: ${{ github.event.pull_request.number }} MAX_CHUNKS: ${{ env.MAX_CHUNKS }} - BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }} - BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }} - BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }} - FS_CHANGED: ${{ steps.changed-files.outputs.fs_any_changed == 'true' }} - NETWORKING_CHANGED: ${{ steps.changed-files.outputs.networking_any_changed == 'true' }} - CORE_CHANGED: ${{ steps.changed-files.outputs.core_any_changed == 'true' }} - LIB_CHANGED: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | bash ./.github/scripts/set_push_chunks.sh @@ -237,7 +193,7 @@ jobs: needs.gen-chunks.outputs.build_all == 'true' || needs.gen-chunks.outputs.build_libraries == 'true' || needs.gen-chunks.outputs.build_idf == 'true' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -245,7 +201,7 @@ jobs: # See https://hub.docker.com/r/espressif/idf/tags and # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html # for details. - idf_ver: ["release-v5.3"] + idf_ver: ["release-v5.4"] idf_target: [ "esp32", diff --git a/.github/workflows/tests_build.yml b/.github/workflows/tests_build.yml index 7a5a2959657..7a10c95ed22 100644 --- a/.github/workflows/tests_build.yml +++ b/.github/workflows/tests_build.yml @@ -26,10 +26,10 @@ jobs: with: key: tests-${{ env.id }}-bin path: | - ~/.arduino/tests/**/build*.tmp/*.bin - ~/.arduino/tests/**/build*.tmp/*.elf - ~/.arduino/tests/**/build*.tmp/*.json - ~/.arduino/tests/**/build*.tmp/sdkconfig + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig - name: Evaluate if tests should be built id: check-build @@ -73,10 +73,10 @@ jobs: with: key: tests-${{ env.id }}-bin path: | - ~/.arduino/tests/**/build*.tmp/*.bin - ~/.arduino/tests/**/build*.tmp/*.elf - ~/.arduino/tests/**/build*.tmp/*.json - ~/.arduino/tests/**/build*.tmp/sdkconfig + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig - name: Upload ${{ inputs.chip }} ${{ inputs.type }} binaries as artifacts uses: actions/upload-artifact@v4 @@ -84,7 +84,7 @@ jobs: name: tests-bin-${{ inputs.chip }}-${{ inputs.type }} overwrite: true path: | - ~/.arduino/tests/**/build*.tmp/*.bin - ~/.arduino/tests/**/build*.tmp/*.elf - ~/.arduino/tests/**/build*.tmp/*.json - ~/.arduino/tests/**/build*.tmp/sdkconfig + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.bin + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.elf + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/*.json + ~/.arduino/tests/${{ inputs.chip }}/**/build*.tmp/sdkconfig diff --git a/.github/workflows/tests_hw.yml b/.github/workflows/tests_hw.yml index 76480ed7c0e..6c15ba79a7f 100644 --- a/.github/workflows/tests_hw.yml +++ b/.github/workflows/tests_hw.yml @@ -22,13 +22,18 @@ defaults: jobs: hardware-test: name: Hardware ${{ inputs.chip }} ${{ inputs.type }} tests - runs-on: [arduino, "${{ inputs.chip }}"] + runs-on: ["arduino", "${{ inputs.chip }}"] env: id: ${{ github.event.pull_request.number || github.ref }}-${{ github.event.pull_request.head.sha || github.sha }}-${{ inputs.chip }}-${{ inputs.type }} container: image: python:3.10.1-bullseye - options: --privileged + options: --privileged --device-cgroup-rule="c 188:* rmw" --device-cgroup-rule="c 166:* rmw" steps: + - name: Clean workspace + run: | + rm -rf ./* + rm -rf ~/.arduino/tests + - name: Check if already passed id: cache-results if: github.event.pull_request.number != null @@ -81,7 +86,12 @@ jobs: with: name: tests-bin-${{ inputs.chip }}-${{ inputs.type }} path: | - ~/.arduino/tests + ~/.arduino/tests/${{ inputs.chip }} + + - name: List binaries + if: ${{ steps.check-tests.outputs.enabled == 'true' }} + run: | + ls -laR ~/.arduino/tests - name: Run Tests if: ${{ steps.check-tests.outputs.enabled == 'true' }} diff --git a/.github/workflows/tests_qemu.yml b/.github/workflows/tests_qemu.yml index 6675909c9df..6c5934ce69a 100644 --- a/.github/workflows/tests_qemu.yml +++ b/.github/workflows/tests_qemu.yml @@ -117,7 +117,7 @@ jobs: with: name: tests-bin-${{ inputs.chip }}-${{ inputs.type }} path: | - ~/.arduino/tests + ~/.arduino/tests/${{ inputs.chip }} - name: Run Tests if: ${{ steps.check-tests.outputs.enabled == 'true' }} diff --git a/.github/workflows/tests_results.yml b/.github/workflows/tests_results.yml index 947de64ece5..9e213fad14e 100644 --- a/.github/workflows/tests_results.yml +++ b/.github/workflows/tests_results.yml @@ -41,6 +41,7 @@ jobs: original_sha=$(cat ./artifacts/parent-artifacts/sha.txt) original_ref=$(cat ./artifacts/parent-artifacts/ref.txt) original_conclusion=$(cat ./artifacts/parent-artifacts/conclusion.txt) + original_run_id=$(cat ./artifacts/parent-artifacts/run_id.txt) # Sanitize the values to avoid security issues @@ -59,17 +60,27 @@ jobs: # Conclusion: Allow alphabetical characters and underscores original_conclusion=$(echo "$original_conclusion" | tr -cd '[:alpha:]_') + # Run ID: Allow numeric characters + original_run_id=$(echo "$original_run_id" | tr -cd '[:digit:]') + echo "original_event=$original_event" >> $GITHUB_ENV echo "original_action=$original_action" >> $GITHUB_ENV echo "original_sha=$original_sha" >> $GITHUB_ENV echo "original_ref=$original_ref" >> $GITHUB_ENV echo "original_conclusion=$original_conclusion" >> $GITHUB_ENV + echo "original_run_id=$original_run_id" >> $GITHUB_ENV echo "original_event = $original_event" echo "original_action = $original_action" echo "original_sha = $original_sha" echo "original_ref = $original_ref" echo "original_conclusion = $original_conclusion" + echo "original_run_id = $original_run_id" + + - name: Print links to other runs + run: | + echo "Build, Hardware and QEMU tests: https://github.com/${{ github.repository }}/actions/runs/${{ env.original_run_id }}" + echo "Wokwi tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}" - name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v2 @@ -80,6 +91,17 @@ jobs: files: ./artifacts/**/*.xml action_fail: true compare_to_earlier_commit: false + json_file: ./unity_results.json + json_suite_details: true + + - name: Upload JSON + uses: actions/upload-artifact@v4 + if: ${{ always() }} + with: + name: unity_results + overwrite: true + path: | + ./unity_results.json - name: Fail if tests failed if: ${{ env.original_conclusion == 'failure' || env.original_conclusion == 'timed_out' || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' }} @@ -138,11 +160,18 @@ jobs: })).data; core.info(`${name} is ${state}`); - - name: Create output folder + - name: Generate report if: ${{ !cancelled() && (env.original_event == 'schedule' || env.original_event == 'workflow_dispatch') }} # codespell:ignore cancelled + env: + REPORT_FILE: ./runtime-tests-results/RUNTIME_TESTS_REPORT.md + WOKWI_RUN_ID: ${{ github.event.workflow_run.id }} + BUILD_RUN_ID: ${{ env.original_run_id }} + IS_FAILING: ${{ env.original_conclusion == 'failure' || env.original_conclusion == 'timed_out' || github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' || job.status == 'failure' }} run: | - rm -rf artifacts - mkdir -p runtime-tests-results + rm -rf artifacts $REPORT_FILE + mv -f ./unity_results.json ./runtime-tests-results/unity_results.json + touch $REPORT_FILE + python3 ./runtime-tests-results/table_generator.py ./runtime-tests-results/unity_results.json >> $REPORT_FILE - name: Generate badge if: ${{ !cancelled() && (env.original_event == 'schedule' || env.original_event == 'workflow_dispatch') }} # codespell:ignore cancelled @@ -161,6 +190,6 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" if [[ `git status --porcelain` ]]; then git add --all - git commit -m "Updated runtime tests badge" + git commit -m "Updated runtime tests report" git push origin HEAD:gh-pages fi diff --git a/.github/workflows/tests_wokwi.yml b/.github/workflows/tests_wokwi.yml index f5eb2efcad2..4e5d3ceca51 100644 --- a/.github/workflows/tests_wokwi.yml +++ b/.github/workflows/tests_wokwi.yml @@ -109,6 +109,10 @@ jobs: printf "\nAction = " cat artifacts/action.txt + printf "${{ github.event.workflow_run.id }}" >> artifacts/run_id.txt + printf "\nRun ID = " + cat artifacts/run_id.txt + if [ -z "$ref" ] || [ "$ref" == "null" ]; then echo "Failed to get PR number or ref" exit 1 @@ -272,7 +276,7 @@ jobs: run-id: ${{ github.event.workflow_run.id }} name: tests-bin-${{ matrix.chip }}-${{ matrix.type }} path: | - ~/.arduino/tests + ~/.arduino/tests/${{ matrix.chip }} - name: Run Tests if: ${{ steps.check-tests.outputs.enabled == 'true' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd23d14d77..d2a9162a9ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # idf.py build set(min_supported_idf_version "5.3.0") -set(max_supported_idf_version "5.3.99") +set(max_supported_idf_version "5.4.99") set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}") if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}") @@ -33,6 +33,7 @@ set(CORE_SRCS cores/esp32/esp32-hal-dac.c cores/esp32/esp32-hal-gpio.c cores/esp32/esp32-hal-i2c.c + cores/esp32/esp32-hal-i2c-ng.c cores/esp32/esp32-hal-i2c-slave.c cores/esp32/esp32-hal-ledc.c cores/esp32/esp32-hal-matrix.c @@ -290,6 +291,14 @@ set(ARDUINO_LIBRARY_Zigbee_SRCS libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp + libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp + libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp + libraries/Zigbee/src/ep/ZigbeeWindowCovering.cpp + libraries/Zigbee/src/ep/ZigbeeVibrationSensor.cpp + libraries/Zigbee/src/ep/ZigbeeAnalog.cpp + libraries/Zigbee/src/ep/ZigbeeRangeExtender.cpp + libraries/Zigbee/src/ep/ZigbeeGateway.cpp + libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp ) set(ARDUINO_LIBRARY_BLE_SRCS diff --git a/README.md b/README.md index 0a9a6d0440c..9d300b25c54 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/push.yml?branch=master&event=push&label=Compilation%20Tests)](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml?query=branch%3Amaster+event%3Apush) [![Verbose Build Status](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/push.yml?branch=master&event=schedule&label=Compilation%20Tests%20(Verbose))](https://github.com/espressif/arduino-esp32/actions/workflows/push.yml?query=branch%3Amaster+event%3Aschedule) [![External Libraries Test](https://img.shields.io/github/actions/workflow/status/espressif/arduino-esp32/lib.yml?branch=master&event=schedule&label=External%20Libraries%20Test)](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md) -[![Runtime Tests](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/actions/workflows/tests_results.yml) +[![Runtime Tests](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/badge.svg)](https://github.com/espressif/arduino-esp32/blob/gh-pages/runtime-tests-results/RUNTIME_TESTS_REPORT.md) ### Need help or have a question? Join the chat at [Discord](https://discord.gg/8xY6e9crwv) or [open a new Discussion](https://github.com/espressif/arduino-esp32/discussions) diff --git a/boards.txt b/boards.txt index 8e9655cda48..2afe45f50a6 100644 --- a/boards.txt +++ b/boards.txt @@ -536,22 +536,16 @@ esp32h2.menu.ZigbeeMode.default.build.zigbee_mode= esp32h2.menu.ZigbeeMode.default.build.zigbee_libs= esp32h2.menu.ZigbeeMode.ed=Zigbee ED (end device) esp32h2.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32h2.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +esp32h2.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native esp32h2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32h2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32h2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -esp32h2.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -esp32h2.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32h2.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +esp32h2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native esp32h2.menu.ZigbeeMode.ed_debug=Zigbee ED (end device) - Debug esp32h2.menu.ZigbeeMode.ed_debug.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32h2.menu.ZigbeeMode.ed_debug.build.zigbee_libs=-lesp_zb_api_ed.debug -lesp_zb_cli_command -lzboss_stack.ed.debug -lzboss_port.debug +esp32h2.menu.ZigbeeMode.ed_debug.build.zigbee_libs=-lesp_zb_api.ed.debug -lzboss_stack.ed.debug -lzboss_port.native.debug esp32h2.menu.ZigbeeMode.zczr_debug=Zigbee ZCZR (coordinator/router) - Debug esp32h2.menu.ZigbeeMode.zczr_debug.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32h2.menu.ZigbeeMode.zczr_debug.build.zigbee_libs=-lesp_zb_api_zczr.debug -lesp_zb_cli_command -lzboss_stack.zczr.debug -lzboss_port.debug -esp32h2.menu.ZigbeeMode.rcp_debug=Zigbee RCP (radio co-processor) - Debug -esp32h2.menu.ZigbeeMode.rcp_debug.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32h2.menu.ZigbeeMode.rcp_debug.build.zigbee_libs=-lesp_zb_api_rcp.debug -lesp_zb_cli_command -lzboss_stack.rcp.debug -lzboss_port.debug +esp32h2.menu.ZigbeeMode.zczr_debug.build.zigbee_libs=-lesp_zb_api.zczr.debug -lzboss_stack.zczr.debug -lzboss_port.native.debug ############################################################## @@ -748,22 +742,16 @@ esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native esp32c6.menu.ZigbeeMode.ed_debug=Zigbee ED (end device) - Debug esp32c6.menu.ZigbeeMode.ed_debug.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32c6.menu.ZigbeeMode.ed_debug.build.zigbee_libs=-lesp_zb_api_ed.debug -lesp_zb_cli_command -lzboss_stack.ed.debug -lzboss_port.debug +esp32c6.menu.ZigbeeMode.ed_debug.build.zigbee_libs=-lesp_zb_api.ed.debug -lzboss_stack.ed.debug -lzboss_port.native.debug esp32c6.menu.ZigbeeMode.zczr_debug=Zigbee ZCZR (coordinator/router) - Debug esp32c6.menu.ZigbeeMode.zczr_debug.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32c6.menu.ZigbeeMode.zczr_debug.build.zigbee_libs=-lesp_zb_api_zczr.debug -lesp_zb_cli_command -lzboss_stack.zczr.debug -lzboss_port.debug -esp32c6.menu.ZigbeeMode.rcp_debug=Zigbee RCP (radio co-processor) - Debug -esp32c6.menu.ZigbeeMode.rcp_debug.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32c6.menu.ZigbeeMode.rcp_debug.build.zigbee_libs=-lesp_zb_api_rcp.debug -lesp_zb_cli_command -lzboss_stack.rcp.debug -lzboss_port.debug +esp32c6.menu.ZigbeeMode.zczr_debug.build.zigbee_libs=-lesp_zb_api.zczr.debug -lzboss_stack.zczr.debug -lzboss_port.native.debug ############################################################## @@ -959,6 +947,9 @@ esp32s3.menu.PartitionScheme.esp_sr_16.build.partitions=esp_sr_16 esp32s3.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs esp32s3.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr esp32s3.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720 +esp32s3.menu.PartitionScheme.zigbee_zczr_8MB=Zigbee ZCZR 8MB with spiffs +esp32s3.menu.PartitionScheme.zigbee_zczr_8MB.build.partitions=zigbee_zczr_8MB +esp32s3.menu.PartitionScheme.zigbee_zczr_8MB.upload.maximum_size=3407872 esp32s3.menu.PartitionScheme.custom=Custom esp32s3.menu.PartitionScheme.custom.build.partitions= esp32s3.menu.PartitionScheme.custom.upload.maximum_size=16777216 @@ -1014,7 +1005,7 @@ esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -1120,6 +1111,9 @@ esp32c3.menu.PartitionScheme.rainmaker_8MB.upload.maximum_size=4116480 esp32c3.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs esp32c3.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr esp32c3.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720 +esp32c3.menu.PartitionScheme.zigbee_zczr_8MB=Zigbee ZCZR 8MB with spiffs +esp32c3.menu.PartitionScheme.zigbee_zczr_8MB.build.partitions=zigbee_zczr_8MB +esp32c3.menu.PartitionScheme.zigbee_zczr_8MB.upload.maximum_size=3407872 esp32c3.menu.PartitionScheme.custom=Custom esp32c3.menu.PartitionScheme.custom.build.partitions= esp32c3.menu.PartitionScheme.custom.upload.maximum_size=16777216 @@ -1194,7 +1188,7 @@ esp32c3.menu.ZigbeeMode.default.build.zigbee_mode= esp32c3.menu.ZigbeeMode.default.build.zigbee_libs= esp32c3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32c3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32c3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +esp32c3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -1325,6 +1319,9 @@ esp32s2.menu.PartitionScheme.rainmaker_8MB.upload.maximum_size=4116480 esp32s2.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs esp32s2.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr esp32s2.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720 +esp32s2.menu.PartitionScheme.zigbee_zczr_8MB=Zigbee ZCZR 8MB with spiffs +esp32s2.menu.PartitionScheme.zigbee_zczr_8MB.build.partitions=zigbee_zczr_8MB +esp32s2.menu.PartitionScheme.zigbee_zczr_8MB.upload.maximum_size=3407872 esp32s2.menu.PartitionScheme.custom=Custom esp32s2.menu.PartitionScheme.custom.build.partitions= esp32s2.menu.PartitionScheme.custom.upload.maximum_size=16777216 @@ -1401,7 +1398,7 @@ esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -1505,6 +1502,9 @@ esp32.menu.PartitionScheme.rainmaker_8MB.upload.maximum_size=4116480 esp32.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs esp32.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr esp32.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720 +esp32.menu.PartitionScheme.zigbee_zczr_8MB=Zigbee ZCZR 8MB with spiffs +esp32.menu.PartitionScheme.zigbee_zczr_8MB.build.partitions=zigbee_zczr_8MB +esp32.menu.PartitionScheme.zigbee_zczr_8MB.upload.maximum_size=3407872 esp32.menu.PartitionScheme.custom=Custom esp32.menu.PartitionScheme.custom.build.partitions= esp32.menu.PartitionScheme.custom.upload.maximum_size=16777216 @@ -1595,7 +1595,7 @@ esp32.menu.ZigbeeMode.default.build.zigbee_mode= esp32.menu.ZigbeeMode.default.build.zigbee_libs= esp32.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +esp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -4965,13 +4965,10 @@ um_tinyc6.menu.ZigbeeMode.default.build.zigbee_mode= um_tinyc6.menu.ZigbeeMode.default.build.zigbee_libs= um_tinyc6.menu.ZigbeeMode.ed=Zigbee ED (end device) um_tinyc6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -um_tinyc6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +um_tinyc6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native um_tinyc6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) um_tinyc6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -um_tinyc6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -um_tinyc6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -um_tinyc6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -um_tinyc6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +um_tinyc6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -7790,7 +7787,7 @@ sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.default.build.zigbee_mode= sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.default.build.zigbee_libs= sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator) sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +sparkfun_esp32s3_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -7970,13 +7967,10 @@ sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.default.build.zigbee_mode= sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.default.build.zigbee_libs= sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.ed=Zigbee ED (end device) sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +sparkfun_esp32c6_thing_plus.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -8563,13 +8557,10 @@ sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.default.build.zigbee_mode= sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.default.build.zigbee_libs= sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.ed=Zigbee ED (end device) sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +sparkfun_esp32c6_qwiic_pocket.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -11797,13 +11788,10 @@ dfrobot_beetle_esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= dfrobot_beetle_esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= dfrobot_beetle_esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) dfrobot_beetle_esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -dfrobot_beetle_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +dfrobot_beetle_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native dfrobot_beetle_esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) dfrobot_beetle_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -dfrobot_beetle_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -dfrobot_beetle_esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -dfrobot_beetle_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -dfrobot_beetle_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +dfrobot_beetle_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -12346,14 +12334,10 @@ dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port - +dfrobot_firebeetle2_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## # dfrobot Romeo ESP32-S3 @@ -12948,7 +12932,7 @@ adafruit_metro_esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_metro_esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_metro_esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_metro_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_metro_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_metro_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Metro ESP32-S3 @@ -13151,7 +13135,7 @@ adafruit_metro_esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_metro_esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_metro_esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_metro_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_metro_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_metro_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit MagTag 2.9" @@ -13334,7 +13318,7 @@ adafruit_magtag29_esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_magtag29_esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_magtag29_esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_magtag29_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_magtag29_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_magtag29_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit FunHouse @@ -13517,7 +13501,7 @@ adafruit_funhouse_esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_funhouse_esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_funhouse_esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_funhouse_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_funhouse_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_funhouse_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit ESP32 Feather @@ -13651,7 +13635,7 @@ featheresp32.menu.ZigbeeMode.default.build.zigbee_mode= featheresp32.menu.ZigbeeMode.default.build.zigbee_libs= featheresp32.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) featheresp32.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -featheresp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +featheresp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32 V2 @@ -13772,7 +13756,7 @@ adafruit_feather_esp32_v2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32_v2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32_v2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32_v2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32_v2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32_v2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S2 @@ -13955,7 +13939,7 @@ adafruit_feather_esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S2 TFT @@ -14138,7 +14122,7 @@ adafruit_feather_esp32s2_tft.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s2_tft.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s2_tft.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s2_tft.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s2_tft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s2_tft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S2 Reverse TFT @@ -14321,7 +14305,7 @@ adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s2_reversetft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S3 2MB PSRAM @@ -14539,7 +14523,7 @@ adafruit_feather_esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S3 No PSRAM @@ -14726,7 +14710,7 @@ adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S3 TFT @@ -14944,7 +14928,7 @@ adafruit_feather_esp32s3_tft.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s3_tft.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s3_tft.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s3_tft.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s3_tft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s3_tft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Feather ESP32-S3 Reverse TFT @@ -15162,7 +15146,7 @@ adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_feather_esp32s3_reversetft.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################# # Feather C6 @@ -15334,15 +15318,10 @@ adafruit_feather_esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_feather_esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_feather_esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) adafruit_feather_esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -adafruit_feather_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +adafruit_feather_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native adafruit_feather_esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_feather_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_feather_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -adafruit_feather_esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -adafruit_feather_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -adafruit_feather_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port - - +adafruit_feather_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## # Adafruit QT Py ESP32 @@ -15463,7 +15442,7 @@ adafruit_qtpy_esp32_pico.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qtpy_esp32_pico.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qtpy_esp32_pico.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qtpy_esp32_pico.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qtpy_esp32_pico.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qtpy_esp32_pico.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit QT Py ESP32-C3 @@ -15598,7 +15577,7 @@ adafruit_qtpy_esp32c3.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qtpy_esp32c3.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qtpy_esp32c3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qtpy_esp32c3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qtpy_esp32c3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qtpy_esp32c3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit QT Py ESP32-S2 @@ -15781,7 +15760,7 @@ adafruit_qtpy_esp32s2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qtpy_esp32s2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qtpy_esp32s2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qtpy_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qtpy_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qtpy_esp32s2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit QT Py ESP32-S3 No PSRAM @@ -15968,7 +15947,7 @@ adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qtpy_esp32s3_nopsram.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit QT Py ESP32-S3 (4M Flash 2M PSRAM) @@ -16186,7 +16165,7 @@ adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qtpy_esp32s3_n4r2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit ItsyBitsy ESP32 @@ -16304,7 +16283,7 @@ adafruit_itsybitsy_esp32.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_itsybitsy_esp32.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_itsybitsy_esp32.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_itsybitsy_esp32.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_itsybitsy_esp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_itsybitsy_esp32.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit MatrixPortal ESP32-S3 @@ -16501,7 +16480,7 @@ adafruit_matrixportal_esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_matrixportal_esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_matrixportal_esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_matrixportal_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_matrixportal_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_matrixportal_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit pyCamera S3 @@ -16719,7 +16698,7 @@ adafruit_camera_esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_camera_esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_camera_esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_camera_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_camera_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_camera_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Qualia ESP32-S3 RGB666 @@ -16922,7 +16901,7 @@ adafruit_qualia_s3_rgb666.menu.ZigbeeMode.default.build.zigbee_mode= adafruit_qualia_s3_rgb666.menu.ZigbeeMode.default.build.zigbee_libs= adafruit_qualia_s3_rgb666.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) adafruit_qualia_s3_rgb666.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -adafruit_qualia_s3_rgb666.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +adafruit_qualia_s3_rgb666.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Sparkle Motion w/ESP32 @@ -17056,7 +17035,7 @@ sparklemotion.menu.ZigbeeMode.default.build.zigbee_mode= sparklemotion.menu.ZigbeeMode.default.build.zigbee_libs= sparklemotion.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) sparklemotion.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -sparklemotion.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +sparklemotion.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## # Adafruit Sparkle Motion Mini w/ESP32 @@ -17190,7 +17169,7 @@ sparklemotionmini.menu.ZigbeeMode.default.build.zigbee_mode= sparklemotionmini.menu.ZigbeeMode.default.build.zigbee_libs= sparklemotionmini.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) sparklemotionmini.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -sparklemotionmini.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +sparklemotionmini.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -17644,7 +17623,7 @@ nologo_esp32s3_pico.menu.ZigbeeMode.default.build.zigbee_mode= nologo_esp32s3_pico.menu.ZigbeeMode.default.build.zigbee_libs= nologo_esp32s3_pico.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) nologo_esp32s3_pico.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -nologo_esp32s3_pico.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +nologo_esp32s3_pico.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -19577,13 +19556,10 @@ esp32c6-evb.menu.ZigbeeMode.default.build.zigbee_mode= esp32c6-evb.menu.ZigbeeMode.default.build.zigbee_libs= esp32c6-evb.menu.ZigbeeMode.ed=Zigbee ED (end device) esp32c6-evb.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32c6-evb.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +esp32c6-evb.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native esp32c6-evb.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32c6-evb.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32c6-evb.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -esp32c6-evb.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -esp32c6-evb.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32c6-evb.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +esp32c6-evb.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -19757,13 +19733,10 @@ esp32h2-devkitlipo.menu.ZigbeeMode.default.build.zigbee_mode= esp32h2-devkitlipo.menu.ZigbeeMode.default.build.zigbee_libs= esp32h2-devkitlipo.menu.ZigbeeMode.ed=Zigbee ED (end device) esp32h2-devkitlipo.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -esp32h2-devkitlipo.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +esp32h2-devkitlipo.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native esp32h2-devkitlipo.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32h2-devkitlipo.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32h2-devkitlipo.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -esp32h2-devkitlipo.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -esp32h2-devkitlipo.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -esp32h2-devkitlipo.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +esp32h2-devkitlipo.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -19954,7 +19927,7 @@ esp32-sbc-fabgl.menu.ZigbeeMode.default.build.zigbee_mode= esp32-sbc-fabgl.menu.ZigbeeMode.default.build.zigbee_libs= esp32-sbc-fabgl.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) esp32-sbc-fabgl.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -esp32-sbc-fabgl.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +esp32-sbc-fabgl.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -24628,13 +24601,10 @@ m5stack_nanoc6.menu.ZigbeeMode.default.build.zigbee_mode= m5stack_nanoc6.menu.ZigbeeMode.default.build.zigbee_libs= m5stack_nanoc6.menu.ZigbeeMode.ed=Zigbee ED (end device) m5stack_nanoc6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -m5stack_nanoc6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +m5stack_nanoc6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native m5stack_nanoc6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) m5stack_nanoc6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -m5stack_nanoc6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -m5stack_nanoc6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -m5stack_nanoc6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -m5stack_nanoc6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +m5stack_nanoc6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -35023,13 +34993,10 @@ XIAO_ESP32C6.menu.ZigbeeMode.default.build.zigbee_mode= XIAO_ESP32C6.menu.ZigbeeMode.default.build.zigbee_libs= XIAO_ESP32C6.menu.ZigbeeMode.ed=Zigbee ED (end device) XIAO_ESP32C6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -XIAO_ESP32C6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +XIAO_ESP32C6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native XIAO_ESP32C6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) XIAO_ESP32C6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -XIAO_ESP32C6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -XIAO_ESP32C6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -XIAO_ESP32C6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -XIAO_ESP32C6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +XIAO_ESP32C6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -35211,6 +35178,184 @@ XIAO_ESP32S3.menu.EraseFlash.all.upload.erase_cmd=-e ############################################################## +XIAO_ESP32S3_Plus.name=XIAO_ESP32S3_PLUS +XIAO_ESP32S3_Plus.vid.0=0x2886 +XIAO_ESP32S3_Plus.pid.0=0x0063 +XIAO_ESP32S3_Plus.vid.1=0x2886 +XIAO_ESP32S3_Plus.pid.1=0x8063 + +XIAO_ESP32S3_Plus.bootloader.tool=esptool_py +XIAO_ESP32S3_Plus.bootloader.tool.default=esptool_py + +XIAO_ESP32S3_Plus.upload.tool=esptool_py +XIAO_ESP32S3_Plus.upload.tool.default=esptool_py +XIAO_ESP32S3_Plus.upload.tool.network=esp_ota + +XIAO_ESP32S3_Plus.upload.maximum_size=1310720 +XIAO_ESP32S3_Plus.upload.maximum_data_size=327680 +XIAO_ESP32S3_Plus.upload.flags= +XIAO_ESP32S3_Plus.upload.extra_flags= +XIAO_ESP32S3_Plus.upload.use_1200bps_touch=false +XIAO_ESP32S3_Plus.upload.wait_for_upload_port=false + +XIAO_ESP32S3_Plus.serial.disableDTR=false +XIAO_ESP32S3_Plus.serial.disableRTS=false + +XIAO_ESP32S3_Plus.build.tarch=xtensa +XIAO_ESP32S3_Plus.build.bootloader_addr=0x0 +XIAO_ESP32S3_Plus.build.target=esp32s3 +XIAO_ESP32S3_Plus.build.mcu=esp32s3 +XIAO_ESP32S3_Plus.build.core=esp32 +XIAO_ESP32S3_Plus.build.variant=XIAO_ESP32S3_Plus +XIAO_ESP32S3_Plus.build.board=XIAO_ESP32S3_PLUS + +XIAO_ESP32S3_Plus.build.usb_mode=0 +XIAO_ESP32S3_Plus.build.cdc_on_boot=1 +XIAO_ESP32S3_Plus.build.msc_on_boot=0 +XIAO_ESP32S3_Plus.build.dfu_on_boot=0 +XIAO_ESP32S3_Plus.build.f_cpu=240000000L +XIAO_ESP32S3_Plus.build.flash_size=8MB +XIAO_ESP32S3_Plus.build.flash_freq=80m +XIAO_ESP32S3_Plus.build.flash_mode=dio +XIAO_ESP32S3_Plus.build.boot=qio +XIAO_ESP32S3_Plus.build.boot_freq=80m +XIAO_ESP32S3_Plus.build.partitions=default_8MB +XIAO_ESP32S3_Plus.build.defines= +XIAO_ESP32S3_Plus.build.loop_core= +XIAO_ESP32S3_Plus.build.event_core= +XIAO_ESP32S3_Plus.build.psram_type=qspi +XIAO_ESP32S3_Plus.build.memory_type={build.boot}_{build.psram_type} + +XIAO_ESP32S3_Plus.menu.JTAGAdapter.default=Disabled +XIAO_ESP32S3_Plus.menu.JTAGAdapter.default.build.copy_jtag_files=0 +XIAO_ESP32S3_Plus.menu.JTAGAdapter.builtin=Integrated USB JTAG +XIAO_ESP32S3_Plus.menu.JTAGAdapter.builtin.build.openocdscript=esp32s3-builtin.cfg +XIAO_ESP32S3_Plus.menu.JTAGAdapter.builtin.build.copy_jtag_files=1 +XIAO_ESP32S3_Plus.menu.JTAGAdapter.external=FTDI Adapter +XIAO_ESP32S3_Plus.menu.JTAGAdapter.external.build.openocdscript=esp32s3-ftdi.cfg +XIAO_ESP32S3_Plus.menu.JTAGAdapter.external.build.copy_jtag_files=1 +XIAO_ESP32S3_Plus.menu.JTAGAdapter.bridge=ESP USB Bridge +XIAO_ESP32S3_Plus.menu.JTAGAdapter.bridge.build.openocdscript=esp32s3-bridge.cfg +XIAO_ESP32S3_Plus.menu.JTAGAdapter.bridge.build.copy_jtag_files=1 + +XIAO_ESP32S3_Plus.menu.PSRAM.disabled=Disabled +XIAO_ESP32S3_Plus.menu.PSRAM.disabled.build.defines= +XIAO_ESP32S3_Plus.menu.PSRAM.disabled.build.psram_type=qspi +XIAO_ESP32S3_Plus.menu.PSRAM.opi=OPI PSRAM +XIAO_ESP32S3_Plus.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM +XIAO_ESP32S3_Plus.menu.PSRAM.opi.build.psram_type=opi + +XIAO_ESP32S3_Plus.menu.FlashMode.qio=QIO 80MHz +XIAO_ESP32S3_Plus.menu.FlashMode.qio.build.flash_mode=dio +XIAO_ESP32S3_Plus.menu.FlashMode.qio.build.boot=qio +XIAO_ESP32S3_Plus.menu.FlashMode.qio.build.boot_freq=80m +XIAO_ESP32S3_Plus.menu.FlashMode.qio.build.flash_freq=80m +XIAO_ESP32S3_Plus.menu.FlashMode.dio=DIO 80MHz +XIAO_ESP32S3_Plus.menu.FlashMode.dio.build.flash_mode=dio +XIAO_ESP32S3_Plus.menu.FlashMode.dio.build.boot=dio +XIAO_ESP32S3_Plus.menu.FlashMode.dio.build.boot_freq=80m +XIAO_ESP32S3_Plus.menu.FlashMode.dio.build.flash_freq=80m + +XIAO_ESP32S3_Plus.menu.FlashSize.8M=8MB (64Mb) +XIAO_ESP32S3_Plus.menu.FlashSize.8M.build.flash_size=8MB + +XIAO_ESP32S3_Plus.menu.LoopCore.1=Core 1 +XIAO_ESP32S3_Plus.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 +XIAO_ESP32S3_Plus.menu.LoopCore.0=Core 0 +XIAO_ESP32S3_Plus.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 + +XIAO_ESP32S3_Plus.menu.EventsCore.1=Core 1 +XIAO_ESP32S3_Plus.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 +XIAO_ESP32S3_Plus.menu.EventsCore.0=Core 0 +XIAO_ESP32S3_Plus.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 + +XIAO_ESP32S3_Plus.menu.USBMode.hwcdc=Hardware CDC and JTAG +XIAO_ESP32S3_Plus.menu.USBMode.hwcdc.build.usb_mode=1 +XIAO_ESP32S3_Plus.menu.USBMode.default=USB-OTG (TinyUSB) +XIAO_ESP32S3_Plus.menu.USBMode.default.build.usb_mode=0 + +XIAO_ESP32S3_Plus.menu.CDCOnBoot.default=Enabled +XIAO_ESP32S3_Plus.menu.CDCOnBoot.default.build.cdc_on_boot=1 +XIAO_ESP32S3_Plus.menu.CDCOnBoot.cdc=Disabled +XIAO_ESP32S3_Plus.menu.CDCOnBoot.cdc.build.cdc_on_boot=0 + +XIAO_ESP32S3_Plus.menu.MSCOnBoot.default=Disabled +XIAO_ESP32S3_Plus.menu.MSCOnBoot.default.build.msc_on_boot=0 +XIAO_ESP32S3_Plus.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) +XIAO_ESP32S3_Plus.menu.MSCOnBoot.msc.build.msc_on_boot=1 + +XIAO_ESP32S3_Plus.menu.DFUOnBoot.default=Disabled +XIAO_ESP32S3_Plus.menu.DFUOnBoot.default.build.dfu_on_boot=0 +XIAO_ESP32S3_Plus.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) +XIAO_ESP32S3_Plus.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 + +XIAO_ESP32S3_Plus.menu.UploadMode.default=UART0 / Hardware CDC +XIAO_ESP32S3_Plus.menu.UploadMode.default.upload.use_1200bps_touch=false +XIAO_ESP32S3_Plus.menu.UploadMode.default.upload.wait_for_upload_port=false +XIAO_ESP32S3_Plus.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) +XIAO_ESP32S3_Plus.menu.UploadMode.cdc.upload.use_1200bps_touch=true +XIAO_ESP32S3_Plus.menu.UploadMode.cdc.upload.wait_for_upload_port=true + +XIAO_ESP32S3_Plus.menu.PartitionScheme.default_8MB=Default with spiffs (3MB APP/1.5MB SPIFFS) +XIAO_ESP32S3_Plus.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +XIAO_ESP32S3_Plus.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +XIAO_ESP32S3_Plus.menu.PartitionScheme.max_app_8MB=Maximum APP (7.9MB APP No OTA/No FS) +XIAO_ESP32S3_Plus.menu.PartitionScheme.max_app_8MB.build.partitions=max_app_8MB +XIAO_ESP32S3_Plus.menu.PartitionScheme.max_app_8MB.upload.maximum_size=8257536 +XIAO_ESP32S3_Plus.menu.PartitionScheme.tinyuf2=TinyUF2 8MB (2MB APP/3.7MB FFAT) +XIAO_ESP32S3_Plus.menu.PartitionScheme.tinyuf2.build.custom_bootloader=bootloader-tinyuf2 +XIAO_ESP32S3_Plus.menu.PartitionScheme.tinyuf2.build.custom_partitions=partitions-8MB +XIAO_ESP32S3_Plus.menu.PartitionScheme.tinyuf2.upload.maximum_size=2097152 +XIAO_ESP32S3_Plus.menu.PartitionScheme.tinyuf2.upload.extra_flags=0x410000 "{runtime.platform.path}/variants/{build.variant}/tinyuf2.bin" + +XIAO_ESP32S3_Plus.menu.CPUFreq.240=240MHz (WiFi) +XIAO_ESP32S3_Plus.menu.CPUFreq.240.build.f_cpu=240000000L +XIAO_ESP32S3_Plus.menu.CPUFreq.160=160MHz (WiFi) +XIAO_ESP32S3_Plus.menu.CPUFreq.160.build.f_cpu=160000000L +XIAO_ESP32S3_Plus.menu.CPUFreq.80=80MHz (WiFi) +XIAO_ESP32S3_Plus.menu.CPUFreq.80.build.f_cpu=80000000L +XIAO_ESP32S3_Plus.menu.CPUFreq.40=40MHz +XIAO_ESP32S3_Plus.menu.CPUFreq.40.build.f_cpu=40000000L +XIAO_ESP32S3_Plus.menu.CPUFreq.20=20MHz +XIAO_ESP32S3_Plus.menu.CPUFreq.20.build.f_cpu=20000000L +XIAO_ESP32S3_Plus.menu.CPUFreq.10=10MHz +XIAO_ESP32S3_Plus.menu.CPUFreq.10.build.f_cpu=10000000L + +XIAO_ESP32S3_Plus.menu.UploadSpeed.921600=921600 +XIAO_ESP32S3_Plus.menu.UploadSpeed.921600.upload.speed=921600 +XIAO_ESP32S3_Plus.menu.UploadSpeed.115200=115200 +XIAO_ESP32S3_Plus.menu.UploadSpeed.115200.upload.speed=115200 +XIAO_ESP32S3_Plus.menu.UploadSpeed.256000.windows=256000 +XIAO_ESP32S3_Plus.menu.UploadSpeed.256000.upload.speed=256000 +XIAO_ESP32S3_Plus.menu.UploadSpeed.230400.windows.upload.speed=256000 +XIAO_ESP32S3_Plus.menu.UploadSpeed.230400=230400 +XIAO_ESP32S3_Plus.menu.UploadSpeed.230400.upload.speed=230400 +XIAO_ESP32S3_Plus.menu.UploadSpeed.460800.linux=460800 +XIAO_ESP32S3_Plus.menu.UploadSpeed.460800.macosx=460800 +XIAO_ESP32S3_Plus.menu.UploadSpeed.460800.upload.speed=460800 +XIAO_ESP32S3_Plus.menu.UploadSpeed.512000.windows=512000 +XIAO_ESP32S3_Plus.menu.UploadSpeed.512000.upload.speed=512000 + +XIAO_ESP32S3_Plus.menu.DebugLevel.none=None +XIAO_ESP32S3_Plus.menu.DebugLevel.none.build.code_debug=0 +XIAO_ESP32S3_Plus.menu.DebugLevel.error=Error +XIAO_ESP32S3_Plus.menu.DebugLevel.error.build.code_debug=1 +XIAO_ESP32S3_Plus.menu.DebugLevel.warn=Warn +XIAO_ESP32S3_Plus.menu.DebugLevel.warn.build.code_debug=2 +XIAO_ESP32S3_Plus.menu.DebugLevel.info=Info +XIAO_ESP32S3_Plus.menu.DebugLevel.info.build.code_debug=3 +XIAO_ESP32S3_Plus.menu.DebugLevel.debug=Debug +XIAO_ESP32S3_Plus.menu.DebugLevel.debug.build.code_debug=4 +XIAO_ESP32S3_Plus.menu.DebugLevel.verbose=Verbose +XIAO_ESP32S3_Plus.menu.DebugLevel.verbose.build.code_debug=5 + +XIAO_ESP32S3_Plus.menu.EraseFlash.none=Disabled +XIAO_ESP32S3_Plus.menu.EraseFlash.none.upload.erase_cmd= +XIAO_ESP32S3_Plus.menu.EraseFlash.all=Enabled +XIAO_ESP32S3_Plus.menu.EraseFlash.all.upload.erase_cmd=-e + +############################################################## + connaxio_espoir.name=Connaxio's Espoir connaxio_espoir.vid.0=0x10C4 connaxio_espoir.pid.0=0x8D9A @@ -39384,13 +39529,10 @@ ioxesp32c6.menu.ZigbeeMode.default.build.zigbee_mode= ioxesp32c6.menu.ZigbeeMode.default.build.zigbee_libs= ioxesp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) ioxesp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -ioxesp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +ioxesp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native ioxesp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator) ioxesp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -ioxesp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -ioxesp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -ioxesp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -ioxesp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +ioxesp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## # ATD1.47-S3 @@ -40568,13 +40710,10 @@ epulse_feather_c6.menu.ZigbeeMode.default.build.zigbee_mode= epulse_feather_c6.menu.ZigbeeMode.default.build.zigbee_libs= epulse_feather_c6.menu.ZigbeeMode.ed=Zigbee ED (end device) epulse_feather_c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -epulse_feather_c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +epulse_feather_c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native epulse_feather_c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) epulse_feather_c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -epulse_feather_c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -epulse_feather_c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -epulse_feather_c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -epulse_feather_c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +epulse_feather_c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -40705,6 +40844,196 @@ Geekble_ESP32C3.menu.EraseFlash.none.upload.erase_cmd= Geekble_ESP32C3.menu.EraseFlash.all=Enabled Geekble_ESP32C3.menu.EraseFlash.all.upload.erase_cmd=-e +############################################################## + +Geekble_Nano_ESP32S3.name=Geekble nano ESP32-S3 +Geekble_Nano_ESP32S3.vid.0=0x303a +Geekble_Nano_ESP32S3.pid.0= 0x82C5 +Geekble_Nano_ESP32S3.upload_port.0.vid=0x303a +Geekble_Nano_ESP32S3.upload_port.0.pid= 0x82C5 + +Geekble_Nano_ESP32S3.bootloader.tool=esptool_py +Geekble_Nano_ESP32S3.bootloader.tool.default=esptool_py + +Geekble_Nano_ESP32S3.upload.tool=esptool_py +Geekble_Nano_ESP32S3.upload.tool.default=esptool_py +Geekble_Nano_ESP32S3.upload.tool.network=esp_ota + +Geekble_Nano_ESP32S3.upload.maximum_size=1310720 + +Geekble_Nano_ESP32S3.upload.maximum_data_size=327680 +Geekble_Nano_ESP32S3.upload.flags= +Geekble_Nano_ESP32S3.upload.extra_flags= +Geekble_Nano_ESP32S3.upload.use_1200bps_touch=false +Geekble_Nano_ESP32S3.upload.wait_for_upload_port=false + +Geekble_Nano_ESP32S3.serial.disableDTR=false +Geekble_Nano_ESP32S3.serial.disableRTS=false + +Geekble_Nano_ESP32S3.build.tarch=xtensa +Geekble_Nano_ESP32S3.build.bootloader_addr=0x0 +Geekble_Nano_ESP32S3.build.target=esp32s3 +Geekble_Nano_ESP32S3.build.mcu=esp32s3 +Geekble_Nano_ESP32S3.build.core=esp32 +Geekble_Nano_ESP32S3.build.variant=Geekble_Nano_ESP32S3 +Geekble_Nano_ESP32S3.build.board=GEEKBLE_NANO_ESP32S3 + +Geekble_Nano_ESP32S3.build.usb_mode=1 +Geekble_Nano_ESP32S3.build.cdc_on_boot=1 +Geekble_Nano_ESP32S3.build.msc_on_boot=0 +Geekble_Nano_ESP32S3.build.dfu_on_boot=0 +Geekble_Nano_ESP32S3.build.f_cpu=240000000L +Geekble_Nano_ESP32S3.build.flash_size=4MB +Geekble_Nano_ESP32S3.build.flash_freq=80m +Geekble_Nano_ESP32S3.build.flash_mode=dio +Geekble_Nano_ESP32S3.build.boot=qio +Geekble_Nano_ESP32S3.build.boot_freq=80m +Geekble_Nano_ESP32S3.build.partitions=default +Geekble_Nano_ESP32S3.build.defines= +Geekble_Nano_ESP32S3.build.loop_core= +Geekble_Nano_ESP32S3.build.event_core= +Geekble_Nano_ESP32S3.build.psram_type=qspi +Geekble_Nano_ESP32S3.build.memory_type={build.boot}_{build.psram_type} + +Geekble_Nano_ESP32S3.menu.PSRAM.disabled=Disabled +Geekble_Nano_ESP32S3.menu.PSRAM.disabled.build.defines= +Geekble_Nano_ESP32S3.menu.PSRAM.disabled.build.psram_type=qspi +Geekble_Nano_ESP32S3.menu.PSRAM.enabled=Enabled +Geekble_Nano_ESP32S3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM +Geekble_Nano_ESP32S3.menu.PSRAM.enabled.build.psram_type=qspi + +Geekble_Nano_ESP32S3.menu.FlashMode.qio=QIO 80MHz +Geekble_Nano_ESP32S3.menu.FlashMode.qio.build.flash_mode=dio +Geekble_Nano_ESP32S3.menu.FlashMode.qio.build.boot=qio +Geekble_Nano_ESP32S3.menu.FlashMode.qio.build.boot_freq=80m +Geekble_Nano_ESP32S3.menu.FlashMode.qio.build.flash_freq=80m +Geekble_Nano_ESP32S3.menu.FlashMode.qio120=QIO 120MHz +Geekble_Nano_ESP32S3.menu.FlashMode.qio120.build.flash_mode=dio +Geekble_Nano_ESP32S3.menu.FlashMode.qio120.build.boot=qio +Geekble_Nano_ESP32S3.menu.FlashMode.qio120.build.boot_freq=120m +Geekble_Nano_ESP32S3.menu.FlashMode.qio120.build.flash_freq=80m + +Geekble_Nano_ESP32S3.menu.LoopCore.1=Core 1 +Geekble_Nano_ESP32S3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 +Geekble_Nano_ESP32S3.menu.LoopCore.0=Core 0 +Geekble_Nano_ESP32S3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 + +Geekble_Nano_ESP32S3.menu.EventsCore.1=Core 1 +Geekble_Nano_ESP32S3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 +Geekble_Nano_ESP32S3.menu.EventsCore.0=Core 0 +Geekble_Nano_ESP32S3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 + +Geekble_Nano_ESP32S3.menu.USBMode.hwcdc=Hardware CDC and JTAG +Geekble_Nano_ESP32S3.menu.USBMode.hwcdc.build.usb_mode=1 +Geekble_Nano_ESP32S3.menu.USBMode.default=USB-OTG (TinyUSB) +Geekble_Nano_ESP32S3.menu.USBMode.default.build.usb_mode=0 + +Geekble_Nano_ESP32S3.menu.CDCOnBoot.default=Disabled +Geekble_Nano_ESP32S3.menu.CDCOnBoot.default.build.cdc_on_boot=0 +Geekble_Nano_ESP32S3.menu.CDCOnBoot.cdc=Enabled +Geekble_Nano_ESP32S3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 + +Geekble_Nano_ESP32S3.menu.MSCOnBoot.default=Disabled +Geekble_Nano_ESP32S3.menu.MSCOnBoot.default.build.msc_on_boot=0 +Geekble_Nano_ESP32S3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) +Geekble_Nano_ESP32S3.menu.MSCOnBoot.msc.build.msc_on_boot=1 + +Geekble_Nano_ESP32S3.menu.DFUOnBoot.default=Disabled +Geekble_Nano_ESP32S3.menu.DFUOnBoot.default.build.dfu_on_boot=0 +Geekble_Nano_ESP32S3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) +Geekble_Nano_ESP32S3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 + +Geekble_Nano_ESP32S3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) +Geekble_Nano_ESP32S3.menu.UploadMode.cdc.upload.use_1200bps_touch=true +Geekble_Nano_ESP32S3.menu.UploadMode.cdc.upload.wait_for_upload_port=true + +Geekble_Nano_ESP32S3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.default.build.partitions=default +Geekble_Nano_ESP32S3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +Geekble_Nano_ESP32S3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.no_ota.build.partitions=no_ota +Geekble_Nano_ESP32S3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +Geekble_Nano_ESP32S3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +Geekble_Nano_ESP32S3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.huge_app.build.partitions=huge_app +Geekble_Nano_ESP32S3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +Geekble_Nano_ESP32S3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +Geekble_Nano_ESP32S3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +Geekble_Nano_ESP32S3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker=RainMaker 4MB +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080 +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker_4MB=RainMaker 4MB No OTA +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker_4MB.build.partitions=rainmaker_4MB_no_ota +Geekble_Nano_ESP32S3.menu.PartitionScheme.rainmaker_4MB.upload.maximum_size=4038656 + +Geekble_Nano_ESP32S3.menu.PartitionScheme.otanofs=OTA no FS (2MB APP with OTA) +Geekble_Nano_ESP32S3.menu.PartitionScheme.otanofs.build.custom_partitions=ota_nofs_4MB +Geekble_Nano_ESP32S3.menu.PartitionScheme.otanofs.upload.maximum_size=2031616 +Geekble_Nano_ESP32S3.menu.PartitionScheme.all_app=Max APP (4MB APP no OTA) +Geekble_Nano_ESP32S3.menu.PartitionScheme.all_app.build.custom_partitions=max_app_4MB +Geekble_Nano_ESP32S3.menu.PartitionScheme.all_app.upload.maximum_size=4063232 + +Geekble_Nano_ESP32S3.menu.PartitionScheme.custom=Custom +Geekble_Nano_ESP32S3.menu.PartitionScheme.custom.build.partitions= +Geekble_Nano_ESP32S3.menu.PartitionScheme.custom.upload.maximum_size=16777216 + +Geekble_Nano_ESP32S3.menu.CPUFreq.240=240MHz (WiFi) +Geekble_Nano_ESP32S3.menu.CPUFreq.240.build.f_cpu=240000000L +Geekble_Nano_ESP32S3.menu.CPUFreq.160=160MHz (WiFi) +Geekble_Nano_ESP32S3.menu.CPUFreq.160.build.f_cpu=160000000L +Geekble_Nano_ESP32S3.menu.CPUFreq.80=80MHz (WiFi) +Geekble_Nano_ESP32S3.menu.CPUFreq.80.build.f_cpu=80000000L +Geekble_Nano_ESP32S3.menu.CPUFreq.40=40MHz +Geekble_Nano_ESP32S3.menu.CPUFreq.40.build.f_cpu=40000000L +Geekble_Nano_ESP32S3.menu.CPUFreq.20=20MHz +Geekble_Nano_ESP32S3.menu.CPUFreq.20.build.f_cpu=20000000L +Geekble_Nano_ESP32S3.menu.CPUFreq.10=10MHz +Geekble_Nano_ESP32S3.menu.CPUFreq.10.build.f_cpu=10000000L + +Geekble_Nano_ESP32S3.menu.UploadSpeed.921600=921600 +Geekble_Nano_ESP32S3.menu.UploadSpeed.921600.upload.speed=921600 +Geekble_Nano_ESP32S3.menu.UploadSpeed.115200=115200 +Geekble_Nano_ESP32S3.menu.UploadSpeed.115200.upload.speed=115200 +Geekble_Nano_ESP32S3.menu.UploadSpeed.256000.windows=256000 +Geekble_Nano_ESP32S3.menu.UploadSpeed.256000.upload.speed=256000 +Geekble_Nano_ESP32S3.menu.UploadSpeed.230400.windows.upload.speed=256000 +Geekble_Nano_ESP32S3.menu.UploadSpeed.230400=230400 +Geekble_Nano_ESP32S3.menu.UploadSpeed.230400.upload.speed=230400 +Geekble_Nano_ESP32S3.menu.UploadSpeed.460800.linux=460800 +Geekble_Nano_ESP32S3.menu.UploadSpeed.460800.macosx=460800 +Geekble_Nano_ESP32S3.menu.UploadSpeed.460800.upload.speed=460800 +Geekble_Nano_ESP32S3.menu.UploadSpeed.512000.windows=512000 +Geekble_Nano_ESP32S3.menu.UploadSpeed.512000.upload.speed=512000 + +Geekble_Nano_ESP32S3.menu.DebugLevel.none=None +Geekble_Nano_ESP32S3.menu.DebugLevel.none.build.code_debug=0 +Geekble_Nano_ESP32S3.menu.DebugLevel.error=Error +Geekble_Nano_ESP32S3.menu.DebugLevel.error.build.code_debug=1 +Geekble_Nano_ESP32S3.menu.DebugLevel.warn=Warn +Geekble_Nano_ESP32S3.menu.DebugLevel.warn.build.code_debug=2 +Geekble_Nano_ESP32S3.menu.DebugLevel.info=Info +Geekble_Nano_ESP32S3.menu.DebugLevel.info.build.code_debug=3 +Geekble_Nano_ESP32S3.menu.DebugLevel.debug=Debug +Geekble_Nano_ESP32S3.menu.DebugLevel.debug.build.code_debug=4 +Geekble_Nano_ESP32S3.menu.DebugLevel.verbose=Verbose +Geekble_Nano_ESP32S3.menu.DebugLevel.verbose.build.code_debug=5 + +Geekble_Nano_ESP32S3.menu.EraseFlash.none=Disabled +Geekble_Nano_ESP32S3.menu.EraseFlash.none.upload.erase_cmd= +Geekble_Nano_ESP32S3.menu.EraseFlash.all=Enabled +Geekble_Nano_ESP32S3.menu.EraseFlash.all.upload.erase_cmd=-e + + ############################################################## waveshare_esp32_s3_zero.name=Waveshare ESP32-S3-Zero @@ -43052,7 +43381,7 @@ jczn_2432s028r.menu.ZigbeeMode.default.build.zigbee_mode= jczn_2432s028r.menu.ZigbeeMode.default.build.zigbee_libs= jczn_2432s028r.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) jczn_2432s028r.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -jczn_2432s028r.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +jczn_2432s028r.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -44695,7 +45024,7 @@ waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_touch_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -44862,13 +45191,10 @@ cezerio_dev_esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= cezerio_dev_esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= cezerio_dev_esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) cezerio_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -cezerio_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +cezerio_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native cezerio_dev_esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator) cezerio_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -cezerio_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -cezerio_dev_esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -cezerio_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -cezerio_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +cezerio_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -45035,13 +45361,10 @@ cezerio_mini_dev_esp32c6.menu.ZigbeeMode.default.build.zigbee_mode= cezerio_mini_dev_esp32c6.menu.ZigbeeMode.default.build.zigbee_libs= cezerio_mini_dev_esp32c6.menu.ZigbeeMode.ed=Zigbee ED (end device) cezerio_mini_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -cezerio_mini_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +cezerio_mini_dev_esp32c6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native cezerio_mini_dev_esp32c6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator) cezerio_mini_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -cezerio_mini_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -cezerio_mini_dev_esp32c6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -cezerio_mini_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -cezerio_mini_dev_esp32c6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +cezerio_mini_dev_esp32c6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -45278,7 +45601,7 @@ waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_lcd_185.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -45515,7 +45838,7 @@ waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_touch_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -45752,7 +46075,7 @@ waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_lcd_146.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -45989,7 +46312,7 @@ waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_touch_lcd_185_box.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -46226,7 +46549,7 @@ waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_lcd_147.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -46463,7 +46786,7 @@ waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_touch_lcd_21.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -46700,7 +47023,7 @@ waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_touch_lcd_28.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -46940,7 +47263,7 @@ waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.default.build.zigbee_mode= waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.default.build.zigbee_libs= waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port +waveshare_esp32_s3_relay_6ch.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote ############################################################## @@ -47839,17 +48162,13 @@ Pcbcupid_GLYPH_H2.menu.ZigbeeMode.default.build.zigbee_mode= Pcbcupid_GLYPH_H2.menu.ZigbeeMode.default.build.zigbee_libs= Pcbcupid_GLYPH_H2.menu.ZigbeeMode.ed=Zigbee ED (end device) Pcbcupid_GLYPH_H2.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -Pcbcupid_GLYPH_H2.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +Pcbcupid_GLYPH_H2.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native Pcbcupid_GLYPH_H2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) Pcbcupid_GLYPH_H2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -Pcbcupid_GLYPH_H2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -Pcbcupid_GLYPH_H2.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -Pcbcupid_GLYPH_H2.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -Pcbcupid_GLYPH_H2.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +Pcbcupid_GLYPH_H2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## - Pcbcupid_GLYPH_C6.name=Pcbcupid GLYPH C6 Pcbcupid_GLYPH_C6.bootloader.tool=esptool_py @@ -47994,13 +48313,10 @@ Pcbcupid_GLYPH_C6.menu.ZigbeeMode.default.build.zigbee_mode= Pcbcupid_GLYPH_C6.menu.ZigbeeMode.default.build.zigbee_libs= Pcbcupid_GLYPH_C6.menu.ZigbeeMode.ed=Zigbee ED (end device) Pcbcupid_GLYPH_C6.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED -Pcbcupid_GLYPH_C6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port +Pcbcupid_GLYPH_C6.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api.ed -lzboss_stack.ed -lzboss_port.native Pcbcupid_GLYPH_C6.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) Pcbcupid_GLYPH_C6.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR -Pcbcupid_GLYPH_C6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port -Pcbcupid_GLYPH_C6.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor) -Pcbcupid_GLYPH_C6.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP -Pcbcupid_GLYPH_C6.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port +Pcbcupid_GLYPH_C6.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.native ############################################################## @@ -48745,20 +49061,6 @@ huidu_hd_wf2.menu.CPUFreq.80.build.f_cpu=80000000L huidu_hd_wf2.menu.CPUFreq.40=40MHz huidu_hd_wf2.menu.CPUFreq.40.build.f_cpu=40000000L -huidu_hd_wf2.menu.PSRAM.enabled=QSPI Flash fix -huidu_hd_wf2.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -huidu_hd_wf2.menu.PSRAM.enabled.build.psram_type=qspi - -huidu_hd_wf2.menu.FlashMode.qio=QIO 80MHz -huidu_hd_wf2.menu.FlashMode.qio.build.flash_mode=dio -huidu_hd_wf2.menu.FlashMode.qio.build.boot=qio -huidu_hd_wf2.menu.FlashMode.qio.build.boot_freq=80m -huidu_hd_wf2.menu.FlashMode.qio.build.flash_freq=80m -huidu_hd_wf2.menu.FlashMode.qio120=QIO 120MHz -huidu_hd_wf2.menu.FlashMode.qio120.build.flash_mode=dio -huidu_hd_wf2.menu.FlashMode.qio120.build.boot=qio -huidu_hd_wf2.menu.FlashMode.qio120.build.boot_freq=120m -huidu_hd_wf2.menu.FlashMode.qio120.build.flash_freq=80m huidu_hd_wf2.menu.FlashMode.dio=DIO 80MHz huidu_hd_wf2.menu.FlashMode.dio.build.flash_mode=dio huidu_hd_wf2.menu.FlashMode.dio.build.boot=dio @@ -48898,20 +49200,6 @@ huidu_hd_wf4.menu.CPUFreq.80.build.f_cpu=80000000L huidu_hd_wf4.menu.CPUFreq.40=40MHz huidu_hd_wf4.menu.CPUFreq.40.build.f_cpu=40000000L -huidu_hd_wf4.menu.PSRAM.enabled=QSPI Flash fix -huidu_hd_wf4.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -huidu_hd_wf4.menu.PSRAM.enabled.build.psram_type=qspi - -huidu_hd_wf4.menu.FlashMode.qio=QIO 80MHz -huidu_hd_wf4.menu.FlashMode.qio.build.flash_mode=dio -huidu_hd_wf4.menu.FlashMode.qio.build.boot=qio -huidu_hd_wf4.menu.FlashMode.qio.build.boot_freq=80m -huidu_hd_wf4.menu.FlashMode.qio.build.flash_freq=80m -huidu_hd_wf4.menu.FlashMode.qio120=QIO 120MHz -huidu_hd_wf4.menu.FlashMode.qio120.build.flash_mode=dio -huidu_hd_wf4.menu.FlashMode.qio120.build.boot=qio -huidu_hd_wf4.menu.FlashMode.qio120.build.boot_freq=120m -huidu_hd_wf4.menu.FlashMode.qio120.build.flash_freq=80m huidu_hd_wf4.menu.FlashMode.dio=DIO 80MHz huidu_hd_wf4.menu.FlashMode.dio.build.flash_mode=dio huidu_hd_wf4.menu.FlashMode.dio.build.boot=dio @@ -48945,3 +49233,255 @@ huidu_hd_wf4.menu.EraseFlash.all=Enabled huidu_hd_wf4.menu.EraseFlash.all.upload.erase_cmd=-e ############################################################## + +# CYOBot (CYOBrain V2 ESP32S3) Board +cyobot_v2_esp32s3.name=CYOBOT V2 ESP32S3 + +cyobot_v2_esp32s3.bootloader.tool=esptool_py +cyobot_v2_esp32s3.bootloader.tool.default=esptool_py + +cyobot_v2_esp32s3.upload.tool=esptool_py +cyobot_v2_esp32s3.upload.tool.default=esptool_py +cyobot_v2_esp32s3.upload.tool.network=esp_ota + +cyobot_v2_esp32s3.upload.maximum_size=1310720 +cyobot_v2_esp32s3.upload.maximum_data_size=327680 +cyobot_v2_esp32s3.upload.flags= +cyobot_v2_esp32s3.upload.extra_flags= +cyobot_v2_esp32s3.upload.use_1200bps_touch=false +cyobot_v2_esp32s3.upload.wait_for_upload_port=false + +cyobot_v2_esp32s3.serial.disableDTR=false +cyobot_v2_esp32s3.serial.disableRTS=false + +cyobot_v2_esp32s3.build.tarch=xtensa +cyobot_v2_esp32s3.build.bootloader_addr=0x0 +cyobot_v2_esp32s3.build.target=esp32s3 +cyobot_v2_esp32s3.build.mcu=esp32s3 +cyobot_v2_esp32s3.build.core=esp32 +cyobot_v2_esp32s3.build.variant=cyobot_v2_esp32s3 +cyobot_v2_esp32s3.build.board=CYOBOT_V2_ESP32S3 + +cyobot_v2_esp32s3.build.usb_mode=1 +cyobot_v2_esp32s3.build.cdc_on_boot=0 +cyobot_v2_esp32s3.build.msc_on_boot=0 +cyobot_v2_esp32s3.build.dfu_on_boot=0 +cyobot_v2_esp32s3.build.f_cpu=240000000L +cyobot_v2_esp32s3.build.flash_size=4MB +cyobot_v2_esp32s3.build.flash_freq=80m +cyobot_v2_esp32s3.build.flash_mode=dio +cyobot_v2_esp32s3.build.boot=qio +cyobot_v2_esp32s3.build.boot_freq=80m +cyobot_v2_esp32s3.build.partitions=default +cyobot_v2_esp32s3.build.defines= +cyobot_v2_esp32s3.build.loop_core= +cyobot_v2_esp32s3.build.event_core= +cyobot_v2_esp32s3.build.psram_type=qspi +cyobot_v2_esp32s3.build.memory_type={build.boot}_{build.psram_type} + +## IDE 2.0 Seems to not update the value +cyobot_v2_esp32s3.menu.JTAGAdapter.default=Disabled +cyobot_v2_esp32s3.menu.JTAGAdapter.default.build.copy_jtag_files=0 +cyobot_v2_esp32s3.menu.JTAGAdapter.builtin=Integrated USB JTAG +cyobot_v2_esp32s3.menu.JTAGAdapter.builtin.build.openocdscript=cyobot_v2_esp32s3-builtin.cfg +cyobot_v2_esp32s3.menu.JTAGAdapter.builtin.build.copy_jtag_files=1 +cyobot_v2_esp32s3.menu.JTAGAdapter.external=FTDI Adapter +cyobot_v2_esp32s3.menu.JTAGAdapter.external.build.openocdscript=cyobot_v2_esp32s3-ftdi.cfg +cyobot_v2_esp32s3.menu.JTAGAdapter.external.build.copy_jtag_files=1 +cyobot_v2_esp32s3.menu.JTAGAdapter.bridge=ESP USB Bridge +cyobot_v2_esp32s3.menu.JTAGAdapter.bridge.build.openocdscript=cyobot_v2_esp32s3-bridge.cfg +cyobot_v2_esp32s3.menu.JTAGAdapter.bridge.build.copy_jtag_files=1 + +cyobot_v2_esp32s3.menu.PSRAM.disabled=Disabled +cyobot_v2_esp32s3.menu.PSRAM.disabled.build.defines= +cyobot_v2_esp32s3.menu.PSRAM.disabled.build.psram_type=qspi +cyobot_v2_esp32s3.menu.PSRAM.enabled=QSPI PSRAM +cyobot_v2_esp32s3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM +cyobot_v2_esp32s3.menu.PSRAM.enabled.build.psram_type=qspi +cyobot_v2_esp32s3.menu.PSRAM.opi=OPI PSRAM +cyobot_v2_esp32s3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM +cyobot_v2_esp32s3.menu.PSRAM.opi.build.psram_type=opi + +cyobot_v2_esp32s3.menu.FlashMode.qio=QIO 80MHz +cyobot_v2_esp32s3.menu.FlashMode.qio.build.flash_mode=dio +cyobot_v2_esp32s3.menu.FlashMode.qio.build.boot=qio +cyobot_v2_esp32s3.menu.FlashMode.qio.build.boot_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.qio.build.flash_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.qio120=QIO 120MHz +cyobot_v2_esp32s3.menu.FlashMode.qio120.build.flash_mode=dio +cyobot_v2_esp32s3.menu.FlashMode.qio120.build.boot=qio +cyobot_v2_esp32s3.menu.FlashMode.qio120.build.boot_freq=120m +cyobot_v2_esp32s3.menu.FlashMode.qio120.build.flash_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.dio=DIO 80MHz +cyobot_v2_esp32s3.menu.FlashMode.dio.build.flash_mode=dio +cyobot_v2_esp32s3.menu.FlashMode.dio.build.boot=dio +cyobot_v2_esp32s3.menu.FlashMode.dio.build.boot_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.dio.build.flash_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.opi=OPI 80MHz +cyobot_v2_esp32s3.menu.FlashMode.opi.build.flash_mode=dout +cyobot_v2_esp32s3.menu.FlashMode.opi.build.boot=opi +cyobot_v2_esp32s3.menu.FlashMode.opi.build.boot_freq=80m +cyobot_v2_esp32s3.menu.FlashMode.opi.build.flash_freq=80m + +cyobot_v2_esp32s3.menu.FlashSize.4M=4MB (32Mb) +cyobot_v2_esp32s3.menu.FlashSize.4M.build.flash_size=4MB +cyobot_v2_esp32s3.menu.FlashSize.8M=8MB (64Mb) +cyobot_v2_esp32s3.menu.FlashSize.8M.build.flash_size=8MB +cyobot_v2_esp32s3.menu.FlashSize.16M=16MB (128Mb) +cyobot_v2_esp32s3.menu.FlashSize.16M.build.flash_size=16MB +cyobot_v2_esp32s3.menu.FlashSize.32M=32MB (256Mb) +cyobot_v2_esp32s3.menu.FlashSize.32M.build.flash_size=32MB + +cyobot_v2_esp32s3.menu.LoopCore.1=Core 1 +cyobot_v2_esp32s3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1 +cyobot_v2_esp32s3.menu.LoopCore.0=Core 0 +cyobot_v2_esp32s3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0 + +cyobot_v2_esp32s3.menu.EventsCore.1=Core 1 +cyobot_v2_esp32s3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1 +cyobot_v2_esp32s3.menu.EventsCore.0=Core 0 +cyobot_v2_esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0 + +cyobot_v2_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG +cyobot_v2_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1 +cyobot_v2_esp32s3.menu.USBMode.default=USB-OTG (TinyUSB) +cyobot_v2_esp32s3.menu.USBMode.default.build.usb_mode=0 + +cyobot_v2_esp32s3.menu.CDCOnBoot.default=Disabled +cyobot_v2_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0 +cyobot_v2_esp32s3.menu.CDCOnBoot.cdc=Enabled +cyobot_v2_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1 + +cyobot_v2_esp32s3.menu.MSCOnBoot.default=Disabled +cyobot_v2_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0 +cyobot_v2_esp32s3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode) +cyobot_v2_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1 + +cyobot_v2_esp32s3.menu.DFUOnBoot.default=Disabled +cyobot_v2_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0 +cyobot_v2_esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode) +cyobot_v2_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1 + +cyobot_v2_esp32s3.menu.UploadMode.default=UART0 / Hardware CDC +cyobot_v2_esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false +cyobot_v2_esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false +cyobot_v2_esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB) +cyobot_v2_esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true +cyobot_v2_esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true + +cyobot_v2_esp32s3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.default.build.partitions=default +cyobot_v2_esp32s3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +cyobot_v2_esp32s3.menu.PartitionScheme.default_8MB=8M with spiffs (3MB APP/1.5MB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB +cyobot_v2_esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336 +cyobot_v2_esp32s3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.minimal.build.partitions=minimal +cyobot_v2_esp32s3.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2) +cyobot_v2_esp32s3.menu.PartitionScheme.no_fs.build.partitions=no_fs +cyobot_v2_esp32s3.menu.PartitionScheme.no_fs.upload.maximum_size=2031616 +cyobot_v2_esp32s3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.no_ota.build.partitions=no_ota +cyobot_v2_esp32s3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152 +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576 +cyobot_v2_esp32s3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat +cyobot_v2_esp32s3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152 +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat +cyobot_v2_esp32s3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576 +cyobot_v2_esp32s3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.huge_app.build.partitions=huge_app +cyobot_v2_esp32s3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728 +cyobot_v2_esp32s3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) +cyobot_v2_esp32s3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +cyobot_v2_esp32s3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +cyobot_v2_esp32s3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.fatflash.build.partitions=ffat +cyobot_v2_esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 +cyobot_v2_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB +cyobot_v2_esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker=RainMaker 4MB +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080 +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_4MB=RainMaker 4MB No OTA +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_4MB.build.partitions=rainmaker_4MB_no_ota +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_4MB.upload.maximum_size=4038656 +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_8MB=RainMaker 8MB +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_8MB.build.partitions=rainmaker_8MB +cyobot_v2_esp32s3.menu.PartitionScheme.rainmaker_8MB.upload.maximum_size=4116480 +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_fat24M_32MB=32M Flash (4.8MB APP/22MB FATFS) +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_fat24M_32MB.build.partitions=large_fat_32MB +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_fat24M_32MB.upload.maximum_size=4718592 +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_little24M_32MB=32M Flash (4.8MB APP/22MB LittleFS) +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_little24M_32MB.build.partitions=large_littlefs_32MB +cyobot_v2_esp32s3.menu.PartitionScheme.app5M_little24M_32MB.upload.maximum_size=4718592 +cyobot_v2_esp32s3.menu.PartitionScheme.esp_sr_16=ESP SR 16M (3MB APP/7MB SPIFFS/2.9MB MODEL) +cyobot_v2_esp32s3.menu.PartitionScheme.esp_sr_16.upload.maximum_size=3145728 +cyobot_v2_esp32s3.menu.PartitionScheme.esp_sr_16.upload.extra_flags=0xD10000 {build.path}/srmodels.bin +cyobot_v2_esp32s3.menu.PartitionScheme.esp_sr_16.build.partitions=esp_sr_16 +cyobot_v2_esp32s3.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs +cyobot_v2_esp32s3.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr +cyobot_v2_esp32s3.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720 +cyobot_v2_esp32s3.menu.PartitionScheme.custom=Custom +cyobot_v2_esp32s3.menu.PartitionScheme.custom.build.partitions= +cyobot_v2_esp32s3.menu.PartitionScheme.custom.upload.maximum_size=16777216 + +cyobot_v2_esp32s3.menu.CPUFreq.240=240MHz (WiFi) +cyobot_v2_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L +cyobot_v2_esp32s3.menu.CPUFreq.160=160MHz (WiFi) +cyobot_v2_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L +cyobot_v2_esp32s3.menu.CPUFreq.80=80MHz (WiFi) +cyobot_v2_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L +cyobot_v2_esp32s3.menu.CPUFreq.40=40MHz +cyobot_v2_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L +cyobot_v2_esp32s3.menu.CPUFreq.20=20MHz +cyobot_v2_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L +cyobot_v2_esp32s3.menu.CPUFreq.10=10MHz +cyobot_v2_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L + +cyobot_v2_esp32s3.menu.UploadSpeed.921600=921600 +cyobot_v2_esp32s3.menu.UploadSpeed.921600.upload.speed=921600 +cyobot_v2_esp32s3.menu.UploadSpeed.115200=115200 +cyobot_v2_esp32s3.menu.UploadSpeed.115200.upload.speed=115200 +cyobot_v2_esp32s3.menu.UploadSpeed.256000.windows=256000 +cyobot_v2_esp32s3.menu.UploadSpeed.256000.upload.speed=256000 +cyobot_v2_esp32s3.menu.UploadSpeed.230400.windows.upload.speed=256000 +cyobot_v2_esp32s3.menu.UploadSpeed.230400=230400 +cyobot_v2_esp32s3.menu.UploadSpeed.230400.upload.speed=230400 +cyobot_v2_esp32s3.menu.UploadSpeed.460800.linux=460800 +cyobot_v2_esp32s3.menu.UploadSpeed.460800.macosx=460800 +cyobot_v2_esp32s3.menu.UploadSpeed.460800.upload.speed=460800 +cyobot_v2_esp32s3.menu.UploadSpeed.512000.windows=512000 +cyobot_v2_esp32s3.menu.UploadSpeed.512000.upload.speed=512000 + +cyobot_v2_esp32s3.menu.DebugLevel.none=None +cyobot_v2_esp32s3.menu.DebugLevel.none.build.code_debug=0 +cyobot_v2_esp32s3.menu.DebugLevel.error=Error +cyobot_v2_esp32s3.menu.DebugLevel.error.build.code_debug=1 +cyobot_v2_esp32s3.menu.DebugLevel.warn=Warn +cyobot_v2_esp32s3.menu.DebugLevel.warn.build.code_debug=2 +cyobot_v2_esp32s3.menu.DebugLevel.info=Info +cyobot_v2_esp32s3.menu.DebugLevel.info.build.code_debug=3 +cyobot_v2_esp32s3.menu.DebugLevel.debug=Debug +cyobot_v2_esp32s3.menu.DebugLevel.debug.build.code_debug=4 +cyobot_v2_esp32s3.menu.DebugLevel.verbose=Verbose +cyobot_v2_esp32s3.menu.DebugLevel.verbose.build.code_debug=5 + +cyobot_v2_esp32s3.menu.EraseFlash.none=Disabled +cyobot_v2_esp32s3.menu.EraseFlash.none.upload.erase_cmd= +cyobot_v2_esp32s3.menu.EraseFlash.all=Enabled +cyobot_v2_esp32s3.menu.EraseFlash.all.upload.erase_cmd=-e + +cyobot_v2_esp32s3.menu.ZigbeeMode.default=Disabled +cyobot_v2_esp32s3.menu.ZigbeeMode.default.build.zigbee_mode= +cyobot_v2_esp32s3.menu.ZigbeeMode.default.build.zigbee_libs= +cyobot_v2_esp32s3.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router) +cyobot_v2_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR +cyobot_v2_esp32s3.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote + +############################################################## diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index fb93dad1c47..76135691411 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -11,52 +11,52 @@ #include "driver/uart.h" #include "freertos/queue.h" -#ifndef ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE -#define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048 -#endif - -#ifndef ARDUINO_SERIAL_EVENT_TASK_PRIORITY -#define ARDUINO_SERIAL_EVENT_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#endif - -#ifndef ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE -#define ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE -1 +#if (SOC_UART_LP_NUM >= 1) +#define UART_HW_FIFO_LEN(uart_num) ((uart_num < SOC_UART_HP_NUM) ? SOC_UART_FIFO_LEN : SOC_LP_UART_FIFO_LEN) +#else +#define UART_HW_FIFO_LEN(uart_num) SOC_UART_FIFO_LEN #endif void serialEvent(void) __attribute__((weak)); -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 void serialEvent1(void) __attribute__((weak)); -#endif /* SOC_UART_HP_NUM > 1 */ +#endif /* SOC_UART_NUM > 1 */ -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 void serialEvent2(void) __attribute__((weak)); -#endif /* SOC_UART_HP_NUM > 2 */ +#endif /* SOC_UART_NUM > 2 */ -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 void serialEvent3(void) __attribute__((weak)); -#endif /* SOC_UART_HP_NUM > 3 */ +#endif /* SOC_UART_NUM > 3 */ -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 void serialEvent4(void) __attribute__((weak)); -#endif /* SOC_UART_HP_NUM > 4 */ +#endif /* SOC_UART_NUM > 4 */ + +#if SOC_UART_NUM > 5 +void serialEvent5(void) __attribute__((weak)); +#endif /* SOC_UART_NUM > 5 */ #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) // There is always Seria0 for UART0 HardwareSerial Serial0(0); -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 HardwareSerial Serial1(1); #endif -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 HardwareSerial Serial2(2); #endif -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 HardwareSerial Serial3(3); #endif -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 HardwareSerial Serial4(4); #endif - +#if (SOC_UART_NUM > 5) +HardwareSerial Serial5(5); +#endif #if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event extern void HWCDCSerialEvent(void) __attribute__((weak)); #endif @@ -81,26 +81,31 @@ void serialEventRun(void) { if (serialEvent && Serial0.available()) { serialEvent(); } -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 if (serialEvent1 && Serial1.available()) { serialEvent1(); } #endif -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 if (serialEvent2 && Serial2.available()) { serialEvent2(); } #endif -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 if (serialEvent3 && Serial3.available()) { serialEvent3(); } #endif -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 if (serialEvent4 && Serial4.available()) { serialEvent4(); } #endif +#if SOC_UART_NUM > 5 + if (serialEvent5 && Serial5.available()) { + serialEvent5(); + } +#endif } #endif @@ -185,7 +190,8 @@ void HardwareSerial::onReceive(OnReceiveCb function, bool onlyOnTimeout) { // in case that onReceive() shall work only with RX Timeout, FIFO shall be high // this is a work around for an IDF issue with events and low FIFO Full value (< 3) - if (_onReceiveTimeout) { + // Not valid for the LP UART + if (_onReceiveTimeout && _uart_nr < SOC_UART_HP_NUM) { uartSetRxFIFOFull(_uart, 120); log_w("OnReceive is set to Timeout only, thus FIFO Full is now 120 bytes."); } @@ -207,12 +213,13 @@ bool HardwareSerial::setRxFIFOFull(uint8_t fifoBytes) { HSERIAL_MUTEX_LOCK(); // in case that onReceive() shall work only with RX Timeout, FIFO shall be high // this is a work around for an IDF issue with events and low FIFO Full value (< 3) - if (_onReceiveCB != NULL && _onReceiveTimeout) { + // Not valid for the LP UART + if (_onReceiveCB != NULL && _onReceiveTimeout && _uart_nr < SOC_UART_HP_NUM) { fifoBytes = 120; log_w("OnReceive is set to Timeout only, thus FIFO Full is now 120 bytes."); } bool retCode = uartSetRxFIFOFull(_uart, fifoBytes); // Set new timeout - if (fifoBytes > 0 && fifoBytes < SOC_UART_FIFO_LEN - 1) { + if (fifoBytes > 0 && fifoBytes < UART_HW_FIFO_LEN(_uart_nr) - 1) { _rxFIFOFull = fifoBytes; } HSERIAL_MUTEX_UNLOCK(); @@ -298,8 +305,8 @@ void HardwareSerial::_uartEventTask(void *args) { } void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd) { - if (_uart_nr >= SOC_UART_HP_NUM) { - log_e("Serial number is invalid, please use a number from 0 to %u", SOC_UART_HP_NUM - 1); + if (_uart_nr >= SOC_UART_NUM) { + log_e("Serial number is invalid, please use a number from 0 to %u", SOC_UART_NUM - 1); return; } @@ -333,7 +340,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in txPin = _txPin < 0 ? (int8_t)SOC_TX0 : _txPin; } break; -#if SOC_UART_HP_NUM > 1 // may save some flash bytes... +#if SOC_UART_HP_NUM > 1 case UART_NUM_1: if (rxPin < 0 && txPin < 0) { // do not change RX1/TX1 if it has already been set before @@ -341,8 +348,8 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in txPin = _txPin < 0 ? (int8_t)TX1 : _txPin; } break; -#endif -#if SOC_UART_HP_NUM > 2 // may save some flash bytes... +#endif // UART_NUM_1 +#if SOC_UART_HP_NUM > 2 case UART_NUM_2: if (rxPin < 0 && txPin < 0) { // do not change RX2/TX2 if it has already been set before @@ -354,11 +361,11 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in #endif } break; -#endif -#if SOC_UART_HP_NUM > 3 // may save some flash bytes... +#endif // UART_NUM_2 +#if SOC_UART_HP_NUM > 3 case UART_NUM_3: if (rxPin < 0 && txPin < 0) { - // do not change RX2/TX2 if it has already been set before + // do not change RX3/TX3 if it has already been set before #ifdef RX3 rxPin = _rxPin < 0 ? (int8_t)RX3 : _rxPin; #endif @@ -367,11 +374,11 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in #endif } break; -#endif -#if SOC_UART_HP_NUM > 4 // may save some flash bytes... +#endif // UART_NUM_3 +#if SOC_UART_HP_NUM > 4 case UART_NUM_4: if (rxPin < 0 && txPin < 0) { - // do not change RX2/TX2 if it has already been set before + // do not change RX4/TX4 if it has already been set before #ifdef RX4 rxPin = _rxPin < 0 ? (int8_t)RX4 : _rxPin; #endif @@ -380,7 +387,20 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in #endif } break; +#endif // UART_NUM_4 +#if (SOC_UART_LP_NUM >= 1) + case LP_UART_NUM_0: + if (rxPin < 0 && txPin < 0) { + // do not change RX0_LP/TX0_LP if it has already been set before +#ifdef LP_RX0 + rxPin = _rxPin < 0 ? (int8_t)LP_RX0 : _rxPin; +#endif +#ifdef LP_TX0 + txPin = _txPin < 0 ? (int8_t)LP_TX0 : _txPin; #endif + } + break; +#endif // LP_UART_NUM_0 } } @@ -445,7 +465,8 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in if (!_rxFIFOFull) { // it has not being changed before calling begin() // set a default FIFO Full value for the IDF driver uint8_t fifoFull = 1; - if (baud > 57600 || (_onReceiveCB != NULL && _onReceiveTimeout)) { + // if baud rate is higher than 57600 or onReceive() is set, it will set FIFO Full to 120 bytes, except for LP UART + if (_uart_nr < SOC_UART_HP_NUM && (baud > 57600 || (_onReceiveCB != NULL && _onReceiveTimeout))) { fifoFull = 120; } uartSetRxFIFOFull(_uart, fifoFull); @@ -477,6 +498,12 @@ void HardwareSerial::setDebugOutput(bool en) { if (_uart == 0) { return; } +#if (SOC_UART_LP_NUM >= 1) + if (_uart_nr >= SOC_UART_HP_NUM) { + log_e("LP UART does not support Debug Output."); + return; + } +#endif if (en) { uartSetDebug(_uart); } else { @@ -581,34 +608,37 @@ bool HardwareSerial::setMode(SerialMode mode) { } // minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition. +// LP UART has FIFO of 16 bytes size_t HardwareSerial::setRxBufferSize(size_t new_size) { if (_uart) { log_e("RX Buffer can't be resized when Serial is already running. Set it before calling begin()."); return 0; } - - if (new_size <= SOC_UART_FIFO_LEN) { - log_w("RX Buffer set to minimum value: %d.", SOC_UART_FIFO_LEN + 1); // ESP32, S2, S3 and C3 means higher than 128 - new_size = SOC_UART_FIFO_LEN + 1; + uint8_t FIFOLen = UART_HW_FIFO_LEN(_uart_nr); + // Valid value is higher than the FIFO length + if (new_size <= FIFOLen) { + new_size = FIFOLen + 1; + log_w("RX Buffer set to minimum value: %d.", new_size); } _rxBufferSize = new_size; return _rxBufferSize; } -// minimum total TX Buffer size is the UART FIFO space (128 bytes for most SoC). +// minimum total TX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. +// LP UART has FIFO of 16 bytes size_t HardwareSerial::setTxBufferSize(size_t new_size) { if (_uart) { log_e("TX Buffer can't be resized when Serial is already running. Set it before calling begin()."); return 0; } - - if (new_size <= SOC_UART_FIFO_LEN) { - log_w("TX Buffer set to minimum value: %d.", SOC_UART_FIFO_LEN); // ESP32, S2, S3 and C3 means higher than 128 - _txBufferSize = 0; // it will use just UART FIFO with SOC_UART_FIFO_LEN bytes (128 for most SoC) - return SOC_UART_FIFO_LEN; + uint8_t FIFOLen = UART_HW_FIFO_LEN(_uart_nr); + // Valid values are zero or higher than the FIFO length + if (new_size > 0 && new_size <= FIFOLen) { + new_size = FIFOLen + 1; + log_w("TX Buffer set to minimum value: %d.", new_size); } // if new_size is higher than SOC_UART_FIFO_LEN, TX Ringbuffer will be active and it will be used to report back "availableToWrite()" _txBufferSize = new_size; diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index a33d5def34d..b1f6df17724 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -97,15 +97,27 @@ typedef enum { } hardwareSerial_error_t; #ifndef ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE +#ifndef CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE #define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048 +#else +#define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE +#endif #endif #ifndef ARDUINO_SERIAL_EVENT_TASK_PRIORITY +#ifndef CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY #define ARDUINO_SERIAL_EVENT_TASK_PRIORITY (configMAX_PRIORITIES - 1) +#else +#define ARDUINO_SERIAL_EVENT_TASK_PRIORITY CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY +#endif #endif #ifndef ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE +#ifndef CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE #define ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE -1 +#else +#define ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE +#endif #endif // UART0 pins are defined by default by the bootloader. @@ -212,6 +224,16 @@ typedef enum { #endif #endif /* SOC_UART_HP_NUM > 2 */ +#if SOC_UART_LP_NUM >= 1 +#ifndef LP_RX0 +#define LP_RX0 (gpio_num_t) LP_U0RXD_GPIO_NUM +#endif + +#ifndef LP_TX0 +#define LP_TX0 (gpio_num_t) LP_U0TXD_GPIO_NUM +#endif +#endif /* SOC_UART_LP_NUM >= 1 */ + typedef std::function OnReceiveCb; typedef std::function OnReceiveErrorCb; @@ -259,7 +281,7 @@ class HardwareSerial : public Stream { // rxfifo_full_thrhd if the UART Flow Control Threshold in the UART FIFO (max 127) void begin( unsigned long baud, uint32_t config = SERIAL_8N1, int8_t rxPin = -1, int8_t txPin = -1, bool invert = false, unsigned long timeout_ms = 20000UL, - uint8_t rxfifo_full_thrhd = 112 + uint8_t rxfifo_full_thrhd = 120 ); void end(void); void updateBaudRate(unsigned long baud); @@ -365,18 +387,21 @@ extern void serialEventRun(void) __attribute__((weak)); #endif // ARDUINO_USB_CDC_ON_BOOT // There is always Seria0 for UART0 extern HardwareSerial Serial0; -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 extern HardwareSerial Serial1; #endif -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 extern HardwareSerial Serial2; #endif -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 extern HardwareSerial Serial3; #endif -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 extern HardwareSerial Serial4; #endif +#if SOC_UART_NUM > 5 +extern HardwareSerial Serial5; +#endif #endif //!defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) #endif // HardwareSerial_h diff --git a/cores/esp32/USBCDC.cpp b/cores/esp32/USBCDC.cpp index 795a17dc0b8..945021a79e2 100644 --- a/cores/esp32/USBCDC.cpp +++ b/cores/esp32/USBCDC.cpp @@ -25,8 +25,7 @@ ESP_EVENT_DEFINE_BASE(ARDUINO_USB_CDC_EVENTS); esp_err_t arduino_usb_event_post(esp_event_base_t event_base, int32_t event_id, void *event_data, size_t event_data_size, TickType_t ticks_to_wait); esp_err_t arduino_usb_event_handler_register_with(esp_event_base_t event_base, int32_t event_id, esp_event_handler_t event_handler, void *event_handler_arg); -#define MAX_USB_CDC_DEVICES 2 -USBCDC *devices[MAX_USB_CDC_DEVICES] = {NULL, NULL}; +USBCDC *devices[CFG_TUD_CDC]; static uint16_t load_cdc_descriptor(uint8_t *dst, uint8_t *itf) { uint8_t str_index = tinyusb_add_string_descriptor("TinyUSB CDC"); @@ -38,23 +37,43 @@ static uint16_t load_cdc_descriptor(uint8_t *dst, uint8_t *itf) { return TUD_CDC_DESC_LEN; } +static uint16_t load_cdc_descriptor2(uint8_t *dst, uint8_t *itf) { + uint8_t str_index = tinyusb_add_string_descriptor("TinyUSB CDC2"); + uint8_t ep_ntfy = tinyusb_get_free_in_endpoint(); + TU_VERIFY(ep_ntfy != 0); + uint8_t ep_in = tinyusb_get_free_in_endpoint(); + TU_VERIFY(ep_in != 0); + uint8_t ep_out = tinyusb_get_free_out_endpoint(); + TU_VERIFY(ep_out != 0); + uint8_t descriptor[TUD_CDC_DESC_LEN] = { + // Interface number, string index, EP notification address and size, EP data address (out, in) and size. + TUD_CDC_DESCRIPTOR(*itf, str_index, (uint8_t)(0x80 | ep_ntfy), CFG_TUD_ENDOINT_SIZE, ep_out, (uint8_t)(0x80 | ep_in), CFG_TUD_ENDOINT_SIZE) + }; + *itf += 2; + memcpy(dst, descriptor, TUD_CDC_DESC_LEN); + return TUD_CDC_DESC_LEN; +} + // Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { - if (itf < MAX_USB_CDC_DEVICES && devices[itf] != NULL) { + //log_v("ITF: %u, DTR: %u, RTS: %u", itf, dtr, rts); + if (itf < CFG_TUD_CDC && devices[itf] != NULL) { devices[itf]->_onLineState(dtr, rts); } } // Invoked when line coding is change via SET_LINE_CODING void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const *p_line_coding) { - if (itf < MAX_USB_CDC_DEVICES && devices[itf] != NULL) { + //log_v("ITF: %u, BITRATE: %lu, STOP_BITS: %u, PARITY: %u, DATA_BITS: %u", itf, p_line_coding->bit_rate, p_line_coding->stop_bits, p_line_coding->parity, p_line_coding->data_bits); + if (itf < CFG_TUD_CDC && devices[itf] != NULL) { devices[itf]->_onLineCoding(p_line_coding->bit_rate, p_line_coding->stop_bits, p_line_coding->parity, p_line_coding->data_bits); } } // Invoked when received new data void tud_cdc_rx_cb(uint8_t itf) { - if (itf < MAX_USB_CDC_DEVICES && devices[itf] != NULL) { + //log_v("ITF: %u", itf); + if (itf < CFG_TUD_CDC && devices[itf] != NULL) { devices[itf]->_onRX(); } } @@ -66,13 +85,13 @@ void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms) { // Invoked when space becomes available in TX buffer void tud_cdc_tx_complete_cb(uint8_t itf) { - if (itf < MAX_USB_CDC_DEVICES && devices[itf] != NULL) { + if (itf < CFG_TUD_CDC && devices[itf] != NULL) { devices[itf]->_onTX(); } } static void ARDUINO_ISR_ATTR cdc0_write_char(char c) { - if (devices[0] != NULL) { + if (CFG_TUD_CDC && devices[0] != NULL) { tud_cdc_n_write_char(0, c); } } @@ -84,9 +103,15 @@ static void usb_unplugged_cb(void *arg, esp_event_base_t event_base, int32_t eve USBCDC::USBCDC(uint8_t itfn) : itf(itfn), bit_rate(0), stop_bits(0), parity(0), data_bits(0), dtr(false), rts(false), connected(false), reboot_enable(true), rx_queue(NULL), tx_lock(NULL), tx_timeout_ms(250) { - tinyusb_enable_interface(USB_INTERFACE_CDC, TUD_CDC_DESC_LEN, load_cdc_descriptor); - if (itf < MAX_USB_CDC_DEVICES) { + if (itf < CFG_TUD_CDC) { + if (itf == 0) { + tinyusb_enable_interface(USB_INTERFACE_CDC, TUD_CDC_DESC_LEN, load_cdc_descriptor); + } else { + tinyusb_enable_interface(USB_INTERFACE_CDC2, TUD_CDC_DESC_LEN, load_cdc_descriptor2); + } arduino_usb_event_handler_register_with(ARDUINO_USB_EVENTS, ARDUINO_USB_STOPPED_EVENT, usb_unplugged_cb, this); + } else { + log_e("Maximum of %u CDC devices are supported", CFG_TUD_CDC); } } @@ -142,6 +167,9 @@ size_t USBCDC::setRxBufferSize(size_t rx_queue_len) { } void USBCDC::begin(unsigned long baud) { + if (itf >= CFG_TUD_CDC) { + return; + } if (tx_lock == NULL) { tx_lock = xSemaphoreCreateMutex(); } @@ -153,6 +181,9 @@ void USBCDC::begin(unsigned long baud) { } void USBCDC::end() { + if (itf >= CFG_TUD_CDC) { + return; + } connected = false; devices[itf] = NULL; setRxBufferSize(0); @@ -298,14 +329,14 @@ bool USBCDC::rebootEnabled(void) { } int USBCDC::available(void) { - if (itf >= MAX_USB_CDC_DEVICES || rx_queue == NULL) { + if (itf >= CFG_TUD_CDC || rx_queue == NULL) { return -1; } return uxQueueMessagesWaiting(rx_queue); } int USBCDC::peek(void) { - if (itf >= MAX_USB_CDC_DEVICES || rx_queue == NULL) { + if (itf >= CFG_TUD_CDC || rx_queue == NULL) { return -1; } uint8_t c; @@ -316,7 +347,7 @@ int USBCDC::peek(void) { } int USBCDC::read(void) { - if (itf >= MAX_USB_CDC_DEVICES || rx_queue == NULL) { + if (itf >= CFG_TUD_CDC || rx_queue == NULL) { return -1; } uint8_t c = 0; @@ -327,7 +358,7 @@ int USBCDC::read(void) { } size_t USBCDC::read(uint8_t *buffer, size_t size) { - if (itf >= MAX_USB_CDC_DEVICES || rx_queue == NULL) { + if (itf >= CFG_TUD_CDC || rx_queue == NULL) { return -1; } uint8_t c = 0; @@ -339,7 +370,7 @@ size_t USBCDC::read(uint8_t *buffer, size_t size) { } void USBCDC::flush(void) { - if (itf >= MAX_USB_CDC_DEVICES || tx_lock == NULL || !tud_cdc_n_connected(itf)) { + if (itf >= CFG_TUD_CDC || tx_lock == NULL || !tud_cdc_n_connected(itf)) { return; } if (xSemaphoreTake(tx_lock, tx_timeout_ms / portTICK_PERIOD_MS) != pdPASS) { @@ -350,7 +381,7 @@ void USBCDC::flush(void) { } int USBCDC::availableForWrite(void) { - if (itf >= MAX_USB_CDC_DEVICES || tx_lock == NULL || !tud_cdc_n_connected(itf)) { + if (itf >= CFG_TUD_CDC || tx_lock == NULL || !tud_cdc_n_connected(itf)) { return 0; } if (xSemaphoreTake(tx_lock, tx_timeout_ms / portTICK_PERIOD_MS) != pdPASS) { @@ -362,7 +393,7 @@ int USBCDC::availableForWrite(void) { } size_t USBCDC::write(const uint8_t *buffer, size_t size) { - if (itf >= MAX_USB_CDC_DEVICES || tx_lock == NULL || buffer == NULL || size == 0 || !tud_cdc_n_connected(itf)) { + if (itf >= CFG_TUD_CDC || tx_lock == NULL || buffer == NULL || size == 0 || !tud_cdc_n_connected(itf)) { return 0; } if (xPortInIsrContext()) { @@ -415,6 +446,9 @@ uint32_t USBCDC::baudRate() { } void USBCDC::setDebugOutput(bool en) { + if (itf) { + return; + } if (en) { uartSetDebug(NULL); ets_install_putc2((void (*)(char)) & cdc0_write_char); @@ -424,7 +458,7 @@ void USBCDC::setDebugOutput(bool en) { } USBCDC::operator bool() const { - if (itf >= MAX_USB_CDC_DEVICES) { + if (itf >= CFG_TUD_CDC) { return false; } return connected; diff --git a/cores/esp32/WString.cpp b/cores/esp32/WString.cpp index 71183213ac2..18e64767545 100644 --- a/cores/esp32/WString.cpp +++ b/cores/esp32/WString.cpp @@ -226,11 +226,11 @@ bool String::changeBuffer(unsigned int maxStrLen) { /*********************************************/ String &String::copy(const char *cstr, unsigned int length) { - if (!reserve(length)) { + if (cstr == nullptr || !reserve(length)) { invalidate(); return *this; } - memmove(wbuffer(), cstr, length + 1); + memmove(wbuffer(), cstr, length); setLen(length); return *this; } @@ -239,15 +239,18 @@ String &String::copy(const char *cstr, unsigned int length) { void String::move(String &rhs) { if (buffer()) { if (capacity() >= rhs.len()) { - memmove(wbuffer(), rhs.buffer(), rhs.length() + 1); + // Use case: When 'reserve()' was called and the first + // assignment/append is the return value of a function. + if (rhs.len() && rhs.buffer()) { + memmove(wbuffer(), rhs.buffer(), rhs.length()); + } setLen(rhs.len()); rhs.invalidate(); return; - } else { - if (!isSSO()) { - free(wbuffer()); - setBuffer(nullptr); - } + } + if (!isSSO()) { + free(wbuffer()); + setBuffer(nullptr); } } if (rhs.isSSO()) { @@ -259,10 +262,7 @@ void String::move(String &rhs) { } setCapacity(rhs.capacity()); setLen(rhs.len()); - rhs.setSSO(false); - rhs.setCapacity(0); - rhs.setBuffer(nullptr); - rhs.setLen(0); + rhs.init(); } #endif @@ -270,12 +270,7 @@ String &String::operator=(const String &rhs) { if (this == &rhs) { return *this; } - if (rhs.buffer()) { - copy(rhs.buffer(), rhs.len()); - } else { - invalidate(); - } - return *this; + return copy(rhs.buffer(), rhs.len()); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ @@ -295,12 +290,8 @@ String &String::operator=(StringSumHelper &&rval) { #endif String &String::operator=(const char *cstr) { - if (cstr) { - copy(cstr, strlen(cstr)); - } else { - invalidate(); - } - return *this; + const uint32_t length = cstr ? strlen(cstr) : 0u; + return copy(cstr, length); } /*********************************************/ @@ -311,23 +302,21 @@ bool String::concat(const String &s) { // Special case if we're concatting ourself (s += s;) since we may end up // realloc'ing the buffer and moving s.buffer in the method called if (&s == this) { - unsigned int newlen = 2 * len(); - if (!s.buffer()) { - return false; - } if (s.len() == 0) { return true; } + if (!s.buffer()) { + return false; + } + unsigned int newlen = 2 * len(); if (!reserve(newlen)) { return false; } memmove(wbuffer() + len(), buffer(), len()); setLen(newlen); - wbuffer()[len()] = 0; return true; - } else { - return concat(s.buffer(), s.len()); } + return concat(s.buffer(), s.len()); } bool String::concat(const char *cstr, unsigned int length) { @@ -343,10 +332,10 @@ bool String::concat(const char *cstr, unsigned int length) { } if (cstr >= wbuffer() && cstr < wbuffer() + len()) { // compatible with SSO in ram #6155 (case "x += x.c_str()") - memmove(wbuffer() + len(), cstr, length + 1); + memmove(wbuffer() + len(), cstr, length); } else { // compatible with source in flash #6367 - memcpy_P(wbuffer() + len(), cstr, length + 1); + memcpy_P(wbuffer() + len(), cstr, length); } setLen(newlen); return true; diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index b11636daf81..c681be077b3 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -173,7 +173,7 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) { if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) { gpio_set_level((gpio_num_t)pin, val); } else { - log_e("IO %i is not set as GPIO.", pin); + log_e("IO %i is not set as GPIO. Execute digitalMode(%i, OUTPUT) first.", pin, pin); } } @@ -182,14 +182,12 @@ extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) { if (pin == RGB_BUILTIN) { return RGB_BUILTIN_storage; } -#endif - - if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) { - return gpio_get_level((gpio_num_t)pin); - } else { - log_e("IO %i is not set as GPIO.", pin); - return 0; +#endif // RGB_BUILTIN + // This work when the pin is set as GPIO and in INPUT mode. For all other pin functions, it may return inconsistent response + if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) { + log_w("IO %i is not set as GPIO. digitalRead() may return an inconsistent value."); } + return gpio_get_level((gpio_num_t)pin); } static void ARDUINO_ISR_ATTR __onPinInterrupt(void *arg) { diff --git a/cores/esp32/esp32-hal-i2c-ng.c b/cores/esp32/esp32-hal-i2c-ng.c new file mode 100644 index 00000000000..8e48d0e0397 --- /dev/null +++ b/cores/esp32/esp32-hal-i2c-ng.c @@ -0,0 +1,445 @@ +// Copyright 2015-2025 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "esp32-hal-i2c.h" + +#if SOC_I2C_SUPPORTED +#include "esp_idf_version.h" +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) +#include "esp32-hal.h" +#if !CONFIG_DISABLE_HAL_LOCKS +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#endif +#include "esp_attr.h" +#include "esp_system.h" +#include "soc/soc_caps.h" +#include "driver/i2c_master.h" +#include "esp32-hal-periman.h" + +typedef volatile struct { + bool initialized; + uint32_t frequency; +#if !CONFIG_DISABLE_HAL_LOCKS + SemaphoreHandle_t lock; +#endif + int8_t scl; + int8_t sda; + i2c_master_bus_handle_t bus_handle; + i2c_master_dev_handle_t dev_handles[128]; +} i2c_bus_t; + +static i2c_bus_t bus[SOC_I2C_NUM]; + +static bool i2cDetachBus(void *bus_i2c_num) { + uint8_t i2c_num = (int)bus_i2c_num - 1; + if (!bus[i2c_num].initialized) { + return true; + } + esp_err_t err = i2cDeinit(i2c_num); + if (err != ESP_OK) { + log_e("i2cDeinit failed with error: %d", err); + return false; + } + return true; +} + +bool i2cIsInit(uint8_t i2c_num) { + if (i2c_num >= SOC_I2C_NUM) { + return false; + } + return bus[i2c_num].initialized; +} + +esp_err_t i2cInit(uint8_t i2c_num, int8_t sda, int8_t scl, uint32_t frequency) { + esp_err_t ret = ESP_OK; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + if (bus[i2c_num].lock == NULL) { + bus[i2c_num].lock = xSemaphoreCreateMutex(); + if (bus[i2c_num].lock == NULL) { + log_e("xSemaphoreCreateMutex failed"); + return ESP_ERR_NO_MEM; + } + } + //acquire lock + if (xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return ESP_FAIL; + } +#endif + if (bus[i2c_num].initialized) { + log_e("bus is already initialized"); + ret = ESP_FAIL; + goto init_fail; + } + + if (!frequency) { + frequency = 100000UL; + } else if (frequency > 1000000UL) { + frequency = 1000000UL; + } + + perimanSetBusDeinit(ESP32_BUS_TYPE_I2C_MASTER_SDA, i2cDetachBus); + perimanSetBusDeinit(ESP32_BUS_TYPE_I2C_MASTER_SCL, i2cDetachBus); + + if (!perimanClearPinBus(sda) || !perimanClearPinBus(scl)) { + ret = ESP_FAIL; + goto init_fail; + } + + log_i("Initializing I2C Master: num=%u sda=%d scl=%d freq=%lu", i2c_num, sda, scl, frequency); + + i2c_master_bus_handle_t bus_handle = NULL; + i2c_master_bus_config_t bus_config; + memset(&bus_config, 0, sizeof(i2c_master_bus_config_t)); + bus_config.i2c_port = (i2c_port_num_t)i2c_num; + bus_config.sda_io_num = (gpio_num_t)sda; + bus_config.scl_io_num = (gpio_num_t)scl; +#if SOC_LP_I2C_SUPPORTED + if (i2c_num >= SOC_HP_I2C_NUM) { + bus_config.lp_source_clk = LP_I2C_SCLK_DEFAULT; + } else +#endif + { + bus_config.clk_source = I2C_CLK_SRC_DEFAULT; + } + bus_config.glitch_ignore_cnt = 7; + bus_config.intr_priority = 0; // auto + bus_config.trans_queue_depth = 0; // only valid in asynchronous transaction, which Arduino does not use + bus_config.flags.enable_internal_pullup = 1; +#if SOC_I2C_SUPPORT_SLEEP_RETENTION + bus_config.flags.allow_pd = 1; // backup/restore the I2C registers before/after entering/exist sleep mode +#endif + + ret = i2c_new_master_bus(&bus_config, &bus_handle); + if (ret != ESP_OK) { + log_e("i2c_new_master_bus failed: [%d] %s", ret, esp_err_to_name(ret)); + } else { + bus[i2c_num].initialized = true; + bus[i2c_num].frequency = frequency; + bus[i2c_num].scl = scl; + bus[i2c_num].sda = sda; + bus[i2c_num].bus_handle = bus_handle; + for (uint8_t i = 0; i < 128; i++) { + bus[i2c_num].dev_handles[i] = NULL; + } + if (!perimanSetPinBus(sda, ESP32_BUS_TYPE_I2C_MASTER_SDA, (void *)(i2c_num + 1), i2c_num, -1) + || !perimanSetPinBus(scl, ESP32_BUS_TYPE_I2C_MASTER_SCL, (void *)(i2c_num + 1), i2c_num, -1)) { +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock so that i2cDetachBus can execute i2cDeinit + xSemaphoreGive(bus[i2c_num].lock); +#endif + i2cDetachBus((void *)(i2c_num + 1)); + return ESP_FAIL; + } + } + +init_fail: +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return ret; +} + +esp_err_t i2cDeinit(uint8_t i2c_num) { + esp_err_t err = ESP_FAIL; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + //acquire lock + if (bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return err; + } +#endif + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + } else { + // remove devices from the bus + for (uint8_t i = 0; i < 128; i++) { + if (bus[i2c_num].dev_handles[i] != NULL) { + err = i2c_master_bus_rm_device(bus[i2c_num].dev_handles[i]); + bus[i2c_num].dev_handles[i] = NULL; + if (err != ESP_OK) { + log_e("i2c_master_bus_rm_device failed: [%d] %s", err, esp_err_to_name(err)); + } + } + } + err = i2c_del_master_bus(bus[i2c_num].bus_handle); + if (err != ESP_OK) { + log_e("i2c_del_master_bus failed: [%d] %s", err, esp_err_to_name(err)); + } else { + bus[i2c_num].initialized = false; + perimanClearPinBus(bus[i2c_num].scl); + perimanClearPinBus(bus[i2c_num].sda); + bus[i2c_num].scl = -1; + bus[i2c_num].sda = -1; + bus[i2c_num].bus_handle = NULL; + } + } +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return err; +} + +static esp_err_t i2cAddDeviceIfNeeded(uint8_t i2c_num, uint16_t address) { + esp_err_t ret = ESP_OK; + if (bus[i2c_num].dev_handles[address] == NULL) { + i2c_master_dev_handle_t dev_handle = NULL; + i2c_device_config_t dev_config; + memset(&dev_config, 0, sizeof(i2c_device_config_t)); + dev_config.dev_addr_length = I2C_ADDR_BIT_LEN_7; // Arduino supports only 7bit addresses + dev_config.device_address = address; + dev_config.scl_speed_hz = bus[i2c_num].frequency; + dev_config.scl_wait_us = 0; + dev_config.flags.disable_ack_check = 0; + + ret = i2c_master_bus_add_device(bus[i2c_num].bus_handle, &dev_config, &dev_handle); + if (ret != ESP_OK) { + log_e("i2c_master_bus_add_device failed: [%d] %s", ret, esp_err_to_name(ret)); + } else { + bus[i2c_num].dev_handles[address] = dev_handle; + log_v("added device: bus=%u addr=0x%x handle=0x%08x", i2c_num, address, dev_handle); + } + } + return ret; +} + +esp_err_t i2cWrite(uint8_t i2c_num, uint16_t address, const uint8_t *buff, size_t size, uint32_t timeOutMillis) { + esp_err_t ret = ESP_FAIL; + // i2c_cmd_handle_t cmd = NULL; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } + if (address >= 128) { + log_e("Only 7bit I2C addresses are supported"); + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + //acquire lock + if (bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return ret; + } +#endif + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + goto end; + } + + if (size == 0) { + // Probe device + ret = i2c_master_probe(bus[i2c_num].bus_handle, address, timeOutMillis); + if (ret != ESP_OK) { + log_v("i2c_master_probe failed: [%d] %s", ret, esp_err_to_name(ret)); + } + } else { + // writing data to device + ret = i2cAddDeviceIfNeeded(i2c_num, address); + if (ret != ESP_OK) { + goto end; + } + + log_v("i2c_master_transmit: bus=%u addr=0x%x handle=0x%08x size=%u", i2c_num, address, bus[i2c_num].dev_handles[address], size); + ret = i2c_master_transmit(bus[i2c_num].dev_handles[address], buff, size, timeOutMillis); + if (ret != ESP_OK) { + log_e("i2c_master_transmit failed: [%d] %s", ret, esp_err_to_name(ret)); + goto end; + } + + // wait for transactions to finish (is it needed with sync transactions?) + // ret = i2c_master_bus_wait_all_done(bus[i2c_num].bus_handle, timeOutMillis); + // if (ret != ESP_OK) { + // log_e("i2c_master_bus_wait_all_done failed: [%d] %s", ret, esp_err_to_name(ret)); + // goto end; + // } + } + +end: +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return ret; +} + +esp_err_t i2cRead(uint8_t i2c_num, uint16_t address, uint8_t *buff, size_t size, uint32_t timeOutMillis, size_t *readCount) { + esp_err_t ret = ESP_FAIL; + *readCount = 0; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + //acquire lock + if (bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return ret; + } +#endif + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + goto end; + } + + ret = i2cAddDeviceIfNeeded(i2c_num, address); + if (ret != ESP_OK) { + goto end; + } + + log_v("i2c_master_receive: bus=%u addr=0x%x handle=0x%08x size=%u", i2c_num, address, bus[i2c_num].dev_handles[address], size); + ret = i2c_master_receive(bus[i2c_num].dev_handles[address], buff, size, timeOutMillis); + if (ret != ESP_OK) { + log_e("i2c_master_receive failed: [%d] %s", ret, esp_err_to_name(ret)); + goto end; + } + + // wait for transactions to finish (is it needed with sync transactions?) + // ret = i2c_master_bus_wait_all_done(bus[i2c_num].bus_handle, timeOutMillis); + // if (ret != ESP_OK) { + // log_e("i2c_master_bus_wait_all_done failed: [%d] %s", ret, esp_err_to_name(ret)); + // goto end; + // } + *readCount = size; + +end: +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return ret; +} + +esp_err_t i2cWriteReadNonStop( + uint8_t i2c_num, uint16_t address, const uint8_t *wbuff, size_t wsize, uint8_t *rbuff, size_t rsize, uint32_t timeOutMillis, size_t *readCount +) { + esp_err_t ret = ESP_FAIL; + *readCount = 0; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + //acquire lock + if (bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return ret; + } +#endif + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + goto end; + } + + ret = i2cAddDeviceIfNeeded(i2c_num, address); + if (ret != ESP_OK) { + goto end; + } + + log_v("i2c_master_transmit_receive: bus=%u addr=0x%x handle=0x%08x write=%u read=%u", i2c_num, address, bus[i2c_num].dev_handles[address], wsize, rsize); + ret = i2c_master_transmit_receive(bus[i2c_num].dev_handles[address], wbuff, wsize, rbuff, rsize, timeOutMillis); + if (ret != ESP_OK) { + log_e("i2c_master_transmit_receive failed: [%d] %s", ret, esp_err_to_name(ret)); + goto end; + } + + // wait for transactions to finish (is it needed with sync transactions?) + // ret = i2c_master_bus_wait_all_done(bus[i2c_num].bus_handle, timeOutMillis); + // if (ret != ESP_OK) { + // log_e("i2c_master_bus_wait_all_done failed: [%d] %s", ret, esp_err_to_name(ret)); + // goto end; + // } + *readCount = rsize; + +end: +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return ret; +} + +esp_err_t i2cSetClock(uint8_t i2c_num, uint32_t frequency) { + esp_err_t ret = ESP_FAIL; + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } +#if !CONFIG_DISABLE_HAL_LOCKS + //acquire lock + if (bus[i2c_num].lock == NULL || xSemaphoreTake(bus[i2c_num].lock, portMAX_DELAY) != pdTRUE) { + log_e("could not acquire lock"); + return ret; + } +#endif + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + goto end; + } + if (bus[i2c_num].frequency == frequency) { + ret = ESP_OK; + goto end; + } + if (!frequency) { + frequency = 100000UL; + } else if (frequency > 1000000UL) { + frequency = 1000000UL; + } + + bus[i2c_num].frequency = frequency; + + // loop through devices, remove them and then re-add them with the new frequency + for (uint8_t i = 0; i < 128; i++) { + if (bus[i2c_num].dev_handles[i] != NULL) { + ret = i2c_master_bus_rm_device(bus[i2c_num].dev_handles[i]); + if (ret != ESP_OK) { + log_e("i2c_master_bus_rm_device failed: [%d] %s", ret, esp_err_to_name(ret)); + goto end; + } else { + bus[i2c_num].dev_handles[i] = NULL; + ret = i2cAddDeviceIfNeeded(i2c_num, i); + if (ret != ESP_OK) { + goto end; + } + } + } + } + +end: +#if !CONFIG_DISABLE_HAL_LOCKS + //release lock + xSemaphoreGive(bus[i2c_num].lock); +#endif + return ret; +} + +esp_err_t i2cGetClock(uint8_t i2c_num, uint32_t *frequency) { + if (i2c_num >= SOC_I2C_NUM) { + return ESP_ERR_INVALID_ARG; + } + if (!bus[i2c_num].initialized) { + log_e("bus is not initialized"); + return ESP_FAIL; + } + *frequency = bus[i2c_num].frequency; + return ESP_OK; +} + +#endif /* ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) */ +#endif /* SOC_I2C_SUPPORTED */ diff --git a/cores/esp32/esp32-hal-i2c-slave.c b/cores/esp32/esp32-hal-i2c-slave.c index 85eddcdfcf4..46c3a4d58c2 100644 --- a/cores/esp32/esp32-hal-i2c-slave.c +++ b/cores/esp32/esp32-hal-i2c-slave.c @@ -336,7 +336,11 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t #endif // !defined(CONFIG_IDF_TARGET_ESP32P4) i2c_ll_slave_init(i2c->dev); +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) + i2c_ll_enable_fifo_mode(i2c->dev, true); +#else i2c_ll_slave_set_fifo_mode(i2c->dev, true); +#endif i2c_ll_set_slave_addr(i2c->dev, slaveID, false); i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT); i2c_slave_set_frequency(i2c, frequency); @@ -357,7 +361,11 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t i2c_ll_disable_intr_mask(i2c->dev, I2C_LL_INTR_MASK); i2c_ll_clear_intr_mask(i2c->dev, I2C_LL_INTR_MASK); +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) + i2c_ll_enable_fifo_mode(i2c->dev, true); +#else i2c_ll_slave_set_fifo_mode(i2c->dev, true); +#endif if (!i2c->intr_handle) { uint32_t flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED; diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index 359b2161201..71c8ae1c428 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -15,6 +15,8 @@ #include "esp32-hal-i2c.h" #if SOC_I2C_SUPPORTED +#include "esp_idf_version.h" +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 4, 0) #include "esp32-hal.h" #if !CONFIG_DISABLE_HAL_LOCKS #include "freertos/FreeRTOS.h" @@ -429,4 +431,5 @@ esp_err_t i2cGetClock(uint8_t i2c_num, uint32_t *frequency) { return ESP_OK; } +#endif /* ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 4, 0) */ #endif /* SOC_I2C_SUPPORTED */ diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 0bce548bdd2..50e2973d27a 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -25,7 +25,7 @@ #include "esp_ota_ops.h" #endif //CONFIG_APP_ROLLBACK_ENABLE #include "esp_private/startup_internal.h" -#ifdef CONFIG_BT_ENABLED +#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED #include "esp_bt.h" #endif //CONFIG_BT_ENABLED #include @@ -156,11 +156,13 @@ void enableCore0WDT() { } } -void disableCore0WDT() { +bool disableCore0WDT() { TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCore(0); - if (idle_0 == NULL || esp_task_wdt_delete(idle_0) != ESP_OK) { + if (idle_0 == NULL || esp_task_wdt_status(idle_0) || esp_task_wdt_delete(idle_0) != ESP_OK) { log_e("Failed to remove Core 0 IDLE task from WDT"); + return false; } + return true; } #ifndef CONFIG_FREERTOS_UNICORE @@ -171,11 +173,13 @@ void enableCore1WDT() { } } -void disableCore1WDT() { +bool disableCore1WDT() { TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCore(1); - if (idle_1 == NULL || esp_task_wdt_delete(idle_1) != ESP_OK) { + if (idle_1 == NULL || esp_task_wdt_status(idle_1) || esp_task_wdt_delete(idle_1) != ESP_OK) { log_e("Failed to remove Core 1 IDLE task from WDT"); + return false; } + return true; } #endif @@ -301,7 +305,7 @@ void initArduino() { if (err) { log_e("Failed to initialize NVS! Error: %u", err); } -#ifdef CONFIG_BT_ENABLED +#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED if (!btInUse()) { esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); } diff --git a/cores/esp32/esp32-hal-tinyusb.c b/cores/esp32/esp32-hal-tinyusb.c index f83e8b61bd2..0991e08d27f 100644 --- a/cores/esp32/esp32-hal-tinyusb.c +++ b/cores/esp32/esp32-hal-tinyusb.c @@ -616,7 +616,7 @@ void usb_persist_restart(restart_type_t mode) { } static bool tinyusb_reserve_in_endpoint(uint8_t endpoint) { - if (endpoint > 6 || (tinyusb_endpoints.in & BIT(endpoint)) != 0) { + if (endpoint > CFG_TUD_NUM_EPS || (tinyusb_endpoints.in & BIT(endpoint)) != 0) { return false; } tinyusb_endpoints.in |= BIT(endpoint); @@ -624,7 +624,7 @@ static bool tinyusb_reserve_in_endpoint(uint8_t endpoint) { } static bool tinyusb_reserve_out_endpoint(uint8_t endpoint) { - if (endpoint > 6 || (tinyusb_endpoints.out & BIT(endpoint)) != 0) { + if (endpoint > CFG_TUD_NUM_EPS || (tinyusb_endpoints.out & BIT(endpoint)) != 0) { return false; } tinyusb_endpoints.out |= BIT(endpoint); @@ -632,11 +632,13 @@ static bool tinyusb_reserve_out_endpoint(uint8_t endpoint) { } static bool tinyusb_has_available_fifos(void) { - uint8_t max_endpoints = 4, active_endpoints = 0; + uint8_t max_endpoints = CFG_TUD_NUM_IN_EPS - 1, active_endpoints = 0; +#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 if (tinyusb_loaded_interfaces_mask & BIT(USB_INTERFACE_CDC)) { - max_endpoints = 5; //CDC endpoint 0x85 is actually not linked to FIFO and not used + max_endpoints = CFG_TUD_NUM_IN_EPS; //CDC endpoint 0x85 is actually not linked to FIFO and not used } - for (uint8_t i = 1; i < 7; i++) { +#endif + for (uint8_t i = 1; i <= CFG_TUD_NUM_EPS; i++) { if ((tinyusb_endpoints.in & BIT(i)) != 0) { active_endpoints++; } @@ -771,7 +773,7 @@ static void usb_device_task(void *param) { * PUBLIC API * */ #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_ERROR -const char *tinyusb_interface_names[USB_INTERFACE_MAX] = {"MSC", "DFU", "HID", "VENDOR", "CDC", "MIDI", "CUSTOM"}; +const char *tinyusb_interface_names[USB_INTERFACE_MAX] = {"MSC", "DFU", "HID", "VENDOR", "CDC", "CDC2", "MIDI", "CUSTOM"}; #endif static bool tinyusb_is_initialized = false; @@ -862,7 +864,7 @@ uint8_t tinyusb_get_free_duplex_endpoint(void) { log_e("No available IN endpoints"); return 0; } - for (uint8_t i = 1; i < 7; i++) { + for (uint8_t i = 1; i <= CFG_TUD_NUM_IN_EPS; i++) { if ((tinyusb_endpoints.in & BIT(i)) == 0 && (tinyusb_endpoints.out & BIT(i)) == 0) { tinyusb_endpoints.in |= BIT(i); tinyusb_endpoints.out |= BIT(i); @@ -878,13 +880,13 @@ uint8_t tinyusb_get_free_in_endpoint(void) { log_e("No available IN endpoints"); return 0; } - for (uint8_t i = 1; i < 7; i++) { + for (uint8_t i = 1; i <= CFG_TUD_NUM_IN_EPS; i++) { if ((tinyusb_endpoints.in & BIT(i)) == 0 && (tinyusb_endpoints.out & BIT(i)) != 0) { tinyusb_endpoints.in |= BIT(i); return i; } } - for (uint8_t i = 1; i < 7; i++) { + for (uint8_t i = 1; i <= CFG_TUD_NUM_IN_EPS; i++) { if ((tinyusb_endpoints.in & BIT(i)) == 0) { tinyusb_endpoints.in |= BIT(i); return i; @@ -894,13 +896,13 @@ uint8_t tinyusb_get_free_in_endpoint(void) { } uint8_t tinyusb_get_free_out_endpoint(void) { - for (uint8_t i = 1; i < 7; i++) { + for (uint8_t i = 1; i <= CFG_TUD_NUM_EPS; i++) { if ((tinyusb_endpoints.out & BIT(i)) == 0 && (tinyusb_endpoints.in & BIT(i)) != 0) { tinyusb_endpoints.out |= BIT(i); return i; } } - for (uint8_t i = 1; i < 7; i++) { + for (uint8_t i = 1; i <= CFG_TUD_NUM_EPS; i++) { if ((tinyusb_endpoints.out & BIT(i)) == 0) { tinyusb_endpoints.out |= BIT(i); return i; diff --git a/cores/esp32/esp32-hal-tinyusb.h b/cores/esp32/esp32-hal-tinyusb.h index 0b42760e69f..73210c4872b 100644 --- a/cores/esp32/esp32-hal-tinyusb.h +++ b/cores/esp32/esp32-hal-tinyusb.h @@ -38,6 +38,13 @@ extern "C" { #define CFG_TUD_ENDOINT_SIZE 64 #endif #endif +#if CONFIG_IDF_TARGET_ESP32P4 +#define CFG_TUD_NUM_EPS 15 +#define CFG_TUD_NUM_IN_EPS 8 +#else +#define CFG_TUD_NUM_EPS 6 +#define CFG_TUD_NUM_IN_EPS 5 +#endif typedef struct { uint16_t vid; @@ -88,6 +95,7 @@ typedef enum { USB_INTERFACE_HID, USB_INTERFACE_VENDOR, USB_INTERFACE_CDC, + USB_INTERFACE_CDC2, USB_INTERFACE_MIDI, USB_INTERFACE_CUSTOM, USB_INTERFACE_MAX diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 34a2660e3a3..59a95a084f6 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -1,4 +1,4 @@ -// Copyright 2015-2024 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2025 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,6 +33,11 @@ #include "hal/gpio_hal.h" #include "esp_rom_gpio.h" +#include "driver/rtc_io.h" +#include "driver/lp_io.h" +#include "soc/uart_periph.h" +#include "esp_private/uart_share_hw_ctrl.h" + static int s_uart_debug_nr = 0; // UART number for debug output #define REF_TICK_BAUDRATE_LIMIT 250000 // this is maximum UART badrate using REF_TICK as clock @@ -62,18 +67,21 @@ struct uart_struct_t { static uart_t _uart_bus_array[] = { {0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 {1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 {2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 {3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 {4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif +#if SOC_UART_NUM > 5 + {5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, +#endif }; #else @@ -88,27 +96,121 @@ static uart_t _uart_bus_array[] = { static uart_t _uart_bus_array[] = { {NULL, 0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, -#if SOC_UART_HP_NUM > 1 +#if SOC_UART_NUM > 1 {NULL, 1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 2 +#if SOC_UART_NUM > 2 {NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 3 +#if SOC_UART_NUM > 3 {NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif -#if SOC_UART_HP_NUM > 4 +#if SOC_UART_NUM > 4 {NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, #endif +#if SOC_UART_NUM > 5 + {NULL, 5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0}, +#endif }; #endif +#if SOC_UART_LP_NUM >= 1 +// LP UART enable pins routine +static bool lp_uart_config_io(uint8_t uart_num, int8_t pin, rtc_gpio_mode_t direction, uint32_t idx) { + /* Skip configuration if the LP_IO is -1 */ + if (pin < 0) { + return true; + } + + // Initialize LP_IO + if (rtc_gpio_init(pin) != ESP_OK) { + log_e("Failed to initialize LP_IO %d", pin); + return false; + } + + // Set LP_IO direction + if (rtc_gpio_set_direction(pin, direction) != ESP_OK) { + log_e("Failed to set LP_IO %d direction", pin); + return false; + } + + // Connect pins + const uart_periph_sig_t *upin = &uart_periph_signal[uart_num].pins[idx]; +#if !SOC_LP_GPIO_MATRIX_SUPPORTED // ESP32-C6/C61/C5 + // When LP_IO Matrix is not support, LP_IO Mux must be connected to the pins + if (rtc_gpio_iomux_func_sel(pin, upin->iomux_func) != ESP_OK) { + log_e("Failed to set LP_IO pin %d into Mux function", pin); + return false; + } +#else // So far, only ESP32-P4 + // If the configured pin is the default LP_IO Mux pin for LP UART, then set the LP_IO MUX function + if (upin->default_gpio == pin) { + if (rtc_gpio_iomux_func_sel(pin, upin->iomux_func) != ESP_OK) { + log_e("Failed to set LP_IO pin %d into Mux function", pin); + return false; + } + } else { + // Otherwise, set the LP_IO Matrix and select FUNC1 + if (rtc_gpio_iomux_func_sel(pin, 1) != ESP_OK) { + log_e("Failed to set LP_IO pin %d into Mux function GPIO", pin); + return false; + } + // Connect the LP_IO to the LP UART peripheral signal + esp_err_t ret; + if (direction == RTC_GPIO_MODE_OUTPUT_ONLY) { + ret = lp_gpio_connect_out_signal(pin, UART_PERIPH_SIGNAL(uart_num, idx), 0, 0); + } else { + ret = lp_gpio_connect_in_signal(pin, UART_PERIPH_SIGNAL(uart_num, idx), 0); + } + if (ret != ESP_OK) { + log_e("Failed to connect LP_IO pin %d to UART%d signal", pin, uart_num); + return false; + } + } +#endif // SOC_LP_GPIO_MATRIX_SUPPORTED + + return true; +} + +// When LP UART needs the RTC IO MUX to set the pin, it will always have fixed pins for RX, TX, CTS and RTS +static bool lpuartCheckPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin, uint8_t uart_nr) { +// check if LP UART is being used and if the pins are valid +#if !SOC_LP_GPIO_MATRIX_SUPPORTED // ESP32-C6/C61/C5 + uint16_t lp_uart_fixed_pin = uart_periph_signal[uart_nr].pins[SOC_UART_RX_PIN_IDX].default_gpio; + if (uart_nr >= SOC_UART_HP_NUM) { // it is a LP UART NUM + if (rxPin > 0 && rxPin != lp_uart_fixed_pin) { + log_e("UART%d LP UART requires RX pin to be set to %d.", uart_nr, lp_uart_fixed_pin); + return false; + } + lp_uart_fixed_pin = uart_periph_signal[uart_nr].pins[SOC_UART_TX_PIN_IDX].default_gpio; + if (txPin > 0 && txPin != lp_uart_fixed_pin) { + log_e("UART%d LP UART requires TX pin to be set to %d.", uart_nr, lp_uart_fixed_pin); + return false; + } + lp_uart_fixed_pin = uart_periph_signal[uart_nr].pins[SOC_UART_CTS_PIN_IDX].default_gpio; + if (ctsPin > 0 && ctsPin != lp_uart_fixed_pin) { + log_e("UART%d LP UART requires CTS pin to be set to %d.", uart_nr, lp_uart_fixed_pin); + return false; + } + lp_uart_fixed_pin = uart_periph_signal[uart_nr].pins[SOC_UART_RTS_PIN_IDX].default_gpio; + if (rtsPin > 0 && rtsPin != lp_uart_fixed_pin) { + log_e("UART%d LP UART requires RTS pin to be set to %d.", uart_nr, lp_uart_fixed_pin); + return false; + } + } + return true; +#else // ESP32-P4 can set any pin for LP UART + return true; +#endif // SOC_LP_GPIO_MATRIX_SUPPORTED +} +#endif // SOC_UART_LP_NUM >= 1 + // Negative Pin Number will keep it unmodified, thus this function can detach individual pins // This function will also unset the pins in the Peripheral Manager and set the pin to -1 after detaching static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { - if (uart_num >= SOC_UART_HP_NUM) { - log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_HP_NUM - 1); + if (uart_num >= SOC_UART_NUM) { + log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_NUM - 1); return false; } // get UART information @@ -117,7 +219,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t //log_v("detaching UART%d pins: prev,pin RX(%d,%d) TX(%d,%d) CTS(%d,%d) RTS(%d,%d)", uart_num, // uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10); - // detaches pins and sets Peripheral Manager and UART information + // detaches HP and LP pins and sets Peripheral Manager and UART information if (rxPin >= 0 && uart->_rxPin == rxPin && perimanGetPinBusType(rxPin) == ESP32_BUS_TYPE_UART_RX) { gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rxPin], PIN_FUNC_GPIO); // avoids causing BREAK in the UART line @@ -194,8 +296,8 @@ static bool _uartDetachBus_RTS(void *busptr) { // Attach function for UART // connects the IO Pad, set Paripheral Manager and internal UART structure data static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { - if (uart_num >= SOC_UART_HP_NUM) { - log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_HP_NUM - 1); + if (uart_num >= SOC_UART_NUM) { + log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_NUM - 1); return false; } // get UART information @@ -203,6 +305,8 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t //log_v("attaching UART%d pins: prev,new RX(%d,%d) TX(%d,%d) CTS(%d,%d) RTS(%d,%d)", uart_num, // uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10); + // IDF uart_set_pin() checks if the pin is used within LP UART and if it is a valid RTC IO pin + // No need for Arduino Layer to check it again bool retCode = true; if (rxPin >= 0) { // forces a clean detaching from a previous peripheral @@ -211,6 +315,11 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t } // connect RX Pad bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); +#if SOC_UART_LP_NUM >= 1 + if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM + ret &= lp_uart_config_io(uart->num, rxPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_RX_PIN_IDX); + } +#endif if (ret) { ret &= perimanSetPinBus(rxPin, ESP32_BUS_TYPE_UART_RX, (void *)uart, uart_num, -1); if (ret) { @@ -229,6 +338,11 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t } // connect TX Pad bool ret = ESP_OK == uart_set_pin(uart->num, txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); +#if SOC_UART_LP_NUM >= 1 + if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM + ret &= lp_uart_config_io(uart->num, txPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_TX_PIN_IDX); + } +#endif if (ret) { ret &= perimanSetPinBus(txPin, ESP32_BUS_TYPE_UART_TX, (void *)uart, uart_num, -1); if (ret) { @@ -247,6 +361,11 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t } // connect CTS Pad bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, ctsPin); +#if SOC_UART_LP_NUM >= 1 + if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM + ret &= lp_uart_config_io(uart->num, ctsPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_CTS_PIN_IDX); + } +#endif if (ret) { ret &= perimanSetPinBus(ctsPin, ESP32_BUS_TYPE_UART_CTS, (void *)uart, uart_num, -1); if (ret) { @@ -265,6 +384,11 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t } // connect RTS Pad bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, rtsPin, UART_PIN_NO_CHANGE); +#if SOC_UART_LP_NUM >= 1 + if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM + ret &= lp_uart_config_io(uart->num, rtsPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_RTS_PIN_IDX); + } +#endif if (ret) { ret &= perimanSetPinBus(rtsPin, ESP32_BUS_TYPE_UART_RTS, (void *)uart, uart_num, -1); if (ret) { @@ -321,13 +445,20 @@ bool uartIsDriverInstalled(uart_t *uart) { // Negative Pin Number will keep it unmodified, thus this function can set individual pins // When pins are changed, it will detach the previous one bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { - if (uart_num >= SOC_UART_HP_NUM) { - log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_HP_NUM - 1); + if (uart_num >= SOC_UART_NUM) { + log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_NUM - 1); return false; } // get UART information uart_t *uart = &_uart_bus_array[uart_num]; +#if SOC_UART_LP_NUM >= 1 + // check if LP UART is being used and if the pins are valid + if (!lpuartCheckPins(rxPin, txPin, ctsPin, rtsPin, uart_num)) { + return false; // failed to set pins + } +#endif + bool retCode = true; UART_MUTEX_LOCK(); @@ -391,7 +522,7 @@ bool _testUartBegin( uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint32_t rx_buffer_size, uint32_t tx_buffer_size, bool inverted, uint8_t rxfifo_full_thrhd ) { - if (uart_nr >= SOC_UART_HP_NUM) { + if (uart_nr >= SOC_UART_NUM) { return false; // no new driver has to be installed } uart_t *uart = &_uart_bus_array[uart_nr]; @@ -413,13 +544,24 @@ uart_t *uartBegin( uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint32_t rx_buffer_size, uint32_t tx_buffer_size, bool inverted, uint8_t rxfifo_full_thrhd ) { - if (uart_nr >= SOC_UART_HP_NUM) { - log_e("UART number is invalid, please use number from 0 to %u", SOC_UART_HP_NUM - 1); + if (uart_nr >= SOC_UART_NUM) { + log_e("UART number is invalid, please use number from 0 to %u", SOC_UART_NUM - 1); return NULL; // no new driver was installed } uart_t *uart = &_uart_bus_array[uart_nr]; log_v("UART%d baud(%ld) Mode(%x) rxPin(%d) txPin(%d)", uart_nr, baudrate, config, rxPin, txPin); +#if SOC_UART_LP_NUM >= 1 + // check if LP UART is being used and if the pins are valid + if (!lpuartCheckPins(rxPin, txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, uart_nr)) { + if (uart_is_driver_installed(uart_nr)) { + return uart; // keep the same installed driver + } else { + return NULL; // no new driver was installed + } + } +#endif + #if !CONFIG_DISABLE_HAL_LOCKS if (uart->lock == NULL) { uart->lock = xSemaphoreCreateMutex(); @@ -436,6 +578,10 @@ uart_t *uartBegin( if (uart->_rx_buffer_size != rx_buffer_size || uart->_tx_buffer_size != tx_buffer_size || uart->_inverted != inverted || uart->_rxfifo_full_thrhd != rxfifo_full_thrhd) { log_v("UART%d changing buffer sizes or inverted signal or rxfifo_full_thrhd. IDF driver will be restarted", uart_nr); + log_v("RX buffer size: %d -> %d", uart->_rx_buffer_size, rx_buffer_size); + log_v("TX buffer size: %d -> %d", uart->_tx_buffer_size, tx_buffer_size); + log_v("Inverted signal: %s -> %s", uart->_inverted ? "true" : "false", inverted ? "true" : "false"); + log_v("RX FIFO full threshold: %d -> %d", uart->_rxfifo_full_thrhd, rxfifo_full_thrhd); uartEnd(uart_nr); } else { bool retCode = true; @@ -500,7 +646,7 @@ uart_t *uartBegin( } UART_MUTEX_UNLOCK(); if (retCode) { - // UART driver was already working, just return the uart_t structure, syaing that no new driver was installed + // UART driver was already working, just return the uart_t structure, saying that no new driver was installed return uart; } // if we reach this point, it means that we need to restart the UART driver @@ -516,22 +662,39 @@ uart_t *uartBegin( uart_config.parity = (config & 0x3); uart_config.stop_bits = (config & 0x30) >> 4; uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; - uart_config.rx_flow_ctrl_thresh = rxfifo_full_thrhd; + uart_config.rx_flow_ctrl_thresh = rxfifo_full_thrhd >= UART_HW_FIFO_LEN(uart_nr) ? UART_HW_FIFO_LEN(uart_nr) - 6 : rxfifo_full_thrhd; + log_v( + "UART%d RX FIFO full threshold set to %d (value requested: %d || FIFO Max = %d)", uart_nr, uart_config.rx_flow_ctrl_thresh, rxfifo_full_thrhd, + UART_HW_FIFO_LEN(uart_nr) + ); + rxfifo_full_thrhd = uart_config.rx_flow_ctrl_thresh; // makes sure that it will be set correctly in the struct uart_config.baud_rate = baudrate; - // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored - // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue. +#if SOC_UART_LP_NUM >= 1 + if (uart_nr >= SOC_UART_HP_NUM) { // it is a LP UART NUM + uart_config.lp_source_clk = LP_UART_SCLK_DEFAULT; // use default LP clock + log_v("Setting UART%d to use LP clock", uart_nr); + } else +#endif + { + // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored + // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue. #if SOC_UART_SUPPORT_XTAL_CLK - uart_config.source_clk = UART_SCLK_XTAL; // valid for C2, S3, C3, C6, H2 and P4 + uart_config.source_clk = UART_SCLK_XTAL; // valid for C2, S3, C3, C6, H2 and P4 + log_v("Setting UART%d to use XTAL clock", uart_nr); #elif SOC_UART_SUPPORT_REF_TICK - if (baudrate <= REF_TICK_BAUDRATE_LIMIT) { - uart_config.source_clk = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 250 Kbps - } else { - uart_config.source_clk = UART_SCLK_APB; // baudrate may change with the APB Frequency! - } + if (baudrate <= REF_TICK_BAUDRATE_LIMIT) { + uart_config.source_clk = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 250 Kbps + log_v("Setting UART%d to use REF_TICK clock", uart_nr); + } else { + uart_config.source_clk = UART_SCLK_APB; // baudrate may change with the APB Frequency! + log_v("Setting UART%d to use APB clock", uart_nr); + } #else - // Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6 - uart_config.source_clk = UART_SCLK_DEFAULT; // baudrate may change with the APB Frequency! + // Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6 + uart_config.source_clk = UART_SCLK_DEFAULT; // baudrate may change with the APB Frequency! + log_v("Setting UART%d to use DEFAULT clock", uart_nr); #endif + } UART_MUTEX_LOCK(); bool retCode = ESP_OK == uart_driver_install(uart_nr, rx_buffer_size, tx_buffer_size, 20, &(uart->uart_event_queue), 0); @@ -611,16 +774,25 @@ bool uartSetRxFIFOFull(uart_t *uart, uint8_t numBytesFIFOFull) { if (uart == NULL) { return false; } - + uint8_t rxfifo_full_thrhd = numBytesFIFOFull >= UART_HW_FIFO_LEN(uart->num) ? UART_HW_FIFO_LEN(uart->num) - 6 : numBytesFIFOFull; UART_MUTEX_LOCK(); - bool retCode = (ESP_OK == uart_set_rx_full_threshold(uart->num, numBytesFIFOFull)); + bool retCode = (ESP_OK == uart_set_rx_full_threshold(uart->num, rxfifo_full_thrhd)); + if (retCode) { + uart->_rxfifo_full_thrhd = rxfifo_full_thrhd; + if (rxfifo_full_thrhd != numBytesFIFOFull) { + log_w("The RX FIFO Full value for UART%d was set to %d instead of %d", uart->num, rxfifo_full_thrhd, numBytesFIFOFull); + } + log_v("UART%d RX FIFO Full value set to %d from a requested value of %d", uart->num, rxfifo_full_thrhd, numBytesFIFOFull); + } else { + log_e("UART%d failed to set RX FIFO Full value to %d", uart->num, numBytesFIFOFull); + } UART_MUTEX_UNLOCK(); return retCode; } void uartEnd(uint8_t uart_num) { - if (uart_num >= SOC_UART_HP_NUM) { - log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_HP_NUM - 1); + if (uart_num >= SOC_UART_NUM) { + log_e("Serial number is invalid, please use number from 0 to %u", SOC_UART_NUM - 1); return; } // get UART information @@ -645,7 +817,7 @@ void uartSetRxInvert(uart_t *uart, bool invert) { // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_RXD_INV)); // else // ESP_ERROR_CHECK(uart_set_line_inverse(uart->num, UART_SIGNAL_INV_DISABLE)); - + log_e("uartSetRxInvert is not supported in ESP32C6, ESP32H2 and ESP32P4"); #else // this implementation is better over IDF API because it only affects RXD // this is supported in ESP32, ESP32-S2 and ESP32-C3 @@ -805,11 +977,23 @@ void uartSetBaudRate(uart_t *uart, uint32_t baud_rate) { return; } UART_MUTEX_LOCK(); -#if !SOC_UART_SUPPORT_XTAL_CLK +#if SOC_UART_SUPPORT_XTAL_CLK // ESP32-S3, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-H2 and ESP32-P4 + soc_module_clk_t newClkSrc = UART_SCLK_XTAL; +#if SOC_UART_LP_NUM >= 1 + if (uart->num >= SOC_UART_HP_NUM) { // it is a LP UART NUM + newClkSrc = LP_UART_SCLK_DEFAULT; // use default LP clock + } +#endif + // ESP32-P4 demands an atomic operation for setting the clock source + HP_UART_SRC_CLK_ATOMIC() { + uart_ll_set_sclk(UART_LL_GET_HW(uart->num), newClkSrc); + } +#else // ESP32, ESP32-S2 soc_module_clk_t newClkSrc = baud_rate <= REF_TICK_BAUDRATE_LIMIT ? SOC_MOD_CLK_REF_TICK : SOC_MOD_CLK_APB; uart_ll_set_sclk(UART_LL_GET_HW(uart->num), newClkSrc); #endif if (uart_set_baudrate(uart->num, baud_rate) == ESP_OK) { + log_v("Setting UART%d baud rate to %d.", uart->num, baud_rate); uart->_baudrate = baud_rate; } else { log_e("Setting UART%d baud rate to %d has failed.", uart->num, baud_rate); @@ -889,7 +1073,7 @@ void uart_install_putc() { // Routines that take care of UART mode in the HardwareSerial Class code // used to set UART_MODE_RS485_HALF_DUPLEX auto RTS for TXD for ESP32 chips bool uartSetMode(uart_t *uart, uart_mode_t mode) { - if (uart == NULL || uart->num >= SOC_UART_HP_NUM) { + if (uart == NULL || uart->num >= SOC_UART_NUM) { return false; } @@ -900,6 +1084,7 @@ bool uartSetMode(uart_t *uart, uart_mode_t mode) { } void uartSetDebug(uart_t *uart) { + // LP UART is not supported for debug if (uart == NULL || uart->num >= SOC_UART_HP_NUM) { s_uart_debug_nr = -1; } else { @@ -1170,7 +1355,9 @@ unsigned long uartDetectBaudrate(uart_t *uart) { This creates a loop that lets us receive anything we send on the UART without external wires. */ void uart_internal_loopback(uint8_t uartNum, int8_t rxPin) { - if (uartNum > SOC_UART_HP_NUM - 1 || !GPIO_IS_VALID_GPIO(rxPin)) { + // LP UART is not supported for loopback + if (uartNum >= SOC_UART_HP_NUM || !GPIO_IS_VALID_GPIO(rxPin)) { + log_e("UART%d is not supported for loopback or RX pin %d is invalid.", uartNum, rxPin); return; } esp_rom_gpio_connect_out_signal(rxPin, UART_TX_SIGNAL(uartNum), false, false); diff --git a/cores/esp32/esp32-hal-uart.h b/cores/esp32/esp32-hal-uart.h index 402b5785915..74249194da3 100644 --- a/cores/esp32/esp32-hal-uart.h +++ b/cores/esp32/esp32-hal-uart.h @@ -1,4 +1,4 @@ -// Copyright 2015-2023 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2025 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include "soc/soc_caps.h" #if SOC_UART_SUPPORTED +#include "soc/uart_pins.h" #ifdef __cplusplus extern "C" { diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index d0bd4b8bc93..5ed99aeb205 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -121,11 +121,11 @@ void feedLoopWDT(); //enable/disable WDT for the IDLE task on Core 0 (SYSTEM) void enableCore0WDT(); -void disableCore0WDT(); +bool disableCore0WDT(); #ifndef CONFIG_FREERTOS_UNICORE //enable/disable WDT for the IDLE task on Core 1 (Arduino) void enableCore1WDT(); -void disableCore1WDT(); +bool disableCore1WDT(); #endif //if xCoreID < 0 or CPU is unicore, it will use xTaskCreate, else xTaskCreatePinnedToCore diff --git a/cores/esp32/esp_arduino_version.h b/cores/esp32/esp_arduino_version.h index dece36df1b8..b1355e908ae 100644 --- a/cores/esp32/esp_arduino_version.h +++ b/cores/esp32/esp_arduino_version.h @@ -21,9 +21,9 @@ extern "C" { /** Major version number (X.x.x) */ #define ESP_ARDUINO_VERSION_MAJOR 3 /** Minor version number (x.X.x) */ -#define ESP_ARDUINO_VERSION_MINOR 1 +#define ESP_ARDUINO_VERSION_MINOR 2 /** Patch version number (x.x.X) */ -#define ESP_ARDUINO_VERSION_PATCH 1 +#define ESP_ARDUINO_VERSION_PATCH 0 /** * Macro to convert ARDUINO version number into an integer diff --git a/docs/en/contributing.rst b/docs/en/contributing.rst index fb7843f1fb6..4093c60ec64 100644 --- a/docs/en/contributing.rst +++ b/docs/en/contributing.rst @@ -318,7 +318,7 @@ ESP32-C3 target, you would run: ./.github/scripts/tests_build.sh -s uart -t esp32c3 -You should see the output of the build process and the test binary should be generated in the ``~/.arduino/tests//build.tmp`` folder. +You should see the output of the build process and the test binary should be generated in the ``~/.arduino/tests///build.tmp`` folder. Now that the test is built, you can run it in the target board. Connect the target board to your computer and run: @@ -339,7 +339,7 @@ The test will run on the target board and you should see the output of the test lucassvaz@Lucas--MacBook-Pro esp32 % ./.github/scripts/tests_run.sh -s uart -t esp32c3 Sketch uart test type: validation Running test: uart -- Config: Default - pytest tests --build-dir /Users/lucassvaz/.arduino/tests/uart/build.tmp -k test_uart --junit-xml=/Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests/validation/uart/esp32c3/uart.xml --embedded-services esp,arduino + pytest tests --build-dir /Users/lucassvaz/.arduino/tests/esp32c3/uart/build.tmp -k test_uart --junit-xml=/Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests/validation/uart/esp32c3/uart.xml --embedded-services esp,arduino =============================================================================================== test session starts ================================================================================================ platform darwin -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0 rootdir: /Users/lucassvaz/Espressif/Arduino/hardware/espressif/esp32/tests diff --git a/idf_component.yml b/idf_component.yml index 9c6bd159d42..967c4ecf0f6 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -44,7 +44,7 @@ files: - "platform.txt" - "programmers.txt" dependencies: - idf: ">=5.3,<5.4" + idf: ">=5.3,<5.5" # mdns 1.2.1 is necessary to build H2 with no WiFi espressif/mdns: version: "^1.2.3" @@ -52,12 +52,12 @@ dependencies: espressif/esp_modem: version: "^1.1.0" espressif/esp-zboss-lib: - version: "==1.6.0" + version: "==1.6.3" require: public rules: - if: "target not in [esp32c2, esp32p4]" espressif/esp-zigbee-lib: - version: "==1.6.0" + version: "==1.6.3" require: public rules: - if: "target not in [esp32c2, esp32p4]" @@ -69,7 +69,7 @@ dependencies: espressif/network_provisioning: version: "1.0.2" espressif/esp_rainmaker: - version: "1.5.0" + version: "1.5.2" rules: - if: "target not in [esp32c2, esp32p4]" espressif/rmaker_common: @@ -77,16 +77,16 @@ dependencies: rules: - if: "target not in [esp32c2, esp32p4]" espressif/esp_insights: - version: "1.0.1" + version: "1.2.2" rules: - if: "target not in [esp32c2, esp32p4]" # New version breaks esp_insights 1.0.1 espressif/esp_diag_data_store: - version: "1.0.1" + version: "1.0.2" rules: - if: "target not in [esp32c2, esp32p4]" espressif/esp_diagnostics: - version: "1.0.2" + version: "1.2.1" rules: - if: "target not in [esp32c2, esp32p4]" espressif/cbor: diff --git a/libraries/ArduinoOTA/library.properties b/libraries/ArduinoOTA/library.properties index 524564ff699..0796eddf318 100644 --- a/libraries/ArduinoOTA/library.properties +++ b/libraries/ArduinoOTA/library.properties @@ -1,5 +1,5 @@ name=ArduinoOTA -version=3.1.1 +version=3.2.0 author=Ivan Grokhotkov and Hristo Gochkov maintainer=Hristo Gochkov sentence=Enables Over The Air upgrades, via wifi and espota.py UDP request/TCP download. diff --git a/libraries/ArduinoOTA/src/ArduinoOTA.cpp b/libraries/ArduinoOTA/src/ArduinoOTA.cpp index 0ab5466ab20..cb3ddc1e797 100644 --- a/libraries/ArduinoOTA/src/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/src/ArduinoOTA.cpp @@ -29,7 +29,7 @@ ArduinoOTAClass::ArduinoOTAClass() _start_callback(NULL), _end_callback(NULL), _error_callback(NULL), _progress_callback(NULL) {} ArduinoOTAClass::~ArduinoOTAClass() { - _udp_ota.stop(); + end(); } ArduinoOTAClass &ArduinoOTAClass::onStart(THandlerFunction fn) { diff --git a/libraries/AsyncUDP/library.properties b/libraries/AsyncUDP/library.properties index 5b1afd68273..116dcbacaa8 100644 --- a/libraries/AsyncUDP/library.properties +++ b/libraries/AsyncUDP/library.properties @@ -1,5 +1,5 @@ name=ESP32 Async UDP -version=3.1.1 +version=3.2.0 author=Me-No-Dev maintainer=Me-No-Dev sentence=Async UDP Library for ESP32 diff --git a/libraries/BLE/library.properties b/libraries/BLE/library.properties index afda29db686..7ef636223ec 100644 --- a/libraries/BLE/library.properties +++ b/libraries/BLE/library.properties @@ -1,5 +1,5 @@ name=BLE -version=3.1.1 +version=3.2.0 author=Neil Kolban maintainer=Dariusz Krempa sentence=BLE functions for ESP32 diff --git a/libraries/BluetoothSerial/library.properties b/libraries/BluetoothSerial/library.properties index cf0dab07aa7..0a382410bba 100644 --- a/libraries/BluetoothSerial/library.properties +++ b/libraries/BluetoothSerial/library.properties @@ -1,5 +1,5 @@ name=BluetoothSerial -version=3.1.1 +version=3.2.0 author=Evandro Copercini maintainer=Evandro Copercini sentence=Simple UART to Classical Bluetooth bridge for ESP32 diff --git a/libraries/DNSServer/library.properties b/libraries/DNSServer/library.properties index 8a6d1786625..5e70a6ec03a 100644 --- a/libraries/DNSServer/library.properties +++ b/libraries/DNSServer/library.properties @@ -1,5 +1,5 @@ name=DNSServer -version=3.1.1 +version=3.2.0 author=Kristijan Novoselić maintainer=Kristijan Novoselić, sentence=A simple DNS server for ESP32. diff --git a/libraries/EEPROM/library.properties b/libraries/EEPROM/library.properties index d66116947c7..c7e48501c04 100644 --- a/libraries/EEPROM/library.properties +++ b/libraries/EEPROM/library.properties @@ -1,5 +1,5 @@ name=EEPROM -version=3.1.1 +version=3.2.0 author=Ivan Grokhotkov maintainer=Paolo Becchi sentence=Enables reading and writing data a sequential, addressable FLASH storage diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp index 6b62ee9b6cf..81d643e37ac 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp +++ b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp @@ -281,6 +281,8 @@ static esp_err_t stream_handler(httpd_req_t *req) { int64_t fr_end = esp_timer_get_time(); int64_t frame_time = fr_end - last_frame; + last_frame = fr_end; + frame_time /= 1000; #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_INFO uint32_t avg_frame_time = ra_filter_run(&ra_filter, frame_time); diff --git a/libraries/ESP32/library.properties b/libraries/ESP32/library.properties index 160b392f39e..7ebc69be71f 100644 --- a/libraries/ESP32/library.properties +++ b/libraries/ESP32/library.properties @@ -1,5 +1,5 @@ name=ESP32 -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov maintainer=Hristo Gochkov sentence=ESP32 sketches examples diff --git a/libraries/ESP_I2S/library.properties b/libraries/ESP_I2S/library.properties index 3105266d708..263e9823275 100644 --- a/libraries/ESP_I2S/library.properties +++ b/libraries/ESP_I2S/library.properties @@ -1,5 +1,5 @@ name=ESP_I2S -version=3.1.1 +version=3.2.0 author=me-no-dev maintainer=me-no-dev sentence=Library for ESP I2S communication diff --git a/libraries/ESP_I2S/src/ESP_I2S.cpp b/libraries/ESP_I2S/src/ESP_I2S.cpp index d0ceb0c4b4c..6bf8089e48a 100644 --- a/libraries/ESP_I2S/src/ESP_I2S.cpp +++ b/libraries/ESP_I2S/src/ESP_I2S.cpp @@ -11,6 +11,12 @@ #include "mp3dec.h" #endif +#if SOC_I2S_HW_VERSION_2 +#undef I2S_STD_CLK_DEFAULT_CONFIG +#define I2S_STD_CLK_DEFAULT_CONFIG(rate) \ + { .sample_rate_hz = rate, .clk_src = I2S_CLK_SRC_DEFAULT, .ext_clk_freq_hz = 0, .mclk_multiple = I2S_MCLK_MULTIPLE_256, } +#endif + #define I2S_READ_CHUNK_SIZE 1920 #define I2S_DEFAULT_CFG() \ diff --git a/libraries/ESP_NOW/library.properties b/libraries/ESP_NOW/library.properties index ba52e080046..f3e5c109a9b 100644 --- a/libraries/ESP_NOW/library.properties +++ b/libraries/ESP_NOW/library.properties @@ -1,5 +1,5 @@ name=ESP_NOW -version=3.1.1 +version=3.2.0 author=me-no-dev maintainer=P-R-O-C-H-Y sentence=Library for ESP_NOW diff --git a/libraries/ESP_SR/library.properties b/libraries/ESP_SR/library.properties index b52c0552cbb..295761bd9fb 100644 --- a/libraries/ESP_SR/library.properties +++ b/libraries/ESP_SR/library.properties @@ -1,5 +1,5 @@ name=ESP_SR -version=3.1.1 +version=3.2.0 author=me-no-dev maintainer=me-no-dev sentence=Library for ESP Sound Recognition diff --git a/libraries/ESPmDNS/library.properties b/libraries/ESPmDNS/library.properties index fe06ddb6851..6d36d61b783 100644 --- a/libraries/ESPmDNS/library.properties +++ b/libraries/ESPmDNS/library.properties @@ -1,5 +1,5 @@ name=ESPmDNS -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov maintainer=Hristo Gochkov sentence=ESP32 mDNS Library diff --git a/libraries/Ethernet/library.properties b/libraries/Ethernet/library.properties index e8075d15f11..d34ae036417 100644 --- a/libraries/Ethernet/library.properties +++ b/libraries/Ethernet/library.properties @@ -1,5 +1,5 @@ name=Ethernet -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Enables network connection (local and Internet) using the ESP32 Ethernet. diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index fa8a2b97122..542a7e2a218 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -271,8 +271,8 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i eth_mac_config.sw_reset_timeout_ms = 1000; eth_mac_config.rx_task_stack_size = _task_stack_size; - esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, ð_mac_config); - if (mac == NULL) { + _mac = esp_eth_mac_new_esp32(&mac_config, ð_mac_config); + if (_mac == NULL) { log_e("esp_eth_mac_new_esp32 failed"); return false; } @@ -281,23 +281,25 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i phy_config.phy_addr = phy_addr; phy_config.reset_gpio_num = _pin_power; - esp_eth_phy_t *phy = NULL; switch (type) { - case ETH_PHY_LAN8720: phy = esp_eth_phy_new_lan87xx(&phy_config); break; - case ETH_PHY_TLK110: phy = esp_eth_phy_new_ip101(&phy_config); break; - case ETH_PHY_RTL8201: phy = esp_eth_phy_new_rtl8201(&phy_config); break; - case ETH_PHY_DP83848: phy = esp_eth_phy_new_dp83848(&phy_config); break; - case ETH_PHY_KSZ8041: phy = esp_eth_phy_new_ksz80xx(&phy_config); break; - case ETH_PHY_KSZ8081: phy = esp_eth_phy_new_ksz80xx(&phy_config); break; +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) + case ETH_PHY_GENERIC: _phy = esp_eth_phy_new_generic(&phy_config); break; +#endif + case ETH_PHY_LAN8720: _phy = esp_eth_phy_new_lan87xx(&phy_config); break; + case ETH_PHY_TLK110: _phy = esp_eth_phy_new_ip101(&phy_config); break; + case ETH_PHY_RTL8201: _phy = esp_eth_phy_new_rtl8201(&phy_config); break; + case ETH_PHY_DP83848: _phy = esp_eth_phy_new_dp83848(&phy_config); break; + case ETH_PHY_KSZ8041: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break; + case ETH_PHY_KSZ8081: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break; default: log_e("Unsupported PHY %d", type); break; } - if (phy == NULL) { + if (_phy == NULL) { log_e("esp_eth_phy_new failed"); return false; } _eth_handle = NULL; - esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy); + esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(_mac, _phy); ret = esp_eth_driver_install(ð_config, &_eth_handle); if (ret != ESP_OK) { log_e("Ethernet driver install failed: %d", ret); @@ -1007,6 +1009,18 @@ bool ETHClass::fullDuplex() const { return (link_duplex == ETH_DUPLEX_FULL); } +bool ETHClass::setFullDuplex(bool on) { + if (_eth_handle == NULL) { + return false; + } + eth_duplex_t link_duplex = on ? ETH_DUPLEX_FULL : ETH_DUPLEX_HALF; + esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_DUPLEX_MODE, &link_duplex); + if (err != ESP_OK) { + log_e("Failed to set duplex mode: 0x%x: %s", err, esp_err_to_name(err)); + } + return err == ESP_OK; +} + bool ETHClass::autoNegotiation() const { if (_eth_handle == NULL) { return false; @@ -1016,6 +1030,17 @@ bool ETHClass::autoNegotiation() const { return auto_nego; } +bool ETHClass::setAutoNegotiation(bool on) { + if (_eth_handle == NULL) { + return false; + } + esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_AUTONEGO, &on); + if (err != ESP_OK) { + log_e("Failed to set auto negotiation: 0x%x: %s", err, esp_err_to_name(err)); + } + return err == ESP_OK; +} + uint32_t ETHClass::phyAddr() const { if (_eth_handle == NULL) { return 0; @@ -1025,7 +1050,7 @@ uint32_t ETHClass::phyAddr() const { return phy_addr; } -uint8_t ETHClass::linkSpeed() const { +uint16_t ETHClass::linkSpeed() const { if (_eth_handle == NULL) { return 0; } @@ -1034,6 +1059,18 @@ uint8_t ETHClass::linkSpeed() const { return (link_speed == ETH_SPEED_10M) ? 10 : 100; } +bool ETHClass::setLinkSpeed(uint16_t speed) { + if (_eth_handle == NULL) { + return false; + } + eth_speed_t link_speed = (speed == 10) ? ETH_SPEED_10M : ETH_SPEED_100M; + esp_err_t err = esp_eth_ioctl(_eth_handle, ETH_CMD_S_SPEED, &link_speed); + if (err != ESP_OK) { + log_e("Failed to set link speed: 0x%x: %s", err, esp_err_to_name(err)); + } + return err == ESP_OK; +} + // void ETHClass::getMac(uint8_t* mac) // { // if(_eth_handle != NULL && mac != NULL){ diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index 582835cf8ac..891863e34bf 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -23,6 +23,7 @@ #ifndef _ETH_H_ #define _ETH_H_ +#include "esp_idf_version.h" // // Example configurations for pins_arduino.h to allow starting with ETH.begin(); @@ -127,6 +128,10 @@ typedef emac_rmii_clock_mode_t eth_clock_mode_t; typedef enum { #if CONFIG_ETH_USE_ESP32_EMAC +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) + ETH_PHY_GENERIC, +#define ETH_PHY_JL1101 ETH_PHY_GENERIC +#endif ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, @@ -187,8 +192,14 @@ class ETHClass : public NetworkInterface { // ETH Handle APIs bool fullDuplex() const; - uint8_t linkSpeed() const; + bool setFullDuplex(bool on); + + uint16_t linkSpeed() const; + bool setLinkSpeed(uint16_t speed); //10 or 100 + bool autoNegotiation() const; + bool setAutoNegotiation(bool on); + uint32_t phyAddr() const; esp_eth_handle_t handle() const; diff --git a/libraries/FFat/library.properties b/libraries/FFat/library.properties index e75ef4206a6..35940fd5472 100644 --- a/libraries/FFat/library.properties +++ b/libraries/FFat/library.properties @@ -1,5 +1,5 @@ name=FFat -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov, Larry Bernstone maintainer=Hristo Gochkov sentence=ESP32 FAT on Flash File System diff --git a/libraries/FS/library.properties b/libraries/FS/library.properties index b339f57356f..07bd296bb83 100644 --- a/libraries/FS/library.properties +++ b/libraries/FS/library.properties @@ -1,5 +1,5 @@ name=FS -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov maintainer=Hristo Gochkov sentence=ESP32 File System diff --git a/libraries/HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino b/libraries/HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino index eb6caef0724..73e127d1261 100644 --- a/libraries/HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino +++ b/libraries/HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino @@ -14,30 +14,32 @@ #include -// This is a Baltimore CyberTrust cert, the root Certificate Authority that +// This is a Google Trust Services cert, the root Certificate Authority that // signed the server certificate for the demo server https://jigsaw.w3.org in this -// example. This certificate is valid until Mon, 12 May 2025 23:59:00 GMT -const char *rootCACertificate = "-----BEGIN CERTIFICATE-----\n" - "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" - "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" - "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" - "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" - "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" - "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" - "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" - "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" - "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" - "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" - "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" - "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" - "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" - "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" - "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" - "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" - "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" - "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" - "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" - "-----END CERTIFICATE-----\n"; +// example. This certificate is valid until Jan 28 00:00:42 2028 GMT +const char *rootCACertificate = R"string_literal( +-----BEGIN CERTIFICATE----- +MIIDejCCAmKgAwIBAgIQf+UwvzMTQ77dghYQST2KGzANBgkqhkiG9w0BAQsFADBX +MQswCQYDVQQGEwJCRTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTEQMA4GA1UE +CxMHUm9vdCBDQTEbMBkGA1UEAxMSR2xvYmFsU2lnbiBSb290IENBMB4XDTIzMTEx +NTAzNDMyMVoXDTI4MDEyODAwMDA0MlowRzELMAkGA1UEBhMCVVMxIjAgBgNVBAoT +GUdvb2dsZSBUcnVzdCBTZXJ2aWNlcyBMTEMxFDASBgNVBAMTC0dUUyBSb290IFI0 +MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE83Rzp2iLYK5DuDXFgTB7S0md+8Fhzube +Rr1r1WEYNa5A3XP3iZEwWus87oV8okB2O6nGuEfYKueSkWpz6bFyOZ8pn6KY019e +WIZlD6GEZQbR3IvJx3PIjGov5cSr0R2Ko4H/MIH8MA4GA1UdDwEB/wQEAwIBhjAd +BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDwYDVR0TAQH/BAUwAwEB/zAd +BgNVHQ4EFgQUgEzW63T/STaj1dj8tT7FavCUHYwwHwYDVR0jBBgwFoAUYHtmGkUN +l8qJUC99BM00qP/8/UswNgYIKwYBBQUHAQEEKjAoMCYGCCsGAQUFBzAChhpodHRw +Oi8vaS5wa2kuZ29vZy9nc3IxLmNydDAtBgNVHR8EJjAkMCKgIKAehhxodHRwOi8v +Yy5wa2kuZ29vZy9yL2dzcjEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqG +SIb3DQEBCwUAA4IBAQAYQrsPBtYDh5bjP2OBDwmkoWhIDDkic574y04tfzHpn+cJ +odI2D4SseesQ6bDrarZ7C30ddLibZatoKiws3UL9xnELz4ct92vID24FfVbiI1hY ++SW6FoVHkNeWIP0GCbaM4C6uVdF5dTUsMVs/ZbzNnIdCp5Gxmx5ejvEau8otR/Cs +kGN+hr/W5GvT1tMBjgWKZ1i4//emhA1JG1BbPzoLJQvyEotc03lXjTaCzv8mEbep +8RqZ7a2CPsgRbuvTPBwcOMBBmuFeU88+FSBX6+7iP0il8b4Z0QFqIwwMHfs/L6K1 +vepuoxtGzi4CZ68zJpiq1UvSqTbFJjtbD4seiMHl +-----END CERTIFICATE----- +)string_literal"; // Not sure if NetworkClientSecure checks the validity date of the certificate. // Setting clock just to be sure... diff --git a/libraries/HTTPClient/library.properties b/libraries/HTTPClient/library.properties index df11cb033b8..f2dafc36d1b 100644 --- a/libraries/HTTPClient/library.properties +++ b/libraries/HTTPClient/library.properties @@ -1,5 +1,5 @@ name=HTTPClient -version=3.1.1 +version=3.2.0 author=Markus Sattler maintainer=Markus Sattler sentence=HTTP Client for ESP32 diff --git a/libraries/HTTPUpdate/library.properties b/libraries/HTTPUpdate/library.properties index dc02780c8d2..419f3b97b3f 100644 --- a/libraries/HTTPUpdate/library.properties +++ b/libraries/HTTPUpdate/library.properties @@ -1,5 +1,5 @@ name=HTTPUpdate -version=3.1.1 +version=3.2.0 author=Markus Sattler maintainer=Markus Sattler sentence=Http Update for ESP32 diff --git a/libraries/HTTPUpdateServer/library.properties b/libraries/HTTPUpdateServer/library.properties index 6cdcc1b34ea..9c793a26ac8 100644 --- a/libraries/HTTPUpdateServer/library.properties +++ b/libraries/HTTPUpdateServer/library.properties @@ -1,5 +1,5 @@ name=HTTPUpdateServer -version=3.1.1 +version=3.2.0 author=Hristo Kapanakov maintainer= sentence=Simple HTTP Update server based on the WebServer diff --git a/libraries/Insights/library.properties b/libraries/Insights/library.properties index 39b1f80c876..fefe5aab177 100644 --- a/libraries/Insights/library.properties +++ b/libraries/Insights/library.properties @@ -1,5 +1,5 @@ name=ESP Insights -version=3.1.1 +version=3.2.0 author=Sanket Wadekar maintainer=Sanket Wadekar sentence=ESP Insights diff --git a/libraries/LittleFS/library.properties b/libraries/LittleFS/library.properties index 9f665385dce..a9dae69b7f8 100644 --- a/libraries/LittleFS/library.properties +++ b/libraries/LittleFS/library.properties @@ -1,5 +1,5 @@ name=LittleFS -version=3.1.1 +version=3.2.0 author= maintainer= sentence=LittleFS for esp32 diff --git a/libraries/LittleFS/src/LittleFS.cpp b/libraries/LittleFS/src/LittleFS.cpp index e86caeb74cc..761d1ba4c24 100644 --- a/libraries/LittleFS/src/LittleFS.cpp +++ b/libraries/LittleFS/src/LittleFS.cpp @@ -95,9 +95,11 @@ void LittleFSFS::end() { } bool LittleFSFS::format() { - disableCore0WDT(); + bool wdt_active = disableCore0WDT(); esp_err_t err = esp_littlefs_format(partitionLabel_); - enableCore0WDT(); + if (wdt_active) { + enableCore0WDT(); + } if (err) { log_e("Formatting LittleFS failed! Error: %d", err); return false; diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index dd1724f602d..f3e45887576 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) { analogWrite(ledPin, colorHSV.v); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last HSV Color and OnOff state for when the Light is restarted / power goes off diff --git a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino index 9c3dcf05a83..b98cc8e19c9 100644 --- a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino +++ b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino @@ -128,7 +128,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning the Composed Light Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino b/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino index e27f70e613d..e4c41460d3a 100644 --- a/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino +++ b/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino @@ -140,7 +140,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Contact Sensor Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index cb8b8b6f17f..79751905c20 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) { analogWrite(ledPin, brightness); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last Brightness and OnOff state for when the Light is restarted / power goes off diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index bd2d13899ca..8e12581fdf2 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint analogWrite(ledPin, colorHSV.v); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last HSV Color and OnOff state for when the Light is restarted / power goes off diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index 3dc0c89fcf4..705aa4853da 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) { // drive the Fan DC motor if (fanState == false) { // turn off the Fan +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(dcMotorPin, OUTPUT); +#endif digitalWrite(dcMotorPin, LOW); } else { // set the Fan speed @@ -180,7 +184,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Fan Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino b/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino index 3fcab46c565..1c7889db849 100644 --- a/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino +++ b/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino @@ -122,7 +122,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Humidity Sensor Matter Accessory. It shall be commissioned again."); Matter.decommission(); } diff --git a/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino b/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino index e88a9a8986b..333f178e9de 100644 --- a/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino +++ b/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino @@ -116,7 +116,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Occupancy Sensor Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino b/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino index 394a217b87a..db035e951c9 100644 --- a/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino +++ b/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino @@ -122,8 +122,8 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - // Factory reset is triggered if the button is pressed longer than 10 seconds - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + // Factory reset is triggered if the button is pressed longer than 5 seconds + Serial.println("Decommissioning Pressure Sensor Matter Accessory. It shall be commissioned again."); Matter.decommission(); } diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index b814ba89704..d46427591ab 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds) analogWrite(ledPin, brightness); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last Brightness and OnOff state for when the Light is restarted / power goes off diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index a2866e4655e..086155aeffe 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -122,7 +122,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Temperature Sensor Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/examples/MatterThermostat/MatterThermostat.ino b/libraries/Matter/examples/MatterThermostat/MatterThermostat.ino index 508b508573a..bf76477c846 100644 --- a/libraries/Matter/examples/MatterThermostat/MatterThermostat.ino +++ b/libraries/Matter/examples/MatterThermostat/MatterThermostat.ino @@ -234,7 +234,7 @@ void loop() { // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node uint32_t time_diff = millis() - button_time_stamp; if (button_state && time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Serial.println("Decommissioning Thermostat Matter Accessory. It shall be commissioned again."); Matter.decommission(); button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } diff --git a/libraries/Matter/library.properties b/libraries/Matter/library.properties index 14a7f48c6de..ac9e0964ab5 100644 --- a/libraries/Matter/library.properties +++ b/libraries/Matter/library.properties @@ -1,5 +1,5 @@ name=Matter -version=3.1.1 +version=3.2.0 author=Rodrigo Garcia | GitHub @SuGlider maintainer=Rodrigo Garcia sentence=Library for supporting Matter environment on ESP32. diff --git a/libraries/Matter/src/MatterEndpoints/MatterColorLight.h b/libraries/Matter/src/MatterEndpoints/MatterColorLight.h index b896afa9b7a..99449addd50 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterColorLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterColorLight.h @@ -66,8 +66,8 @@ class MatterColorLight : public MatterEndPoint { protected: bool started = false; - bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) - espHsvColor_t colorHSV = {0}; // default initial color HSV is black, but it can be changed by begin(bool, espHsvColor_t) + bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) + espHsvColor_t colorHSV = {0, 0, 0}; // default initial color HSV is black, but it can be changed by begin(bool, espHsvColor_t) EndPointOnOffCB _onChangeOnOffCB = NULL; EndPointRGBColorCB _onChangeColorCB = NULL; EndPointCB _onChangeCB = NULL; diff --git a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h index ff6e69e3e65..a4baef968a4 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h @@ -91,7 +91,7 @@ class MatterEnhancedColorLight : public MatterEndPoint { bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) uint8_t brightnessLevel = 0; // default initial brightness is 0, but it can be changed by begin(bool, uint8_t) - espHsvColor_t colorHSV = {0}; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t) + espHsvColor_t colorHSV = {0, 0, 0}; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t) uint16_t colorTemperatureLevel = 0; // default initial color temperature is 0, but it can be changed by begin(bool, uint8_t, espHsvColor_t, uint16_t) EndPointOnOffCB _onChangeOnOffCB = NULL; EndPointBrightnessCB _onChangeBrightnessCB = NULL; diff --git a/libraries/NetBIOS/library.properties b/libraries/NetBIOS/library.properties index f28405b7f64..5f134bfdc55 100644 --- a/libraries/NetBIOS/library.properties +++ b/libraries/NetBIOS/library.properties @@ -1,5 +1,5 @@ name=NetBIOS -version=3.1.1 +version=3.2.0 author=Pablo@xpablo.cz maintainer=Hristo Gochkov sentence=Enables NBNS (NetBIOS) name resolution. diff --git a/libraries/Network/library.properties b/libraries/Network/library.properties index d3a9f329306..0b821e08d77 100644 --- a/libraries/Network/library.properties +++ b/libraries/Network/library.properties @@ -1,5 +1,5 @@ name=Networking -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=General network management library. diff --git a/libraries/Network/src/NetworkClient.cpp b/libraries/Network/src/NetworkClient.cpp index da83597d2c6..89411a42453 100644 --- a/libraries/Network/src/NetworkClient.cpp +++ b/libraries/Network/src/NetworkClient.cpp @@ -23,7 +23,11 @@ #include #include -#define IN6_IS_ADDR_V4MAPPED(a) ((((__const uint32_t *)(a))[0] == 0) && (((__const uint32_t *)(a))[1] == 0) && (((__const uint32_t *)(a))[2] == htonl(0xffff))) +// It is already defined in IDF as: +//#define IN6_IS_ADDR_V4MAPPED(a) ip6_addr_isipv4mappedipv6((ip6_addr_t*)(a)) +//#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL))) +// Keeping as a memory of the change. +//#define _IN6_IS_ADDR_V4MAPPED(a) ((((__const uint32_t *)(a))[0] == 0) && (((__const uint32_t *)(a))[1] == 0) && (((__const uint32_t *)(a))[2] == htonl(0xffff))) #define WIFI_CLIENT_DEF_CONN_TIMEOUT_MS (3000) #define WIFI_CLIENT_MAX_WRITE_RETRY (10) diff --git a/libraries/Network/src/NetworkEvents.cpp b/libraries/Network/src/NetworkEvents.cpp index 1a7177bae61..161e55c5d01 100644 --- a/libraries/Network/src/NetworkEvents.cpp +++ b/libraries/Network/src/NetworkEvents.cpp @@ -8,6 +8,10 @@ #include "esp_task.h" #include "esp32-hal.h" +#ifndef ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE +#define ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE 4096 +#endif + NetworkEvents::NetworkEvents() : _arduino_event_group(NULL), _arduino_event_queue(NULL), _arduino_event_task_handle(NULL) {} NetworkEvents::~NetworkEvents() { @@ -61,8 +65,8 @@ bool NetworkEvents::initNetworkEvents() { [](void *self) { static_cast(self)->_checkForEvent(); }, - "arduino_events", // label - 4096, // event task's stack size + "arduino_events", // label + ARDUINO_NETWORK_EVENT_TASK_STACK_SIZE, // event task's stack size this, ESP_TASKD_EVENT_PRIO - 1, &_arduino_event_task_handle, ARDUINO_EVENT_RUNNING_CORE ); if (!_arduino_event_task_handle) { diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp index 4f310821204..01790ec2493 100644 --- a/libraries/Network/src/NetworkInterface.cpp +++ b/libraries/Network/src/NetworkInterface.cpp @@ -81,7 +81,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) { ); #endif memcpy(&arduino_event.event_info.got_ip, event_data, sizeof(ip_event_got_ip_t)); -#if SOC_WIFI_SUPPORTED +#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED if (_interface_id == ESP_NETIF_ID_STA) { arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_GOT_IP; } else @@ -96,7 +96,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) { #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE log_v("%s Lost IP", desc()); #endif -#if SOC_WIFI_SUPPORTED +#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED if (_interface_id == ESP_NETIF_ID_STA) { arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_LOST_IP; } else @@ -123,7 +123,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) { ); #endif memcpy(&arduino_event.event_info.got_ip6, event_data, sizeof(ip_event_got_ip6_t)); -#if SOC_WIFI_SUPPORTED +#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED if (_interface_id == ESP_NETIF_ID_STA) { arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_GOT_IP6; } else if (_interface_id == ESP_NETIF_ID_AP) { @@ -136,7 +136,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) { arduino_event.event_id = ARDUINO_EVENT_ETH_GOT_IP6; } #endif /* CONFIG_LWIP_IPV6 */ -#if SOC_WIFI_SUPPORTED +#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED } else if (event_id == IP_EVENT_AP_STAIPASSIGNED && _interface_id == ESP_NETIF_ID_AP) { setStatusBits(ESP_NETIF_HAS_IP_BIT); #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE diff --git a/libraries/NetworkClientSecure/library.properties b/libraries/NetworkClientSecure/library.properties index 6d79dc61095..455dea6a2bf 100644 --- a/libraries/NetworkClientSecure/library.properties +++ b/libraries/NetworkClientSecure/library.properties @@ -1,5 +1,5 @@ name=NetworkClientSecure -version=3.1.1 +version=3.2.0 author=Evandro Luis Copercini maintainer=Github Community sentence=Enables secure network connection (local and Internet) using the ESP32 built-in WiFi. diff --git a/libraries/OpenThread/library.properties b/libraries/OpenThread/library.properties index a50a803dfa6..0e547d188aa 100644 --- a/libraries/OpenThread/library.properties +++ b/libraries/OpenThread/library.properties @@ -1,5 +1,5 @@ name=OpenThread -version=3.1.1 +version=3.2.0 author=Rodrigo Garcia | GitHub @SuGlider maintainer=Rodrigo Garcia sentence=Library for OpenThread Network on ESP32. diff --git a/libraries/PPP/library.properties b/libraries/PPP/library.properties index fefd89d4904..7158a027b0a 100644 --- a/libraries/PPP/library.properties +++ b/libraries/PPP/library.properties @@ -1,5 +1,5 @@ name=PPP -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Enables network connection using GSM Modem. diff --git a/libraries/Preferences/library.properties b/libraries/Preferences/library.properties index 842ade94003..eb0158e4932 100644 --- a/libraries/Preferences/library.properties +++ b/libraries/Preferences/library.properties @@ -1,5 +1,5 @@ name=Preferences -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Provides friendly access to ESP32's Non-Volatile Storage diff --git a/libraries/README.md b/libraries/README.md index 38765f99b52..aee5bb07614 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -88,6 +88,9 @@ arduino-esp32 includes libraries for Arduino compatibility along with some objec ### SPIFFS SPI Flash Filesystem (see [spiffs-plugin](https://github.com/me-no-dev/arduino-esp32fs-plugin) to upload to device) +### SR + ESP-SR helps users build AI speech solutions based on ESP32-S3 or ESP32-P4 chips + ### Ticker A timer to call functions on an interval diff --git a/libraries/RainMaker/examples/RMakerCustomAirCooler/ci.json b/libraries/RainMaker/examples/RMakerCustomAirCooler/ci.json index 1c80eda1d90..ce63fe9ccf0 100644 --- a/libraries/RainMaker/examples/RMakerCustomAirCooler/ci.json +++ b/libraries/RainMaker/examples/RMakerCustomAirCooler/ci.json @@ -1,4 +1,7 @@ { + "targets": { + "esp32": false + }, "fqbn_append": "PartitionScheme=rainmaker_4MB", "requires": [ "CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK=[1-9][0-9]*" diff --git a/libraries/RainMaker/examples/RMakerSonoffDualR3/ci.json b/libraries/RainMaker/examples/RMakerSonoffDualR3/ci.json index 1c80eda1d90..ce63fe9ccf0 100644 --- a/libraries/RainMaker/examples/RMakerSonoffDualR3/ci.json +++ b/libraries/RainMaker/examples/RMakerSonoffDualR3/ci.json @@ -1,4 +1,7 @@ { + "targets": { + "esp32": false + }, "fqbn_append": "PartitionScheme=rainmaker_4MB", "requires": [ "CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK=[1-9][0-9]*" diff --git a/libraries/RainMaker/library.properties b/libraries/RainMaker/library.properties index 2f49258e78d..95ce14d6708 100644 --- a/libraries/RainMaker/library.properties +++ b/libraries/RainMaker/library.properties @@ -1,5 +1,5 @@ name=ESP RainMaker -version=3.1.1 +version=3.2.0 author=Sweety Mhaiske maintainer=Hristo Gochkov sentence=ESP RainMaker Support diff --git a/libraries/SD/library.properties b/libraries/SD/library.properties index 117de77ca36..66c4f5cfafd 100644 --- a/libraries/SD/library.properties +++ b/libraries/SD/library.properties @@ -1,5 +1,5 @@ name=SD -version=3.1.1 +version=3.2.0 author=Arduino, SparkFun maintainer=Arduino sentence=Enables reading and writing on SD cards. For all Arduino boards. diff --git a/libraries/SD_MMC/library.properties b/libraries/SD_MMC/library.properties index 72c12c61d5c..855390e5057 100644 --- a/libraries/SD_MMC/library.properties +++ b/libraries/SD_MMC/library.properties @@ -1,5 +1,5 @@ name=SD_MMC -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov maintainer=Hristo Gochkov sentence=ESP32 SDMMC File System diff --git a/libraries/SPI/library.properties b/libraries/SPI/library.properties index 8c567f00d40..64db93aceeb 100644 --- a/libraries/SPI/library.properties +++ b/libraries/SPI/library.properties @@ -1,5 +1,5 @@ name=SPI -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. For all Arduino boards, BUT Arduino DUE. diff --git a/libraries/SPIFFS/library.properties b/libraries/SPIFFS/library.properties index 68cb55ca124..78f77fe9794 100644 --- a/libraries/SPIFFS/library.properties +++ b/libraries/SPIFFS/library.properties @@ -1,5 +1,5 @@ name=SPIFFS -version=3.1.1 +version=3.2.0 author=Hristo Gochkov, Ivan Grokhtkov maintainer=Hristo Gochkov sentence=ESP32 SPIFFS File System diff --git a/libraries/SPIFFS/src/SPIFFS.cpp b/libraries/SPIFFS/src/SPIFFS.cpp index a77b32990bf..0b2cc0d462d 100644 --- a/libraries/SPIFFS/src/SPIFFS.cpp +++ b/libraries/SPIFFS/src/SPIFFS.cpp @@ -91,9 +91,11 @@ void SPIFFSFS::end() { } bool SPIFFSFS::format() { - disableCore0WDT(); + bool wdt_active = disableCore0WDT(); esp_err_t err = esp_spiffs_format(partitionLabel_); - enableCore0WDT(); + if (wdt_active) { + enableCore0WDT(); + } if (err) { log_e("Formatting SPIFFS failed! Error: %d", err); return false; diff --git a/libraries/SimpleBLE/library.properties b/libraries/SimpleBLE/library.properties index a5541dd9750..ad5e10d3acb 100644 --- a/libraries/SimpleBLE/library.properties +++ b/libraries/SimpleBLE/library.properties @@ -1,5 +1,5 @@ name=SimpleBLE -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Provides really simple BLE advertizer with just on and off diff --git a/libraries/TFLiteMicro/library.properties b/libraries/TFLiteMicro/library.properties index ef9b474611f..1e8db045610 100644 --- a/libraries/TFLiteMicro/library.properties +++ b/libraries/TFLiteMicro/library.properties @@ -1,5 +1,5 @@ name=TFLite Micro -version=3.1.1 +version=3.2.0 author=Sanket Wadekar maintainer=Sanket Wadekar sentence=TensorFlow Lite for Microcontrollers diff --git a/libraries/Ticker/library.properties b/libraries/Ticker/library.properties index 8d123806109..975db96d1ad 100644 --- a/libraries/Ticker/library.properties +++ b/libraries/Ticker/library.properties @@ -1,5 +1,5 @@ name=Ticker -version=3.1.1 +version=3.2.0 author=Bert Melis maintainer=Hristo Gochkov sentence=Allows to call functions with a given interval. diff --git a/libraries/USB/library.properties b/libraries/USB/library.properties index 17d4e25cae2..9d47dfc6719 100644 --- a/libraries/USB/library.properties +++ b/libraries/USB/library.properties @@ -1,5 +1,5 @@ name=USB -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=ESP32S2 USB Library diff --git a/libraries/Update/library.properties b/libraries/Update/library.properties index 5af58e380e1..c3ee8f7e506 100644 --- a/libraries/Update/library.properties +++ b/libraries/Update/library.properties @@ -1,5 +1,5 @@ name=Update -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=ESP32 Sketch Update Library diff --git a/libraries/WebServer/library.properties b/libraries/WebServer/library.properties index c225d6ebd95..2a9ff530d57 100644 --- a/libraries/WebServer/library.properties +++ b/libraries/WebServer/library.properties @@ -1,5 +1,5 @@ name=WebServer -version=3.1.1 +version=3.2.0 author=Ivan Grokhotkov maintainer=Ivan Grokhtkov sentence=Simple web server library diff --git a/libraries/WiFi/library.properties b/libraries/WiFi/library.properties index a82ae45a2d2..03112c2fcc6 100644 --- a/libraries/WiFi/library.properties +++ b/libraries/WiFi/library.properties @@ -1,5 +1,5 @@ name=WiFi -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Enables network connection (local and Internet) using the ESP32 built-in WiFi. diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 40e3b12c687..aa994963514 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -308,7 +308,7 @@ bool wifiLowLevelInit(bool persistent) { esp_err_t err = esp_wifi_init(&cfg); if (err) { - log_e("esp_wifi_init %d", err); + log_e("esp_wifi_init 0x%x: %s", err, esp_err_to_name(err)); lowLevelInitDone = false; return lowLevelInitDone; } @@ -375,7 +375,7 @@ static bool espWiFiStart() { esp_err_t err = esp_wifi_start(); if (err != ESP_OK) { _esp_wifi_started = false; - log_e("esp_wifi_start %d", err); + log_e("esp_wifi_start 0x%x: %s", err, esp_err_to_name(err)); return _esp_wifi_started; } return _esp_wifi_started; @@ -389,7 +389,7 @@ static bool espWiFiStop() { _esp_wifi_started = false; err = esp_wifi_stop(); if (err) { - log_e("Could not stop WiFi! %d", err); + log_e("Could not stop WiFi! 0x%x: %s", err, esp_err_to_name(err)); _esp_wifi_started = true; return false; } @@ -478,7 +478,7 @@ int WiFiGenericClass::setChannel(uint8_t primary, wifi_second_chan_t secondary) ret = esp_wifi_get_country(&country); if (ret != ESP_OK) { - log_e("Failed to get country info"); + log_e("Failed to get country info 0x%x: %s", ret, esp_err_to_name(ret)); return ret; } @@ -492,7 +492,7 @@ int WiFiGenericClass::setChannel(uint8_t primary, wifi_second_chan_t secondary) ret = esp_wifi_set_channel(primary, secondary); if (ret != ESP_OK) { - log_e("Failed to set channel"); + log_e("Failed to set channel 0x%x: %s", ret, esp_err_to_name(ret)); return ret; } @@ -562,13 +562,13 @@ bool WiFiGenericClass::mode(wifi_mode_t m) { if (((m & WIFI_MODE_STA) != 0) && ((cm & WIFI_MODE_STA) == 0)) { err = esp_netif_set_hostname(esp_netifs[ESP_IF_WIFI_STA], NetworkManager::getHostname()); if (err) { - log_e("Could not set hostname! %d", err); + log_e("Could not set hostname! 0x%x: %s", err, esp_err_to_name(err)); return false; } } err = esp_wifi_set_mode(m); if (err) { - log_e("Could not set mode! %d", err); + log_e("Could not set mode! 0x%x: %s", err, esp_err_to_name(err)); return false; } @@ -585,17 +585,44 @@ bool WiFiGenericClass::mode(wifi_mode_t m) { if (m & WIFI_MODE_STA) { err = esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR); if (err != ESP_OK) { - log_e("Could not enable long range on STA! %d", err); + log_e("Could not enable long range on STA! 0x%x: %s", err, esp_err_to_name(err)); return false; } } if (m & WIFI_MODE_AP) { err = esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_LR); if (err != ESP_OK) { - log_e("Could not enable long range on AP! %d", err); + log_e("Could not enable long range on AP! 0x%x: %s", err, esp_err_to_name(err)); return false; } } + } else { +#if CONFIG_SOC_WIFI_HE_SUPPORT +#define WIFI_PROTOCOL_DEFAULT (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11AX) +#else +#define WIFI_PROTOCOL_DEFAULT (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N) +#endif + uint8_t current_protocol = 0; + if (m & WIFI_MODE_STA) { + err = esp_wifi_get_protocol(WIFI_IF_STA, ¤t_protocol); + if (err == ESP_OK && current_protocol == WIFI_PROTOCOL_LR) { + log_v("Disabling long range on STA"); + err = esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_DEFAULT); + if (err != ESP_OK) { + log_e("Could not disable long range on STA! 0x%x: %s", err, esp_err_to_name(err)); + } + } + } + if (m & WIFI_MODE_AP) { + err = esp_wifi_get_protocol(WIFI_IF_AP, ¤t_protocol); + if (err == ESP_OK && current_protocol == WIFI_PROTOCOL_LR) { + log_v("Disabling long range on AP"); + err = esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_DEFAULT); + if (err != ESP_OK) { + log_e("Could not disable long range on AP! 0x%x: %s", err, esp_err_to_name(err)); + } + } + } } if (!espWiFiStart()) { return false; @@ -683,8 +710,9 @@ bool WiFiGenericClass::setSleep(wifi_ps_type_t sleepType) { if (sleepType != _sleepEnabled) { _sleepEnabled = sleepType; if (WiFi.STA.started()) { - if (esp_wifi_set_ps(_sleepEnabled) != ESP_OK) { - log_e("esp_wifi_set_ps failed!"); + esp_err_t err = esp_wifi_set_ps(_sleepEnabled); + if (err != ESP_OK) { + log_e("esp_wifi_set_ps failed!: 0x%x: %s", err, esp_err_to_name(err)); return false; } } @@ -748,8 +776,9 @@ bool WiFiGenericClass::initiateFTM(uint8_t frm_count, uint16_t burst_period, uin memcpy(ftmi_cfg.resp_mac, mac, 6); } // Request FTM session with the Responder - if (ESP_OK != esp_wifi_ftm_initiate_session(&ftmi_cfg)) { - log_e("Failed to initiate FTM session"); + esp_err_t err = esp_wifi_ftm_initiate_session(&ftmi_cfg); + if (ESP_OK != err) { + log_e("Failed to initiate FTM session: 0x%x: %s", err, esp_err_to_name(err)); return false; } return true; @@ -768,8 +797,9 @@ bool WiFiGenericClass::setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2 esp_phy_ant_gpio_config_t wifi_ant_io; - if (ESP_OK != esp_phy_get_ant_gpio(&wifi_ant_io)) { - log_e("Failed to get antenna configuration"); + esp_err_t err = esp_phy_get_ant_gpio(&wifi_ant_io); + if (ESP_OK != err) { + log_e("Failed to get antenna configuration: 0x%x: %s", err, esp_err_to_name(err)); return false; } @@ -778,8 +808,9 @@ bool WiFiGenericClass::setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2 wifi_ant_io.gpio_cfg[1].gpio_num = gpio_ant2; wifi_ant_io.gpio_cfg[1].gpio_select = 1; - if (ESP_OK != esp_phy_set_ant_gpio(&wifi_ant_io)) { - log_e("Failed to set antenna GPIO configuration"); + err = esp_phy_set_ant_gpio(&wifi_ant_io); + if (ESP_OK != err) { + log_e("Failed to set antenna GPIO configuration: 0x%x: %s", err, esp_err_to_name(err)); return false; } @@ -827,8 +858,9 @@ bool WiFiGenericClass::setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2 } set_ant: - if (ESP_OK != esp_phy_set_ant(&ant_config)) { - log_e("Failed to set antenna configuration"); + err = esp_phy_set_ant(&ant_config); + if (ESP_OK != err) { + log_e("Failed to set antenna configuration: 0x%x: %s", err, esp_err_to_name(err)); return false; } #endif diff --git a/libraries/WiFiProv/library.properties b/libraries/WiFiProv/library.properties index 4cf8aa56b39..13a63c50bb1 100644 --- a/libraries/WiFiProv/library.properties +++ b/libraries/WiFiProv/library.properties @@ -1,5 +1,5 @@ name=WiFiProv -version=3.1.1 +version=3.2.0 author=Switi Mhaiske maintainer=Hristo Gochkov sentence=Enables provisioning. diff --git a/libraries/Wire/library.properties b/libraries/Wire/library.properties index 04beb2053bb..655f4bd3194 100644 --- a/libraries/Wire/library.properties +++ b/libraries/Wire/library.properties @@ -1,5 +1,5 @@ name=Wire -version=3.1.1 +version=3.2.0 author=Hristo Gochkov maintainer=Hristo Gochkov sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For esp8266 boards. diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 24b0eb7c0a3..f8d9496389f 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -462,10 +462,11 @@ uint8_t TwoWire::endTransmission(bool sendStop) { nonStop = true; } switch (err) { - case ESP_OK: return 0; - case ESP_FAIL: return 2; - case ESP_ERR_TIMEOUT: return 5; - default: break; + case ESP_OK: return 0; + case ESP_FAIL: return 2; + case ESP_ERR_NOT_FOUND: return 2; + case ESP_ERR_TIMEOUT: return 5; + default: break; } return 4; } @@ -646,8 +647,16 @@ void TwoWire::onRequestService(uint8_t num, void *arg) { #endif /* SOC_I2C_SUPPORT_SLAVE */ TwoWire Wire = TwoWire(0); +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) +#if SOC_I2C_NUM > 1 +TwoWire Wire1 = TwoWire(1); +#elif SOC_I2C_NUM > 2 +TwoWire Wire2 = TwoWire(2); +#endif /* SOC_I2C_NUM */ +#else #if SOC_HP_I2C_NUM > 1 TwoWire Wire1 = TwoWire(1); #endif /* SOC_HP_I2C_NUM */ +#endif #endif /* SOC_I2C_SUPPORTED */ diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index 45f30c81ffc..0deab7d4a57 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -28,6 +28,7 @@ #include "soc/soc_caps.h" #if SOC_I2C_SUPPORTED +#include "esp_idf_version.h" #include #include @@ -144,9 +145,17 @@ class TwoWire : public HardwareI2C { }; extern TwoWire Wire; +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) +#if SOC_I2C_NUM > 1 +extern TwoWire Wire1; +#elif SOC_I2C_NUM > 2 +extern TwoWire Wire2; +#endif /* SOC_I2C_NUM */ +#else #if SOC_HP_I2C_NUM > 1 extern TwoWire Wire1; #endif /* SOC_HP_I2C_NUM */ +#endif #endif /* SOC_I2C_SUPPORTED */ #endif /* TwoWire_h */ diff --git a/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/README.md b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/README.md new file mode 100644 index 00000000000..d62941755c7 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/README.md @@ -0,0 +1,72 @@ +# Arduino-ESP32 Zigbee Analog Input Output Example + +This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) analog input/output device. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Analog Sensor Functions + + * After this board first starts up, it would be configured locally to report an analog input on change or every 30 seconds. + * By clicking the button (BOOT) on this board, this board will immediately send a report of the current measured value to the network. + +## Hardware Required + +* A USB cable for power supply and programming + +### Configure the Project + +Set the ADC GPIO by changing the `analogPin` variable. By default, it's the pin `A0`. +Set the Button GPIO by changing the `button` variable. By default, it's the pin `BOOT_PIN` (BOOT button on ESP32-C6 and ESP32-H2). + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)` +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator. +You can do the following: + +* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`. +* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack. + +By default, the coordinator network is closed after rebooting or flashing new firmware. +To open the network you have 2 options: + +* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`. +* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/Zigbee_Analog_Input_Output.ino b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/Zigbee_Analog_Input_Output.ino new file mode 100644 index 00000000000..e31407cc8be --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/Zigbee_Analog_Input_Output.ino @@ -0,0 +1,119 @@ +// Copyright 2025 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates Zigbee analog input / output device. + * + * The example demonstrates how to use Zigbee library to create a end device analog device. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + * Modified by Pat Clay + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee end device mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +/* Zigbee analog device configuration */ +#define ANALOG_DEVICE_ENDPOINT_NUMBER 1 + +uint8_t analogPin = A0; +uint8_t button = BOOT_PIN; + +ZigbeeAnalog zbAnalogDevice = ZigbeeAnalog(ANALOG_DEVICE_ENDPOINT_NUMBER); + +void onAnalogOutputChange(float analog_output) { + Serial.printf("Received analog output change: %.1f\r\n", analog_output); +} + +void setup() { + Serial.begin(115200); + Serial.println("Starting..."); + + // Init button switch + pinMode(button, INPUT_PULLUP); + + // Set analog resolution to 10 bits + analogReadResolution(10); + + // Optional: set Zigbee device name and model + zbAnalogDevice.setManufacturerAndModel("Espressif", "ZigbeeAnalogDevice"); + + // Add analog clusters to Zigbee Analog according your needs + zbAnalogDevice.addAnalogInput(); + zbAnalogDevice.addAnalogOutput(); + + // If analog output cluster is added, set callback function for analog output change + zbAnalogDevice.onAnalogOutputChange(onAnalogOutputChange); + + // Add endpoints to Zigbee Core + Zigbee.addEndpoint(&zbAnalogDevice); + + Serial.println("Starting Zigbee..."); + // When all EPs are registered, start Zigbee in End Device mode + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } else { + Serial.println("Zigbee started successfully!"); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println("Connected"); + + // Optional: Add reporting for analog input + zbAnalogDevice.setAnalogInputReporting(0, 30, 10); // report every 30 seconds if value changes by 10 +} + +void loop() { + static uint32_t timeCounter = 0; + + // Read ADC value and update the analog value every 2s + if (!(timeCounter++ % 20)) { // delaying for 100ms x 20 = 2s + float analog = (float)analogRead(analogPin); + Serial.printf("Updating analog input to %.1f\r\n", analog); + zbAnalogDevice.setAnalogInput(analog); + + // Analog input supports reporting + zbAnalogDevice.reportAnalogInput(); + } + + // Checking button for factory reset and reporting + if (digitalRead(button) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(button) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + } + delay(100); +} diff --git a/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/ci.json b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Analog_Input_Output/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor/ci.json +++ b/libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/ci.json b/libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/ci.json b/libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/ci.json index e79a477da11..15d6190e4ae 100644 --- a/libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/ci.json @@ -1,6 +1,6 @@ { "fqbn_append": "PartitionScheme=zigbee_zczr,ZigbeeMode=zczr", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Contact_Switch/README.md b/libraries/Zigbee/examples/Zigbee_Contact_Switch/README.md new file mode 100644 index 00000000000..a5a32358a7c --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Contact_Switch/README.md @@ -0,0 +1,58 @@ +# Arduino-ESP32 Zigbee Contact Switch Example + +This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) contact switch (IAS Zone), +that can be used for example as window/door sensor having 2 states - closed/open. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Hardware Required + +* A USB cable for power supply and programming + +### Configure the Project + +Set the Button GPIO by changing the `button` variable. By default, it's the pin `BOOT_PIN` (BOOT button on ESP32-C6 and ESP32-H2). +Set the Sensor GPIO by changing the `sensor_pin` variable. + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)` +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Contact_Switch/Zigbee_Contact_Switch.ino b/libraries/Zigbee/examples/Zigbee_Contact_Switch/Zigbee_Contact_Switch.ino new file mode 100644 index 00000000000..ce9eedb683d --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Contact_Switch/Zigbee_Contact_Switch.ino @@ -0,0 +1,100 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates Zigbee contact switch (IAS Zone). + * + * The example demonstrates how to use Zigbee library to create a end device contact switch. + * The contact switch is a Zigbee end device, which is reporting data to the Zigbee network. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee end device mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +/* Zigbee contact sensor configuration */ +#define CONTACT_SWITCH_ENDPOINT_NUMBER 10 +uint8_t button = BOOT_PIN; +uint8_t sensor_pin = 4; + +ZigbeeContactSwitch zbContactSwitch = ZigbeeContactSwitch(CONTACT_SWITCH_ENDPOINT_NUMBER); + +void setup() { + Serial.begin(115200); + + // Init button + switch + pinMode(button, INPUT_PULLUP); + pinMode(sensor_pin, INPUT_PULLUP); + + // Optional: set Zigbee device name and model + zbContactSwitch.setManufacturerAndModel("Espressif", "ZigbeeContactSwitch"); + + // Add endpoint to Zigbee Core + Zigbee.addEndpoint(&zbContactSwitch); + + Serial.println("Starting Zigbee..."); + // When all EPs are registered, start Zigbee in End Device mode + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } else { + Serial.println("Zigbee started successfully!"); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); +} + +void loop() { + // Checking pin for contact change + static bool contact = false; + if (digitalRead(sensor_pin) == HIGH && !contact) { + // Update contact sensor value + zbContactSwitch.setOpen(); + contact = true; + } else if (digitalRead(sensor_pin) == LOW && contact) { + zbContactSwitch.setClosed(); + contact = false; + } + + // Checking button for factory reset + if (digitalRead(button) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(button) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + } + delay(100); +} diff --git a/libraries/Zigbee/examples/Zigbee_Contact_Switch/ci.json b/libraries/Zigbee/examples/Zigbee_Contact_Switch/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Contact_Switch/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_Dimmable_Light/ci.json b/libraries/Zigbee/examples/Zigbee_Dimmable_Light/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Dimmable_Light/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Dimmable_Light/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Gateway/README.md b/libraries/Zigbee/examples/Zigbee_Gateway/README.md new file mode 100644 index 00000000000..4156538ccd9 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Gateway/README.md @@ -0,0 +1,64 @@ +# Arduino-ESP32 Zigbee Gateway Example + +This example shows how to configure Zigbee Gateway device, running on SoCs without native IEEE 802.15.4. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | +| ----------------- | ----- | -------- | -------- | -------- | + +## Hardware Required + +* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee Radio Co-processor loaded with [ot_rcp example](https://github.com/espressif/esp-idf/tree/master/examples/openthread/ot_rcp). +* A USB cable for power supply and programming. +* Choose another board from supported targets as Zigbee coordinator/router and upload the Zigbee_Gateway example. + +### Configure the Project + +Set the RCP connection (UART) by changing the `GATEWAY_RCP_UART_PORT`, `GATEWAY_RCP_RX_PIN` and `GATEWAY_RCP_TX_PIN` definition. + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`. +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`. +* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`. + +By default, the coordinator network is closed after rebooting or flashing new firmware. +To open the network you have 2 options: + +* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`. +* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Gateway/Zigbee_Gateway.ino b/libraries/Zigbee/examples/Zigbee_Gateway/Zigbee_Gateway.ino new file mode 100644 index 00000000000..402227b9a3d --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Gateway/Zigbee_Gateway.ino @@ -0,0 +1,130 @@ +// Copyright 2025 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates simple Zigbee Gateway functionality. + * + * The example demonstrates how to use Zigbee library on ESP32s to create a Zigbee Gateway, updating the time from NTP server. + * The Gateway is able to communicate with Zigbee end devices and send/receive data to/from them. + * The Gateway is also able to communicate with the cloud or other devices over Wi-Fi / BLE. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode->Zigbee ZCZR (coordinator/router) + * and also the correct partition scheme must be selected in Tools->Partition Scheme->Zigbee ZCZR + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ZCZR +#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" +#include +#include "time.h" +#include "esp_sntp.h" + +/* Zigbee gateway configuration */ +#define GATEWAY_ENDPOINT_NUMBER 1 +#define GATEWAY_RCP_UART_PORT UART_NUM_1 // UART 0 is used for Serial communication +#define GATEWAY_RCP_RX_PIN 4 +#define GATEWAY_RCP_TX_PIN 5 + +ZigbeeGateway zbGateway = ZigbeeGateway(GATEWAY_ENDPOINT_NUMBER); + +/* Wi-Fi credentials */ +const char *ssid = "your-ssid"; +const char *password = "your-password"; + +/* NTP server configuration */ +const char *ntpServer1 = "pool.ntp.org"; +const char *ntpServer2 = "time.nist.gov"; +const long gmtOffset_sec = 3600; +const int daylightOffset_sec = 3600; +const char *time_zone = "CET-1CEST,M3.5.0,M10.5.0/3"; // TimeZone rule for Europe/Rome including daylight adjustment rules (optional) + +/* Time structure */ +struct tm timeinfo; + +/********************* Arduino functions **************************/ +void setup() { + Serial.begin(115200); + + // Initialize Wi-Fi and connect to AP + WiFi.begin(ssid, password); + esp_sntp_servermode_dhcp(1); // (optional) + + Serial.print("Connecting to WiFi"); + + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println("WiFi connected"); + + // Initialize Zigbee and Begin Zigbee stack + // Optional: set Zigbee device name and model + zbGateway.setManufacturerAndModel("Espressif", "ZigbeeGateway"); + zbGateway.addTimeCluster(timeinfo, gmtOffset_sec); + + // Add endpoint to Zigbee Core + Serial.println("Adding Zigbee Gateway endpoint"); + Zigbee.addEndpoint(&zbGateway); + + // Optional: Open network for 180 seconds after boot + Zigbee.setRebootOpenNetwork(180); + + // Set custom radio configuration for RCP communication + esp_zb_radio_config_t radio_config = ZIGBEE_DEFAULT_UART_RCP_RADIO_CONFIG(); + radio_config.radio_uart_config.port = GATEWAY_RCP_UART_PORT; + radio_config.radio_uart_config.rx_pin = (gpio_num_t)GATEWAY_RCP_RX_PIN; + radio_config.radio_uart_config.tx_pin = (gpio_num_t)GATEWAY_RCP_TX_PIN; + + Zigbee.setRadioConfig(radio_config); + + // When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR or ZIGBEE_ROUTER mode + if (!Zigbee.begin(ZIGBEE_COORDINATOR)) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } + + // set notification call-back function + sntp_set_time_sync_notification_cb(timeavailable); + sntp_set_sync_interval(30000); // sync every 30 seconds + + // config time zone and NTP servers + configTime(gmtOffset_sec, daylightOffset_sec, ntpServer1, ntpServer2); +} + +void loop() { + // Nothing to do here in this example +} + +void printLocalTime() { + if (!getLocalTime(&timeinfo)) { + Serial.println("No time available (yet)"); + return; + } + Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S"); + zbGateway.setTime(timeinfo); + Serial.println("Time updated in Zigbee Gateway"); +} + +// Callback function (gets called when time adjusts via NTP) +void timeavailable(struct timeval *t) { + Serial.println("Got time adjustment from NTP!"); + printLocalTime(); +} diff --git a/libraries/Zigbee/examples/Zigbee_Gateway/ci.json b/libraries/Zigbee/examples/Zigbee_Gateway/ci.json new file mode 100644 index 00000000000..23e1c59d1da --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Gateway/ci.json @@ -0,0 +1,10 @@ +{ + "fqbn_append": "PartitionScheme=zigbee_zczr_8MB,ZigbeeMode=zczr", + "requires": [ + "CONFIG_ZB_ENABLED=y" + ], + "targets": { + "esp32c6": false, + "esp32h2": false + } +} diff --git a/libraries/Zigbee/examples/Zigbee_OTA_Client/README.md b/libraries/Zigbee/examples/Zigbee_OTA_Client/README.md new file mode 100644 index 00000000000..143ff946f28 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_OTA_Client/README.md @@ -0,0 +1,68 @@ +# Arduino-ESP32 Zigbee OTA Client + on/off light Example + +This example shows how to configure the Zigbee end device with OTA Client and use it as a Home Automation (HA) on/off light. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Hardware Required + +* A USB cable for power supply and programming + +### Configure the Project + +Set the LED GPIO by changing the `LED_PIN` definition. By default, the LED_PIN is `RGB_BUILTIN`. +By default, the `rgbLedWrite` function is used to control the LED. You can change it to digitalWrite to control a simple LED. + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)` +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator. +You can do the following: + +* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`. +* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack. + +By default, the coordinator network is closed after rebooting or flashing new firmware. +To open the network you have 2 options: + +* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`. +* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join. + + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_OTA_Client/Zigbee_OTA_Client.ino b/libraries/Zigbee/examples/Zigbee_OTA_Client/Zigbee_OTA_Client.ino new file mode 100644 index 00000000000..29d114014b4 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_OTA_Client/Zigbee_OTA_Client.ino @@ -0,0 +1,112 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates OTA support on light bulb. + * + * The example demonstrates how to use Zigbee library to create a end device light bulb with OTA support. + * The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee end device mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +/* Zigbee light bulb configuration */ +#define ZIGBEE_LIGHT_ENDPOINT 1 +uint8_t led = RGB_BUILTIN; +uint8_t button = BOOT_PIN; + +/* Zigbee OTA configuration */ +#define OTA_UPGRADE_RUNNING_FILE_VERSION 0x01010100 // Increment this value when the running image is updated +#define OTA_UPGRADE_DOWNLOADED_FILE_VERSION 0x01010101 // Increment this value when the downloaded image is updated +#define OTA_UPGRADE_HW_VERSION 0x0101 // The hardware version, this can be used to differentiate between different hardware versions + +ZigbeeLight zbLight = ZigbeeLight(ZIGBEE_LIGHT_ENDPOINT); + +/********************* RGB LED functions **************************/ +void setLED(bool value) { + digitalWrite(led, value); +} + +/********************* Arduino functions **************************/ +void setup() { + Serial.begin(115200); + + // Init LED and turn it OFF (if LED_PIN == RGB_BUILTIN, the rgbLedWrite() will be used under the hood) + pinMode(led, OUTPUT); + digitalWrite(led, LOW); + + // Init button for factory reset + pinMode(button, INPUT_PULLUP); + + // Optional: set Zigbee device name and model + zbLight.setManufacturerAndModel("Espressif", "ZBLightBulb"); + + // Set callback function for light change + zbLight.onLightChange(setLED); + + // Add OTA client to the light bulb + zbLight.addOTAClient(OTA_UPGRADE_RUNNING_FILE_VERSION, OTA_UPGRADE_DOWNLOADED_FILE_VERSION, OTA_UPGRADE_HW_VERSION); + + // Add endpoint to Zigbee Core + Serial.println("Adding ZigbeeLight endpoint to Zigbee Core"); + Zigbee.addEndpoint(&zbLight); + + // When all EPs are registered, start Zigbee. By default acts as ZIGBEE_END_DEVICE + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); + + // Start Zigbee OTA client query, first request is within a minute and the next requests are sent every hour automatically + zbLight.requestOTAUpdate(); +} + +void loop() { + // Checking button for factory reset + if (digitalRead(button) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(button) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + // Toggle light by pressing the button + zbLight.setLight(!zbLight.getLightState()); + } + delay(100); +} diff --git a/libraries/Zigbee/examples/Zigbee_OTA_Client/ci.json b/libraries/Zigbee/examples/Zigbee_OTA_Client/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_OTA_Client/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_Occupancy_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_Occupancy_Sensor/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Occupancy_Sensor/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Occupancy_Sensor/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_On_Off_Light/ci.json b/libraries/Zigbee/examples/Zigbee_On_Off_Light/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_On_Off_Light/ci.json +++ b/libraries/Zigbee/examples/Zigbee_On_Off_Light/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_On_Off_Switch/ci.json b/libraries/Zigbee/examples/Zigbee_On_Off_Switch/ci.json index e79a477da11..15d6190e4ae 100644 --- a/libraries/Zigbee/examples/Zigbee_On_Off_Switch/ci.json +++ b/libraries/Zigbee/examples/Zigbee_On_Off_Switch/ci.json @@ -1,6 +1,6 @@ { "fqbn_append": "PartitionScheme=zigbee_zczr,ZigbeeMode=zczr", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Range_Extender/README.md b/libraries/Zigbee/examples/Zigbee_Range_Extender/README.md new file mode 100644 index 00000000000..198dd85b6ee --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Range_Extender/README.md @@ -0,0 +1,68 @@ +# Arduino-ESP32 Zigbee Range Extender (Router) Example + +This example shows how to configure the Zigbee Router device and use it as a Home Automation (HA) network range extender. + +To see if the communication with your Zigbee network works, use the Serial monitor and watch for output there. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Hardware Required + +* A USB cable for power supply and programming +* Board (ESP32-H2 or ESP32-C6) as Zigbee router device and upload the Zigbee_Range_Extender example +* Zigbee network / coordinator (Other board with switch examples or Zigbee2mqtt or ZigbeeHomeAssistant like application) + +### Configure the Project + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the Coordinator/Router device Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)` +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` (select correct size) +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the Router device flashed with this example is not connecting to the coordinator, erase the flash of the Router device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator. +You can do the following: + +* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`. +* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack. + +By default, the coordinator network is closed after rebooting or flashing new firmware. +To open the network you have 2 options: + +* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`. +* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Range_Extender/Zigbee_Range_Extender.ino b/libraries/Zigbee/examples/Zigbee_Range_Extender/Zigbee_Range_Extender.ino new file mode 100644 index 00000000000..a1ba90fbaf6 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Range_Extender/Zigbee_Range_Extender.ino @@ -0,0 +1,120 @@ +// Copyright 2025 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates simple Zigbee Range Extender (router). + * + * The example demonstrates how to use Zigbee library to create a Zigbee network ragbe extender (router). + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ZCZR +#error "Zigbee coordinator/router mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +/* Zigbee light bulb configuration */ +#define USE_CUSTOM_ZIGBEE_CONFIG 1 +#define ZIGBEE_EXTENDER_ENDPOINT 1 + +#ifndef LED_BUILTIN +#define LED_BUILTIN 4 +#endif + +uint8_t led = LED_BUILTIN; +uint8_t button = BOOT_PIN; + +ZigbeeRangeExtender zbExtender = ZigbeeRangeExtender(ZIGBEE_EXTENDER_ENDPOINT); + +/************************** Identify ******************************/ +// Create a task on identify call to handle the identify function +void identify(uint16_t time) { + static uint8_t blink = 1; + log_d("Identify called for %d seconds", time); + if (time == 0) { + digitalWrite(led, LOW); + return; + } + digitalWrite(led, blink); + blink = !blink; +} + +/********************* Arduino functions **************************/ +void setup() { + Serial.begin(115200); + + // Init LED and turn it OFF (if LED_PIN == RGB_BUILTIN, the rgbLedWrite() will be used under the hood) + pinMode(led, OUTPUT); + digitalWrite(led, LOW); + + // Init button for factory reset + pinMode(button, INPUT_PULLUP); + + // Optional: Set callback function for device identify + zbExtender.onIdentify(identify); + + // Optional: Set Zigbee device name and model + zbExtender.setManufacturerAndModel("Espressif", "ZigbeeRangeExtender"); + + // Add endpoint to Zigbee Core + Serial.println("Adding Zigbee Extender endpoint to Zigbee Core"); + Zigbee.addEndpoint(&zbExtender); + +#if USE_CUSTOM_ZIGBEE_CONFIG + // Optional: Create a custom Zigbee configuration for Zigbee Extender + esp_zb_cfg_t zigbeeConfig = ZIGBEE_DEFAULT_ROUTER_CONFIG(); + zigbeeConfig.nwk_cfg.zczr_cfg.max_children = 20; // 10 is default + + // When all EPs are registered, start Zigbee with custom config + if (!Zigbee.begin(&zigbeeConfig)) { +#else + // When all EPs are registered, start Zigbee as ROUTER device + if (!Zigbee.begin(ZIGBEE_ROUTER)) { +#endif + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); +} + +void loop() { + // Checking button for factory reset + if (digitalRead(button) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(button) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + } +} diff --git a/libraries/Zigbee/examples/Zigbee_Range_Extender/ci.json b/libraries/Zigbee/examples/Zigbee_Range_Extender/ci.json new file mode 100644 index 00000000000..15d6190e4ae --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Range_Extender/ci.json @@ -0,0 +1,6 @@ +{ + "fqbn_append": "PartitionScheme=zigbee_zczr,ZigbeeMode=zczr", + "requires": [ + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_Scan_Networks/ci.json b/libraries/Zigbee/examples/Zigbee_Scan_Networks/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Scan_Networks/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Scan_Networks/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino b/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino index 60bd784cca9..65df4b02957 100644 --- a/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino +++ b/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino @@ -125,8 +125,8 @@ void loop() { int startTime = millis(); while (digitalRead(button) == LOW) { delay(50); - if ((millis() - startTime) > 3000) { - // If key pressed for more than 3secs, factory reset Zigbee and reboot + if ((millis() - startTime) > 10000) { + // If key pressed for more than 10secs, factory reset Zigbee and reboot Serial.println("Resetting Zigbee to factory and rebooting in 1s."); delay(1000); Zigbee.factoryReset(); diff --git a/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/ci.json b/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino b/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino index 27aa2db97bd..ad007abbbaa 100644 --- a/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino +++ b/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino @@ -36,6 +36,11 @@ #define TEMP_SENSOR_ENDPOINT_NUMBER 10 uint8_t button = BOOT_PIN; +// Optional Time cluster variables +struct tm timeinfo; +struct tm *localTime; +int32_t timezone; + ZigbeeTempSensor zbTempSensor = ZigbeeTempSensor(TEMP_SENSOR_ENDPOINT_NUMBER); /************************ Temp sensor *****************************/ @@ -66,6 +71,9 @@ void setup() { // Optional: Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C) zbTempSensor.setTolerance(1); + // Optional: Time cluster configuration (default params, as this device will revieve time from coordinator) + zbTempSensor.addTimeCluster(); + // Add endpoint to Zigbee Core Zigbee.addEndpoint(&zbTempSensor); @@ -85,6 +93,19 @@ void setup() { } Serial.println(); + // Optional: If time cluster is added, time can be read from the coordinator + timeinfo = zbTempSensor.getTime(); + timezone = zbTempSensor.getTimezone(); + + Serial.println("UTC time:"); + Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S"); + + time_t local = mktime(&timeinfo) + timezone; + localTime = localtime(&local); + + Serial.println("Local time with timezone:"); + Serial.println(localTime, "%A, %B %d %Y %H:%M:%S"); + // Start Temperature sensor reading task xTaskCreate(temp_sensor_value_update, "temp_sensor_update", 2048, NULL, 10, NULL); diff --git a/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/ci.json index 7b7ccef8ed7..ceacc367801 100644 --- a/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Temperature_Sensor/ci.json @@ -1,6 +1,7 @@ { "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino b/libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino index a4720feeba4..7cdf45ef711 100644 --- a/libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino +++ b/libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino @@ -45,6 +45,8 @@ float sensor_max_temp; float sensor_min_temp; float sensor_tolerance; +struct tm timeinfo = {}; // Time structure for Time cluster + /****************** Temperature sensor handling *******************/ void recieveSensorTemp(float temperature) { Serial.printf("Temperature sensor value: %.2f°C\n", temperature); @@ -71,6 +73,19 @@ void setup() { //Optional: set Zigbee device name and model zbThermostat.setManufacturerAndModel("Espressif", "ZigbeeThermostat"); + //Optional Time cluster configuration + //example time January 13, 2025 13:30:30 CET + timeinfo.tm_year = 2025 - 1900; // = 2025 + timeinfo.tm_mon = 0; // January + timeinfo.tm_mday = 13; // 13th + timeinfo.tm_hour = 12; // 12 hours - 1 hour (CET) + timeinfo.tm_min = 30; // 30 minutes + timeinfo.tm_sec = 30; // 30 seconds + timeinfo.tm_isdst = -1; + + // Set time and gmt offset (timezone in seconds -> CET = +3600 seconds) + zbThermostat.addTimeCluster(timeinfo, 3600); + //Add endpoint to Zigbee Core Zigbee.addEndpoint(&zbThermostat); diff --git a/libraries/Zigbee/examples/Zigbee_Thermostat/ci.json b/libraries/Zigbee/examples/Zigbee_Thermostat/ci.json index e79a477da11..15d6190e4ae 100644 --- a/libraries/Zigbee/examples/Zigbee_Thermostat/ci.json +++ b/libraries/Zigbee/examples/Zigbee_Thermostat/ci.json @@ -1,6 +1,6 @@ { "fqbn_append": "PartitionScheme=zigbee_zczr,ZigbeeMode=zczr", "requires": [ - "CONFIG_SOC_IEEE802154_SUPPORTED=y" + "CONFIG_ZB_ENABLED=y" ] } diff --git a/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/README.md b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/README.md new file mode 100644 index 00000000000..b0e5b5f09e8 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/README.md @@ -0,0 +1,58 @@ +# Arduino-ESP32 Zigbee Vibration Sensor Example + +This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) vibration sensor (IAS Zone), +that can be used for example as a security device which is sensing a vibrations. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Hardware Required + +* A USB cable for power supply and programming + +### Configure the Project + +Set the Button GPIO by changing the `button` variable. By default, it's the pin `BOOT_PIN` (BOOT button on ESP32-C6 and ESP32-H2). +Set the Sensor GPIO by changing the `sensor_pin` variable. + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)` +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/Zigbee_Vibration_Sensor.ino b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/Zigbee_Vibration_Sensor.ino new file mode 100644 index 00000000000..d9ac7b6e241 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/Zigbee_Vibration_Sensor.ino @@ -0,0 +1,104 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates Zigbee vibration sensor (IAS Zone). + * + * The example demonstrates how to use Zigbee library to create a end device vibration sensor. + * The vibration sensor is a Zigbee end device, which is reporting data to the Zigbee network. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee end device mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +/* Zigbee vibration sensor configuration */ +#define VIBRATION_SENSOR_ENDPOINT_NUMBER 10 +uint8_t button = BOOT_PIN; +uint8_t sensor_pin = 4; + +ZigbeeVibrationSensor zbVibrationSensor = ZigbeeVibrationSensor(VIBRATION_SENSOR_ENDPOINT_NUMBER); + +void setup() { + Serial.begin(115200); + + // Init button + sensor + pinMode(button, INPUT_PULLUP); + pinMode(sensor_pin, INPUT); + + // Optional: set Zigbee device name and model + zbVibrationSensor.setManufacturerAndModel("Espressif", "ZigbeeVibrationSensor"); + + // Add endpoint to Zigbee Core + Zigbee.addEndpoint(&zbVibrationSensor); + + Serial.println("Starting Zigbee..."); + // When all EPs are registered, start Zigbee in End Device mode + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } else { + Serial.println("Zigbee started successfully!"); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); +} + +void loop() { + // Checking pin for contact change + static bool sensed = false; + if (digitalRead(sensor_pin) == HIGH && !sensed) { + // Update contact sensor value + zbVibrationSensor.setVibration(true); + sensed = true; + //if sensed, wait 2 seconds before next sensing + delay(2000); + } else if (digitalRead(sensor_pin) == LOW && sensed) { + zbVibrationSensor.setVibration(false); + sensed = false; + //if not sensed, wait 0,5 seconds before next sensing + delay(500); + } + + // Checking button for factory reset + if (digitalRead(button) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(button) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + } + delay(100); +} diff --git a/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Vibration_Sensor/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/README.md b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/README.md new file mode 100644 index 00000000000..826c7666e6b --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/README.md @@ -0,0 +1,60 @@ +# Zigbee Wind Speed Sensor Integration with HomeAssistant ZHA + +This guide provides a workaround for integrating a Zigbee Wind Speed Sensor with HomeAssistant using the ZHA integration. Since the wind speed cluster is not natively supported, we will use the ZHA Toolkit from HACS to read the wind speed attribute and store it in a helper variable. +## Alternative Option: Creating a Custom Quirk + +For advanced users, a more robust solution is to create a custom quirk for your Zigbee Wind Speed Sensor. This approach involves writing a custom device handler that directly supports the wind speed cluster, providing a more seamless integration with HomeAssistant. + +Creating a custom quirk can be complex and requires familiarity with Python and the Zigbee protocol. However, it offers greater flexibility and control over your device's behavior. + +For more information and guidance on creating custom quirks, visit the [ZHA Device Handlers repository](https://github.com/zigpy/zha-device-handlers/). + +## Prerequisites + +- HomeAssistant installed and running +- Zigbee Wind Speed Sensor paired with HomeAssistant ZHA +- HACS (Home Assistant Community Store) installed. For more information, visit [HACS](https://hacs.xyz) + +## Steps + +### 1. Install ZHA Toolkit + +1. Open HomeAssistant. +2. Navigate to HACS > Integrations. +3. Search for "ZHA Toolkit - Service for advanced Zigbee Usage" and install it. For more information, visit the [ZHA Toolkit repository](https://github.com/mdeweerd/zha-toolkit). +4. Restart HomeAssistant to apply changes. + +### 2. Create a Helper Variable + +1. Go to Configuration -> Devices & Services -> Helpers. +2. Click on "Add Helper" and select "Number". +3. Name the helper (e.g., `wind_speed`), set the minimum and maximum values, and save it. + +### 3. Create an Automation + +1. Go to Configuration > Automations & Scenes. +2. Click on "Add Automation" and choose "Start with an empty automation". +3. Set a name for the automation (e.g., `Read Wind Speed`). +4. Add a trigger: + - Trigger Type: Time Pattern + - Every: 30 seconds +5. Add an action (Then do): + - Action Type: ZHA Toolkit: Read Attribute + - Setup the action: + ```yaml + action: zha_toolkit.attr_read + metadata: {} + data: + ieee: f0:f5:bd:ff:fe:0e:61:30 #set device IEEE address + endpoint: 10 #set windspeed device endpoint + cluster: 1035 #use this windspeed cluster + attribute: 0 #read measurement value + state_id: input_number.wind_speed #save to created helper variable + state_value_template: value/100 #use correct value format (convert u16 to float) + ``` +6. Save the automation. + +## Conclusion + +By following these steps, you can successfully integrate your Zigbee Wind Speed Sensor with HomeAssistant using the ZHA integration and ZHA Toolkit. The wind speed readings will be updated every 30 seconds and stored in the helper variable for use in your HomeAssistant setup. +The helper variable `wind_speed` is now an entity in HomeAssistant. You can use this entity to display the wind speed on your dashboard or in other automations. diff --git a/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/Zigbee_Wind_Speed_Sensor.ino b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/Zigbee_Wind_Speed_Sensor.ino new file mode 100644 index 00000000000..1c24df9a091 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/Zigbee_Wind_Speed_Sensor.ino @@ -0,0 +1,119 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates Zigbee windspeed sensor. + * + * The example demonstrates how to use Zigbee library to create a end device wind speed sensor. + * The wind speed sensor is a Zigbee end device, which is controlled by a Zigbee coordinator. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode" +#endif + +#include "Zigbee.h" + +#define BUTTON_PIN 9 //Boot button for C6/H2 +#define WIND_SPEED_SENSOR_ENDPOINT_NUMBER 10 + +ZigbeeWindSpeedSensor zbWindSpeedSensor = ZigbeeWindSpeedSensor(WIND_SPEED_SENSOR_ENDPOINT_NUMBER); + +/************************ WindSpeed sensor *****************************/ +static void windspeed_sensor_value_update(void *arg) { + for (;;) { + // Read wind speed sensor value (simulated now by temperature sensor) + float windspeed = temperatureRead(); + log_v("Wind speed sensor value: %.2fm/s", windspeed); + // Update windspeed value in Windspeed sensor EP + zbWindSpeedSensor.setWindSpeed(windspeed); + delay(1000); + } +} + +/********************* Arduino functions **************************/ +void setup() { + Serial.begin(115200); + while (!Serial) { + delay(10); + } + + // Init button switch + pinMode(BUTTON_PIN, INPUT); + + // Optional: set Zigbee device name and model + zbWindSpeedSensor.setManufacturerAndModel("Espressif", "ZigbeeWindSpeedSensor"); + + // Set minimum and maximum windspeed measurement value in m/s + zbWindSpeedSensor.setMinMaxValue(0, 50); + + // Set tolerance for windspeed measurement in m/s (lowest possible value is 0.01 m/s) + zbWindSpeedSensor.setTolerance(1); + + // Add endpoint to Zigbee Core + Zigbee.addEndpoint(&zbWindSpeedSensor); + + Serial.println("Starting Zigbee..."); + // When all EPs are registered, start Zigbee in End Device mode + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } else { + Serial.println("Zigbee started successfully!"); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); + + // Start Wind speed sensor reading task + xTaskCreate(windspeed_sensor_value_update, "wind_speed_sensor_update", 2048, NULL, 10, NULL); + + // Set reporting interval for windspeed measurement in seconds, must be called after Zigbee.begin() + // min_interval and max_interval in seconds, delta (WindSpeed change in m/s) + // if min = 1 and max = 0, reporting is sent only when windspeed changes by delta + // if min = 0 and max = 10, reporting is sent every 10 seconds or windspeed changes by delta + // if min = 0, max = 10 and delta = 0, reporting is sent every 10 seconds regardless of windspeed change + zbWindSpeedSensor.setReporting(1, 0, 1); +} + +void loop() { + // Checking button for factory reset + if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(BUTTON_PIN) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.println("Resetting Zigbee to factory and rebooting in 1s."); + delay(1000); + Zigbee.factoryReset(); + } + } + zbWindSpeedSensor.reportWindSpeed(); + } + delay(100); +} diff --git a/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/ci.json b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/examples/Zigbee_Window_Covering/README.md b/libraries/Zigbee/examples/Zigbee_Window_Covering/README.md new file mode 100644 index 00000000000..469560a0e0c --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Window_Covering/README.md @@ -0,0 +1,69 @@ +# Arduino-ESP32 Window Covering Example + +This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) window covering device. + +To see if the communication with your Zigbee network works, use the Serial monitor and watch for output there. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | + +## Hardware Required + +* A USB cable for power supply and programming +* Board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the Zigbee_Window_Covering example +* Zigbee network / coordinator (Other board with switch examples or Zigbee2mqtt or ZigbeeHomeAssistant like application) + +### Configure the Project + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)` +* Select Tools / USB CDC On Boot: "Enabled" +* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs` +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. +* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`. + +## Troubleshooting + +If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator. +You can do the following: + +* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`. +* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack. + +By default, the coordinator network is closed after rebooting or flashing new firmware. +To open the network you have 2 options: + +* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`. +* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join. + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +* **LED not blinking:** Check the wiring connection and the IO selection. +* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed. +* **COM port not detected:** Check the USB cable and the USB to Serial driver installation. + +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) +* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/Zigbee/examples/Zigbee_Window_Covering/Zigbee_Window_Covering.ino b/libraries/Zigbee/examples/Zigbee_Window_Covering/Zigbee_Window_Covering.ino new file mode 100644 index 00000000000..c7f9cf84f74 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Window_Covering/Zigbee_Window_Covering.ino @@ -0,0 +1,198 @@ +// Copyright 2025 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @brief This example demonstrates Zigbee Window Covering. + * + * The example demonstrates how to use Zigbee library to create a end device window covering device. + * The window covering is a Zigbee end device, which is moving the blinds (lift+tilt) and reporting + * its current position to the Zigbee network. + * + * Use setCoveringType() to set the type of covering (blind, shade, etc.). + * + * The example also demonstrates how to use the button to manually control the lift position. + * + * Proper Zigbee mode must be selected in Tools->Zigbee mode + * and also the correct partition scheme must be selected in Tools->Partition Scheme. + * + * Please check the README.md for instructions and more detailed description. + * + * Created by hennikul and Jan Procházka (https://github.com/P-R-O-C-H-Y/) + */ + +#ifndef ZIGBEE_MODE_ED +#error "Zigbee end device mode is not selected in Tools->Zigbee mode" +#endif + +#include "ZigbeeCore.h" +#include "ep/ZigbeeWindowCovering.h" + +#define ZIGBEE_COVERING_ENDPOINT 10 +#define BUTTON_PIN 9 // ESP32-C6/H2 Boot button + +#define MAX_LIFT 200 // centimeters from open position (0-900) +#define MIN_LIFT 0 + +#define MAX_TILT 40 // centimeters from open position (0-900) +#define MIN_TILT 0 + +uint16_t currentLift = MAX_LIFT; +uint8_t currentLiftPercentage = 100; + +uint16_t currentTilt = MAX_TILT; +uint8_t currentTiltPercentage = 100; + +ZigbeeWindowCovering zbCovering = ZigbeeWindowCovering(ZIGBEE_COVERING_ENDPOINT); + +void setup() { + Serial.begin(115200); + + // Init button for factory reset + pinMode(BUTTON_PIN, INPUT_PULLUP); + + // Optional: set Zigbee device name and model + zbCovering.setManufacturerAndModel("Espressif", "WindowBlinds"); + + // Set proper covering type, it defines which attributes are available + zbCovering.setCoveringType(BLIND_LIFT_AND_TILT); + + // Set configuration: operational, online, not commands_reversed, lift / tilt closed_loop, lift / tilt encoder_controlled + zbCovering.setConfigStatus(true, true, false, true, true, true, true); + + // Set mode: not motor_reversed, calibration_mode, not maintenance_mode, not leds_on + zbCovering.setMode(false, true, false, false); + + // Set limits of motion + zbCovering.setLimits(MIN_LIFT, MAX_LIFT, MIN_TILT, MAX_TILT); + + // Set callback function for open, close, filt and tilt change, stop + zbCovering.onOpen(fullOpen); + zbCovering.onClose(fullClose); + zbCovering.onGoToLiftPercentage(goToLiftPercentage); + zbCovering.onGoToTiltPercentage(goToTiltPercentage); + zbCovering.onStop(stopMotor); + + // Add endpoint to Zigbee Core + Serial.println("Adding ZigbeeWindowCovering endpoint to Zigbee Core"); + Zigbee.addEndpoint(&zbCovering); + + // When all EPs are registered, start Zigbee. By default acts as ZIGBEE_END_DEVICE + Serial.println("Calling Zigbee.begin()"); + if (!Zigbee.begin()) { + Serial.println("Zigbee failed to start!"); + Serial.println("Rebooting..."); + ESP.restart(); + } + Serial.println("Connecting to network"); + while (!Zigbee.connected()) { + Serial.print("."); + delay(100); + } + Serial.println(); + + // Set initial position + zbCovering.setLiftPercentage(currentLiftPercentage); + zbCovering.setTiltPercentage(currentTiltPercentage); +} + +void loop() { + // Checking button for factory reset + if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed + // Key debounce handling + delay(100); + int startTime = millis(); + while (digitalRead(BUTTON_PIN) == LOW) { + delay(50); + if ((millis() - startTime) > 3000) { + // If key pressed for more than 3secs, factory reset Zigbee and reboot + Serial.printf("Resetting Zigbee to factory settings, reboot.\n"); + Zigbee.factoryReset(); + delay(30000); + } + } + // Manual lift control simulation by pressing button + manualControl(); + } + delay(500); +} + +void fullOpen() { + /* This is where you would trigger your motor to go to full open state, currentLift should + be updated until full open has been reached in order to provide feedback to controller of actual position + The stop can be always called, so the movement can be stopped at any time */ + + // Our cover updates instantly! + currentLift = MAX_LIFT; + currentLiftPercentage = 100; + Serial.println("Opening cover"); + // Update the current position + zbCovering.setLiftPercentage(currentLiftPercentage); +} + +void fullClose() { + /* This is where you would trigger your motor to go to full close state, currentLift should + be updated until full close has been reached in order to provide feedback to controller of actual position + The stop can be always called, so the movement can be stopped at any time */ + + // Our cover updates instantly! + currentLift = MIN_LIFT; + currentLiftPercentage = 0; + Serial.println("Closing cover"); + // Update the current position + zbCovering.setLiftPercentage(currentLiftPercentage); +} + +void goToLiftPercentage(uint8_t liftPercentage) { + /* This is where you would trigger your motor to go towards liftPercentage, currentLift should + be updated until liftPercentage has been reached in order to provide feedback to controller */ + + // Our simulated cover updates instantly! + currentLift = (liftPercentage * MAX_LIFT) / 100; + currentLiftPercentage = liftPercentage; + Serial.printf("New requested lift from Zigbee: %d (%d)\n", currentLift, liftPercentage); + + // Update the current position + zbCovering.setLiftPercentage(currentLiftPercentage); //or setLiftPosition() +} + +void goToTiltPercentage(uint8_t tiltPercentage) { + /* This is where you would trigger your motor to go towards tiltPercentage, currentTilt should + be updated until tiltPercentage has been reached in order to provide feedback to controller */ + + // Our simulated cover updates instantly! + currentTilt = (tiltPercentage * MAX_TILT) / 100; + currentTiltPercentage = tiltPercentage; + Serial.printf("New requested tilt from Zigbee: %d (%d)\n", currentTilt, tiltPercentage); + + // Update the current position + zbCovering.setTiltPercentage(currentTiltPercentage); //or setTiltPosition() +} + +void stopMotor() { + // Motor can be stopped while moving cover toward current target, when stopped the actual position should be updated + Serial.println("Stopping motor"); + // Update the current position of both lift and tilt + zbCovering.setLiftPercentage(currentLiftPercentage); + zbCovering.setTiltPercentage(currentTiltPercentage); +} + +void manualControl() { + // Simulate lift percentage move by increasing it by 20% each time + currentLiftPercentage += 20; + if (currentLiftPercentage > 100) { + currentLiftPercentage = 0; + } + zbCovering.setLiftPercentage(currentLiftPercentage); + // Also setLiftPosition() can be used to set the exact position instead of percentage +} diff --git a/libraries/Zigbee/examples/Zigbee_Window_Covering/ci.json b/libraries/Zigbee/examples/Zigbee_Window_Covering/ci.json new file mode 100644 index 00000000000..ceacc367801 --- /dev/null +++ b/libraries/Zigbee/examples/Zigbee_Window_Covering/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=zigbee,ZigbeeMode=ed", + "requires": [ + "CONFIG_SOC_IEEE802154_SUPPORTED=y", + "CONFIG_ZB_ENABLED=y" + ] +} diff --git a/libraries/Zigbee/keywords.txt b/libraries/Zigbee/keywords.txt index 483d54eb712..2eeed5878a7 100644 --- a/libraries/Zigbee/keywords.txt +++ b/libraries/Zigbee/keywords.txt @@ -21,12 +21,22 @@ ZigbeeThermostat KEYWORD1 ZigbeeFlowSensor KEYWORD1 ZigbeePressureSensor KEYWORD1 ZigbeeOccupancySensor KEYWORD1 +ZigbeeAnalog KEYWORD1 +ZigbeeCarbonDioxideSensor KEYWORD1 +ZigbeeContactSwitch KEYWORD1 +ZigbeeDoorWindowHandle KEYWORD1 +ZigbeeGateway KEYWORD1 +ZigbeeRangeExtender KEYWORD1 +ZigbeeVibrationSensor KEYWORD1 +ZigbeeWindowCovering KEYWORD1 # Other zigbee_role_t KEYWORD1 zbstring_t KEYWORD1 zb_device_params_t KEYWORD1 zigbee_scan_result_t KEYWORD1 +zb_power_source_t KEYWORD1 +ZigbeeWindowCoveringType KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) @@ -126,6 +136,43 @@ setSensorType KEYWORD2 # ZigbeeCarbonDioxideSensor setCarbonDioxide KEYWORD2 +# ZigbeeAnalog +addAnalogValue KEYWORD2 +addAnalogInput KEYWORD2 +addAnalogOutput KEYWORD2 +onAnalogOutputChange KEYWORD2 +setAnalogValue KEYWORD2 +setAnalogInput KEYWORD2 +reportAnalogInput KEYWORD2 +setAnalogInputReporting KEYWORD2 + +# ZigbeeCarbonDioxideSensor +setCarbonDioxide KEYWORD2 + +# ZigbeeContactSwitch + ZigbeeDoorWindowHandle +setIASClientEndpoint KEYWORD2 +setClosed KEYWORD2 +setOpen KEYWORD2 +setTilted KEYWORD2 + +# ZigbeeVibrationSensor +setVibration KEYWORD2 + +ZigbeeWindowCovering +onOpen KEYWORD2 +onClose KEYWORD2 +onGoToLiftPercentage KEYWORD2 +onGoToTiltPercentage KEYWORD2 +onStop KEYWORD2 +setLiftPosition KEYWORD2 +setLiftPercentage KEYWORD2 +setTiltPosition KEYWORD2 +setTiltPercentage KEYWORD2 +setCoveringType KEYWORD2 +setConfigStatus KEYWORD2 +setMode KEYWORD2 +setLimits KEYWORD2 + ####################################### # Constants (LITERAL1) ####################################### @@ -137,7 +184,6 @@ ZIGBEE_DEFAULT_ED_CONFIG LITERAL1 ZIGBEE_DEFAULT_ROUTER_CONFIG LITERAL1 ZIGBEE_DEFAULT_COORDINATOR_CONFIG LITERAL1 ZIGBEE_DEFAULT_RADIO_CONFIG LITERAL1 +ZIGBEE_DEFAULT_UART_RCP_RADIO_CONFIG LITERAL1 ZIGBEE_DEFAULT_HOST_CONFIG LITERAL1 ZB_ARRAY_LENTH LITERAL1 -XYZ_TO_RGB LITERAL1 -RGB_TO_XYZ LITERAL1 diff --git a/libraries/Zigbee/library.properties b/libraries/Zigbee/library.properties index 87e0cd63e9f..9a558d70216 100644 --- a/libraries/Zigbee/library.properties +++ b/libraries/Zigbee/library.properties @@ -1,5 +1,5 @@ name=Zigbee -version=3.1.1 +version=3.2.0 author=P-R-O-C-H-Y maintainer=Jan Procházka sentence=Enables zigbee connection with the ESP32 diff --git a/libraries/Zigbee/src/Zigbee.h b/libraries/Zigbee/src/Zigbee.h index cf58dc8d5d8..e5f669ba899 100644 --- a/libraries/Zigbee/src/Zigbee.h +++ b/libraries/Zigbee/src/Zigbee.h @@ -15,6 +15,14 @@ #include "ep/ZigbeeTempSensor.h" #include "ep/ZigbeeThermostat.h" #include "ep/ZigbeePressureSensor.h" +#include "ep/ZigbeeAnalog.h" #include "ep/ZigbeeFlowSensor.h" #include "ep/ZigbeeOccupancySensor.h" #include "ep/ZigbeeCarbonDioxideSensor.h" +#include "ep/ZigbeeContactSwitch.h" +#include "ep/ZigbeeDoorWindowHandle.h" +#include "ep/ZigbeeWindowCovering.h" +#include "ep/ZigbeeVibrationSensor.h" +#include "ep/ZigbeeRangeExtender.h" +#include "ep/ZigbeeGateway.h" +#include "ep/ZigbeeWindSpeedSensor.h" diff --git a/libraries/Zigbee/src/ZigbeeCore.cpp b/libraries/Zigbee/src/ZigbeeCore.cpp index 19f4d0872b8..bd5849bb4b8 100644 --- a/libraries/Zigbee/src/ZigbeeCore.cpp +++ b/libraries/Zigbee/src/ZigbeeCore.cpp @@ -1,7 +1,7 @@ /* Zigbee Core Functions */ #include "ZigbeeCore.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeHandlers.cpp" #include "Arduino.h" @@ -87,7 +87,11 @@ void ZigbeeCore::addEndpoint(ZigbeeEP *ep) { return; } - esp_zb_ep_list_add_ep(_zb_ep_list, ep->_cluster_list, ep->_ep_config); + if (ep->_device_id == ESP_ZB_HA_HOME_GATEWAY_DEVICE_ID) { + esp_zb_ep_list_add_gateway_ep(_zb_ep_list, ep->_cluster_list, ep->_ep_config); + } else { + esp_zb_ep_list_add_ep(_zb_ep_list, ep->_cluster_list, ep->_ep_config); + } } static void esp_zb_task(void *pvParameters) { @@ -156,7 +160,7 @@ bool ZigbeeCore::zigbeeInit(esp_zb_cfg_t *zb_cfg, bool erase_nvs) { } // Create Zigbee task and start Zigbee stack - xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL); + xTaskCreate(esp_zb_task, "Zigbee_main", 8192, NULL, 5, NULL); return true; } @@ -526,4 +530,4 @@ const char *ZigbeeCore::getDeviceTypeString(esp_zb_ha_standard_devices_t deviceI ZigbeeCore Zigbee = ZigbeeCore(); -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ZigbeeCore.h b/libraries/Zigbee/src/ZigbeeCore.h index 02dce54e5ff..a26e17e58a7 100644 --- a/libraries/Zigbee/src/ZigbeeCore.h +++ b/libraries/Zigbee/src/ZigbeeCore.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "esp_zigbee_core.h" #include "zdo/esp_zigbee_zdo_common.h" @@ -60,6 +60,26 @@ typedef enum { } \ } +#define ZIGBEE_DEFAULT_UART_RCP_RADIO_CONFIG() \ + { \ + .radio_mode = ZB_RADIO_MODE_UART_RCP, \ + .radio_uart_config = { \ + .port = UART_NUM_1, \ + .rx_pin = GPIO_NUM_NC, \ + .tx_pin = GPIO_NUM_NC, \ + .uart_config = \ + { \ + .baud_rate = 460800, \ + .data_bits = UART_DATA_8_BITS, \ + .parity = UART_PARITY_DISABLE, \ + .stop_bits = UART_STOP_BITS_1, \ + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \ + .rx_flow_ctrl_thresh = 0, \ + .source_clk = UART_SCLK_DEFAULT, \ + }, \ + }, \ + } + class ZigbeeCore { private: esp_zb_radio_config_t _radio_config; @@ -144,4 +164,4 @@ class ZigbeeCore { extern ZigbeeCore Zigbee; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ZigbeeEP.cpp b/libraries/Zigbee/src/ZigbeeEP.cpp index adc87540b83..6774e9111f1 100644 --- a/libraries/Zigbee/src/ZigbeeEP.cpp +++ b/libraries/Zigbee/src/ZigbeeEP.cpp @@ -2,7 +2,7 @@ #include "ZigbeeEP.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "esp_zigbee_cluster.h" #include "zcl/esp_zigbee_zcl_power_config.h" @@ -19,6 +19,7 @@ ZigbeeEP::ZigbeeEP(uint8_t endpoint) { _ep_config.endpoint = 0; _cluster_list = nullptr; _on_identify = nullptr; + _time_status = 0; if (!lock) { lock = xSemaphoreCreateBinary(); if (lock == NULL) { @@ -238,4 +239,209 @@ void ZigbeeEP::zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message) { } } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +void ZigbeeEP::addTimeCluster(tm time, int32_t gmt_offset) { + time_t utc_time = 0; + // Check if time is set + if (time.tm_year > 0) { + // Convert time to UTC + utc_time = mktime(&time); + } + + // Create time cluster server attributes + esp_zb_attribute_list_t *time_cluster_server = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_TIME); + esp_zb_time_cluster_add_attr(time_cluster_server, ESP_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID, (void *)&gmt_offset); + esp_zb_time_cluster_add_attr(time_cluster_server, ESP_ZB_ZCL_ATTR_TIME_TIME_ID, (void *)&utc_time); + esp_zb_time_cluster_add_attr(time_cluster_server, ESP_ZB_ZCL_ATTR_TIME_TIME_STATUS_ID, (void *)&_time_status); + // Create time cluster client attributes + esp_zb_attribute_list_t *time_cluster_client = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_TIME); + // Add time clusters to cluster list + esp_zb_cluster_list_add_time_cluster(_cluster_list, time_cluster_server, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_time_cluster(_cluster_list, time_cluster_client, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE); +} + +void ZigbeeEP::setTime(tm time) { + time_t utc_time = mktime(&time); + log_d("Setting time to %lld", utc_time); + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_TIME, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TIME_TIME_ID, &utc_time, false); + esp_zb_lock_release(); +} + +void ZigbeeEP::setTimezone(int32_t gmt_offset) { + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_TIME, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID, &gmt_offset, false); + esp_zb_lock_release(); +} + +tm ZigbeeEP::getTime(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ieee_addr) { + /* Read peer time */ + esp_zb_zcl_read_attr_cmd_t read_req; + + if (short_addr >= 0) { + read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT; + read_req.zcl_basic_cmd.dst_addr_u.addr_short = (uint16_t)short_addr; + } else { + read_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; + memcpy(read_req.zcl_basic_cmd.dst_addr_u.addr_long, ieee_addr, sizeof(esp_zb_ieee_addr_t)); + } + + uint16_t attributes[] = {ESP_ZB_ZCL_ATTR_TIME_TIME_ID}; + read_req.attr_number = ZB_ARRAY_LENTH(attributes); + read_req.attr_field = attributes; + + read_req.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TIME; + + read_req.zcl_basic_cmd.dst_endpoint = endpoint; + read_req.zcl_basic_cmd.src_endpoint = _endpoint; + + // clear read time + _read_time = 0; + + log_v("Reading time from endpoint %d", endpoint); + esp_zb_zcl_read_attr_cmd_req(&read_req); + + //Wait for response or timeout + if (xSemaphoreTake(lock, ZB_CMD_TIMEOUT) != pdTRUE) { + log_e("Error while reading time"); + return tm(); + } + + struct tm *timeinfo = localtime(&_read_time); + if (timeinfo) { + // Update time + setTime(*timeinfo); + // Update time status to synced + _time_status |= 0x02; + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_TIME, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TIME_TIME_STATUS_ID, &_time_status, false + ); + esp_zb_lock_release(); + + return *timeinfo; + } else { + log_e("Error while converting time"); + return tm(); + } +} + +int32_t ZigbeeEP::getTimezone(uint8_t endpoint, int32_t short_addr, esp_zb_ieee_addr_t ieee_addr) { + /* Read peer timezone */ + esp_zb_zcl_read_attr_cmd_t read_req; + + if (short_addr >= 0) { + read_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT; + read_req.zcl_basic_cmd.dst_addr_u.addr_short = (uint16_t)short_addr; + } else { + read_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; + memcpy(read_req.zcl_basic_cmd.dst_addr_u.addr_long, ieee_addr, sizeof(esp_zb_ieee_addr_t)); + } + + uint16_t attributes[] = {ESP_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID}; + read_req.attr_number = ZB_ARRAY_LENTH(attributes); + read_req.attr_field = attributes; + + read_req.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TIME; + + read_req.zcl_basic_cmd.dst_endpoint = endpoint; + read_req.zcl_basic_cmd.src_endpoint = _endpoint; + + // clear read timezone + _read_timezone = 0; + + log_v("Reading timezone from endpoint %d", endpoint); + esp_zb_zcl_read_attr_cmd_req(&read_req); + + //Wait for response or timeout + if (xSemaphoreTake(lock, ZB_CMD_TIMEOUT) != pdTRUE) { + log_e("Error while reading timezone"); + return 0; + } + setTimezone(_read_timezone); + return _read_timezone; +} + +void ZigbeeEP::zbReadTimeCluster(const esp_zb_zcl_attribute_t *attribute) { + /* Time cluster attributes */ + if (attribute->id == ESP_ZB_ZCL_ATTR_TIME_TIME_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_UTC_TIME) { + log_v("Time attribute received"); + log_v("Time: %lld", *(uint32_t *)attribute->data.value); + _read_time = *(uint32_t *)attribute->data.value; + xSemaphoreGive(lock); + } else if (attribute->id == ESP_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_S32) { + log_v("Timezone attribute received"); + log_v("Timezone: %d", *(int32_t *)attribute->data.value); + _read_timezone = *(int32_t *)attribute->data.value; + xSemaphoreGive(lock); + } +} + +// typedef struct esp_zb_ota_cluster_cfg_s { +// uint32_t ota_upgrade_file_version; /*!< The attribute indicates the file version of the running firmware image on the device */ +// uint16_t ota_upgrade_manufacturer; /*!< The attribute indicates the value for the manufacturer of the device */ +// uint16_t ota_upgrade_image_type; /*!< The attribute indicates the the image type of the file that the client is currently downloading */ +// uint32_t ota_upgrade_downloaded_file_ver; /*!< The attribute indicates the file version of the downloaded image on the device*/ +// esp_zb_ota_cluster_cfg_t; + +// typedef struct esp_zb_zcl_ota_upgrade_client_variable_s { +// uint16_t timer_query; /*!< The field indicates the time of querying OTA image for OTA upgrade client */ +// uint16_t hw_version; /*!< The hardware version */ +// uint8_t max_data_size; /*!< The maximum size of OTA data */ +// } esp_zb_zcl_ota_upgrade_client_variable_t; + +void ZigbeeEP::addOTAClient( + uint32_t file_version, uint32_t downloaded_file_ver, uint16_t hw_version, uint16_t manufacturer, uint16_t image_type, uint8_t max_data_size +) { + + esp_zb_ota_cluster_cfg_t ota_cluster_cfg = {}; + ota_cluster_cfg.ota_upgrade_file_version = file_version; //OTA_UPGRADE_RUNNING_FILE_VERSION; + ota_cluster_cfg.ota_upgrade_downloaded_file_ver = downloaded_file_ver; //OTA_UPGRADE_DOWNLOADED_FILE_VERSION; + ota_cluster_cfg.ota_upgrade_manufacturer = manufacturer; //OTA_UPGRADE_MANUFACTURER; + ota_cluster_cfg.ota_upgrade_image_type = image_type; //OTA_UPGRADE_IMAGE_TYPE; + + esp_zb_attribute_list_t *ota_cluster = esp_zb_ota_cluster_create(&ota_cluster_cfg); + + esp_zb_zcl_ota_upgrade_client_variable_t variable_config = {}; + variable_config.timer_query = ESP_ZB_ZCL_OTA_UPGRADE_QUERY_TIMER_COUNT_DEF; + variable_config.hw_version = hw_version; //OTA_UPGRADE_HW_VERSION; + variable_config.max_data_size = max_data_size; //OTA_UPGRADE_MAX_DATA_SIZE; + + uint16_t ota_upgrade_server_addr = 0xffff; + uint8_t ota_upgrade_server_ep = 0xff; + + ESP_ERROR_CHECK(esp_zb_ota_cluster_add_attr(ota_cluster, ESP_ZB_ZCL_ATTR_OTA_UPGRADE_CLIENT_DATA_ID, (void *)&variable_config)); + ESP_ERROR_CHECK(esp_zb_ota_cluster_add_attr(ota_cluster, ESP_ZB_ZCL_ATTR_OTA_UPGRADE_SERVER_ADDR_ID, (void *)&ota_upgrade_server_addr)); + ESP_ERROR_CHECK(esp_zb_ota_cluster_add_attr(ota_cluster, ESP_ZB_ZCL_ATTR_OTA_UPGRADE_SERVER_ENDPOINT_ID, (void *)&ota_upgrade_server_ep)); + + ESP_ERROR_CHECK(esp_zb_cluster_list_add_ota_cluster(_cluster_list, ota_cluster, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE)); +} + +static void findOTAServer(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t endpoint, void *user_ctx) { + if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) { + esp_zb_ota_upgrade_client_query_interval_set(*((uint8_t *)user_ctx), OTA_UPGRADE_QUERY_INTERVAL); + esp_zb_ota_upgrade_client_query_image_req(addr, endpoint); + log_i("Query OTA upgrade from server endpoint: %d after %d seconds", endpoint, OTA_UPGRADE_QUERY_INTERVAL); + } else { + log_w("No OTA Server found"); + } +} + +void ZigbeeEP::requestOTAUpdate() { + esp_zb_zdo_match_desc_req_param_t req; + uint16_t cluster_list[] = {ESP_ZB_ZCL_CLUSTER_ID_OTA_UPGRADE}; + + /* Match the OTA server of coordinator */ + req.addr_of_interest = 0x0000; + req.dst_nwk_addr = 0x0000; + req.num_in_clusters = 1; + req.num_out_clusters = 0; + req.profile_id = ESP_ZB_AF_HA_PROFILE_ID; + req.cluster_list = cluster_list; + esp_zb_lock_acquire(portMAX_DELAY); + if (esp_zb_bdb_dev_joined()) { + esp_zb_zdo_match_cluster(&req, findOTAServer, &_endpoint); + } + esp_zb_lock_release(); +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ZigbeeEP.h b/libraries/Zigbee/src/ZigbeeEP.h index d8ed900a7e6..0a4e3e9d252 100644 --- a/libraries/Zigbee/src/ZigbeeEP.h +++ b/libraries/Zigbee/src/ZigbeeEP.h @@ -3,29 +3,16 @@ #pragma once #include "ZigbeeCore.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include +#include /* Useful defines */ -#define ZB_CMD_TIMEOUT 10000 // 10 seconds +#define ZB_CMD_TIMEOUT 10000 // 10 seconds +#define OTA_UPGRADE_QUERY_INTERVAL (1 * 60) // 1 hour = 60 minutes #define ZB_ARRAY_LENTH(arr) (sizeof(arr) / sizeof(arr[0])) -#define XYZ_TO_RGB(X, Y, Z, r, g, b) \ - { \ - r = (float)(3.240479 * (X) - 1.537150 * (Y) - 0.498535 * (Z)); \ - g = (float)(-0.969256 * (X) + 1.875992 * (Y) + 0.041556 * (Z)); \ - b = (float)(0.055648 * (X) - 0.204043 * (Y) + 1.057311 * (Z)); \ - if (r > 1) { \ - r = 1; \ - } \ - if (g > 1) { \ - g = 1; \ - } \ - if (b > 1) { \ - b = 1; \ - } \ - } #define RGB_TO_XYZ(r, g, b, X, Y, Z) \ { \ @@ -82,20 +69,51 @@ class ZigbeeEP { _allow_multiple_binding = bind; } - // Manufacturer name and model implemented + // Set Manufacturer name and model void setManufacturerAndModel(const char *name, const char *model); - void setPowerSource(zb_power_source_t power_source, uint8_t percentage = 255); - void setBatteryPercentage(uint8_t percentage); - void reportBatteryPercentage(); // Methods to read manufacturer and model name from selected endpoint and short address char *readManufacturer(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr); char *readModel(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr); + // Set Power source and battery percentage for battery powered devices + void setPowerSource(zb_power_source_t power_source, uint8_t percentage = 255); + void setBatteryPercentage(uint8_t percentage); + void reportBatteryPercentage(); + + // Set time + void addTimeCluster(tm time = {}, int32_t gmt_offset = 0); // gmt offset in seconds + void setTime(tm time); + void setTimezone(int32_t gmt_offset); + + // Get time from Coordinator or specific endpoint (blocking until response) + struct tm getTime(uint8_t endpoint = 1, int32_t short_addr = 0x0000, esp_zb_ieee_addr_t ieee_addr = {0}); + int32_t getTimezone(uint8_t endpoint = 1, int32_t short_addr = 0x0000, esp_zb_ieee_addr_t ieee_addr = {0}); // gmt offset in seconds + bool epAllowMultipleBinding() { return _allow_multiple_binding; } + // OTA methods + /** + * @brief Add OTA client to the Zigbee endpoint. + * + * @param file_version The current file version of the OTA client. + * @param downloaded_file_ver The version of the downloaded file. + * @param hw_version The hardware version of the device. + * @param manufacturer The manufacturer code (default: 0x1001). + * @param image_type The image type code (default: 0x1011). + * @param max_data_size The maximum data size for OTA transfer (default and recommended: 223). + */ + void addOTAClient( + uint32_t file_version, uint32_t downloaded_file_ver, uint16_t hw_version, uint16_t manufacturer = 0x1001, uint16_t image_type = 0x1011, + uint8_t max_data_size = 223 + ); + /** + * @brief Request OTA update from the server, first request is within a minute and the next requests are sent every hour automatically. + */ + void requestOTAUpdate(); + // findEndpoind may be implemented by EPs to find and bind devices virtual void findEndpoint(esp_zb_zdo_match_desc_req_param_t *cmd_req) {}; @@ -104,6 +122,15 @@ class ZigbeeEP { virtual void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) {}; virtual void zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented virtual void zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message); + virtual void zbWindowCoveringMovementCmd(const esp_zb_zcl_window_covering_movement_message_t *message) {}; + virtual void zbReadTimeCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented + virtual void zbIASZoneStatusChangeNotification(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) {}; + virtual void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) {}; + + virtual void addBoundDevice(zb_device_params_t *device) { + _bound_devices.push_back(device); + _is_bound = true; + } void onIdentify(void (*callback)(uint16_t)) { _on_identify = callback; @@ -113,6 +140,8 @@ class ZigbeeEP { char *_read_manufacturer; char *_read_model; void (*_on_identify)(uint16_t time); + time_t _read_time; + int32_t _read_timezone; protected: uint8_t _endpoint; @@ -124,12 +153,9 @@ class ZigbeeEP { std::list _bound_devices; SemaphoreHandle_t lock; zb_power_source_t _power_source; + uint8_t _time_status; - void addBoundDevice(zb_device_params_t *device) { - _bound_devices.push_back(device); - _is_bound = true; - } friend class ZigbeeCore; }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ZigbeeHandlers.cpp b/libraries/Zigbee/src/ZigbeeHandlers.cpp index e387b7ce432..eeeb1e8013a 100644 --- a/libraries/Zigbee/src/ZigbeeHandlers.cpp +++ b/libraries/Zigbee/src/ZigbeeHandlers.cpp @@ -2,14 +2,39 @@ #include "ZigbeeCore.h" #include "Arduino.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED + +#include "esp_ota_ops.h" +#if CONFIG_ZB_DELTA_OTA // Delta OTA, code is prepared for this feature but not enabled by default +#include "esp_delta_ota_ops.h" +#endif + +//OTA Upgrade defines and variables +#define OTA_ELEMENT_HEADER_LEN 6 /* OTA element format header size include tag identifier and length field */ + +/** + * @name Enumeration for the tag identifier denotes the type and format of the data within the element + * @anchor esp_ota_element_tag_id_t + */ +typedef enum esp_ota_element_tag_id_e { + UPGRADE_IMAGE = 0x0000, /*!< Upgrade image */ +} esp_ota_element_tag_id_t; + +static const esp_partition_t *s_ota_partition = NULL; +static esp_ota_handle_t s_ota_handle = 0; +static bool s_tagid_received = false; // forward declaration of all implemented handlers static esp_err_t zb_attribute_set_handler(const esp_zb_zcl_set_attr_value_message_t *message); static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_message_t *message); static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_resp_message_t *message); static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_report_resp_message_t *message); +static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message); +static esp_err_t zb_cmd_ias_zone_enroll_response_handler(const esp_zb_zcl_ias_zone_enroll_response_message_t *message); static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message); +static esp_err_t zb_window_covering_movement_resp_handler(const esp_zb_zcl_window_covering_movement_message_t *message); +static esp_err_t zb_ota_upgrade_status_handler(const esp_zb_zcl_ota_upgrade_value_message_t *message); +static esp_err_t zb_ota_upgrade_query_image_resp_handler(const esp_zb_zcl_ota_upgrade_query_image_resp_message_t *message); // Zigbee action handlers [[maybe_unused]] @@ -20,8 +45,21 @@ static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, case ESP_ZB_CORE_REPORT_ATTR_CB_ID: ret = zb_attribute_reporting_handler((esp_zb_zcl_report_attr_message_t *)message); break; case ESP_ZB_CORE_CMD_READ_ATTR_RESP_CB_ID: ret = zb_cmd_read_attr_resp_handler((esp_zb_zcl_cmd_read_attr_resp_message_t *)message); break; case ESP_ZB_CORE_CMD_REPORT_CONFIG_RESP_CB_ID: ret = zb_configure_report_resp_handler((esp_zb_zcl_cmd_config_report_resp_message_t *)message); break; - case ESP_ZB_CORE_CMD_DEFAULT_RESP_CB_ID: ret = zb_cmd_default_resp_handler((esp_zb_zcl_cmd_default_resp_message_t *)message); break; - default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break; + case ESP_ZB_CORE_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID: + ret = zb_cmd_ias_zone_status_change_handler((esp_zb_zcl_ias_zone_status_change_notification_message_t *)message); + break; + case ESP_ZB_CORE_IAS_ZONE_ENROLL_RESPONSE_VALUE_CB_ID: + ret = zb_cmd_ias_zone_enroll_response_handler((esp_zb_zcl_ias_zone_enroll_response_message_t *)message); + break; + case ESP_ZB_CORE_WINDOW_COVERING_MOVEMENT_CB_ID: + ret = zb_window_covering_movement_resp_handler((esp_zb_zcl_window_covering_movement_message_t *)message); + break; + case ESP_ZB_CORE_OTA_UPGRADE_VALUE_CB_ID: ret = zb_ota_upgrade_status_handler((esp_zb_zcl_ota_upgrade_value_message_t *)message); break; + case ESP_ZB_CORE_OTA_UPGRADE_QUERY_IMAGE_RESP_CB_ID: + ret = zb_ota_upgrade_query_image_resp_handler((esp_zb_zcl_ota_upgrade_query_image_resp_message_t *)message); + break; + case ESP_ZB_CORE_CMD_DEFAULT_RESP_CB_ID: ret = zb_cmd_default_resp_handler((esp_zb_zcl_cmd_default_resp_message_t *)message); break; + default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break; } return ret; } @@ -101,6 +139,8 @@ static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_re if (variable->status == ESP_ZB_ZCL_STATUS_SUCCESS) { if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_BASIC) { (*it)->zbReadBasicCluster(&variable->attribute); //method zbReadBasicCluster implemented in the common EP class + } else if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_TIME) { + (*it)->zbReadTimeCluster(&variable->attribute); //method zbReadTimeCluster implemented in the common EP class } else { (*it)->zbAttributeRead(message->info.cluster, &variable->attribute); //method zbAttributeRead must be implemented in specific EP class } @@ -132,6 +172,215 @@ static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_re return ESP_OK; } +static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) { + if (!message) { + log_e("Empty message"); + return ESP_FAIL; + } + if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) { + log_e("Received message: error status(%d)", message->info.status); + return ESP_ERR_INVALID_ARG; + } + log_v( + "IAS Zone Status Notification: from address(0x%x) src endpoint(%d) to dst endpoint(%d) cluster(0x%x)", message->info.src_address.u.short_addr, + message->info.src_endpoint, message->info.dst_endpoint, message->info.cluster + ); + + for (std::list::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) { + if (message->info.dst_endpoint == (*it)->getEndpoint()) { + (*it)->zbIASZoneStatusChangeNotification(message); + } + } + return ESP_OK; +} + +static esp_err_t zb_cmd_ias_zone_enroll_response_handler(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) { + if (!message) { + log_e("Empty message"); + return ESP_FAIL; + } + if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) { + log_e("Received message: error status(%d)", message->info.status); + return ESP_ERR_INVALID_ARG; + } + log_v("IAS Zone Enroll Response received"); + for (std::list::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) { + if (message->info.dst_endpoint == (*it)->getEndpoint()) { + (*it)->zbIASZoneEnrollResponse(message); + } + } + return ESP_OK; +} + +static esp_err_t zb_window_covering_movement_resp_handler(const esp_zb_zcl_window_covering_movement_message_t *message) { + if (!message) { + log_e("Empty message"); + } + if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) { + log_e("Received message: error status(%d)", message->info.status); + } + + log_v( + "Received message: endpoint(%d), cluster(0x%x), command(0x%x), payload(%d)", message->info.dst_endpoint, message->info.cluster, message->command, + message->payload + ); + + // List through all Zigbee EPs and call the callback function, with the message + for (std::list::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) { + if (message->info.dst_endpoint == (*it)->getEndpoint()) { + (*it)->zbWindowCoveringMovementCmd(message); //method zbWindowCoveringMovementCmd must be implemented in specific EP class + } + } + return ESP_OK; +} + +static esp_err_t esp_element_ota_data(uint32_t total_size, const void *payload, uint16_t payload_size, void **outbuf, uint16_t *outlen) { + static uint16_t tagid = 0; + void *data_buf = NULL; + uint16_t data_len; + + if (!s_tagid_received) { + uint32_t length = 0; + if (!payload || payload_size <= OTA_ELEMENT_HEADER_LEN) { + log_e("Invalid element format"); + return ESP_ERR_INVALID_ARG; + } + + const uint8_t *payload_ptr = (const uint8_t *)payload; + tagid = *(const uint16_t *)payload_ptr; + length = *(const uint32_t *)(payload_ptr + sizeof(tagid)); + if ((length + OTA_ELEMENT_HEADER_LEN) != total_size) { + log_e("Invalid element length [%ld/%ld]", length, total_size); + return ESP_ERR_INVALID_ARG; + } + + s_tagid_received = true; + + data_buf = (void *)(payload_ptr + OTA_ELEMENT_HEADER_LEN); + data_len = payload_size - OTA_ELEMENT_HEADER_LEN; + } else { + data_buf = (void *)payload; + data_len = payload_size; + } + + switch (tagid) { + case UPGRADE_IMAGE: + *outbuf = data_buf; + *outlen = data_len; + break; + default: + log_e("Unsupported element tag identifier %d", tagid); + return ESP_ERR_INVALID_ARG; + break; + } + + return ESP_OK; +} + +static esp_err_t zb_ota_upgrade_status_handler(const esp_zb_zcl_ota_upgrade_value_message_t *message) { + static uint32_t total_size = 0; + static uint32_t offset = 0; + [[maybe_unused]] + static int64_t start_time = 0; + esp_err_t ret = ESP_OK; + + if (message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS) { + switch (message->upgrade_status) { + case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_START: + log_i("Zigbee - OTA upgrade start"); + start_time = esp_timer_get_time(); + s_ota_partition = esp_ota_get_next_update_partition(NULL); + assert(s_ota_partition); +#if CONFIG_ZB_DELTA_OTA + ret = esp_delta_ota_begin(s_ota_partition, 0, &s_ota_handle); +#else + ret = esp_ota_begin(s_ota_partition, 0, &s_ota_handle); +#endif + if (ret != ESP_OK) { + log_e("Zigbee - Failed to begin OTA partition, status: %s", esp_err_to_name(ret)); + return ret; + } + break; + case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_RECEIVE: + total_size = message->ota_header.image_size; + offset += message->payload_size; + log_i("Zigbee - OTA Client receives data: progress [%ld/%ld]", offset, total_size); + if (message->payload_size && message->payload) { + uint16_t payload_size = 0; + void *payload = NULL; + ret = esp_element_ota_data(total_size, message->payload, message->payload_size, &payload, &payload_size); + if (ret != ESP_OK) { + log_e("Zigbee - Failed to element OTA data, status: %s", esp_err_to_name(ret)); + return ret; + } +#if CONFIG_ZB_DELTA_OTA + ret = esp_delta_ota_write(s_ota_handle, payload, payload_size); +#else + ret = esp_ota_write(s_ota_handle, (const void *)payload, payload_size); +#endif + if (ret != ESP_OK) { + log_e("Zigbee - Failed to write OTA data to partition, status: %s", esp_err_to_name(ret)); + return ret; + } + } + break; + case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_APPLY: log_i("Zigbee - OTA upgrade apply"); break; + case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_CHECK: + ret = offset == total_size ? ESP_OK : ESP_FAIL; + offset = 0; + total_size = 0; + s_tagid_received = false; + log_i("Zigbee - OTA upgrade check status: %s", esp_err_to_name(ret)); + break; + case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_FINISH: + log_i("Zigbee - OTA Finish"); + log_i( + "Zigbee - OTA Information: version: 0x%lx, manufacturer code: 0x%x, image type: 0x%x, total size: %ld bytes, cost time: %lld ms,", + message->ota_header.file_version, message->ota_header.manufacturer_code, message->ota_header.image_type, message->ota_header.image_size, + (esp_timer_get_time() - start_time) / 1000 + ); +#if CONFIG_ZB_DELTA_OTA + ret = esp_delta_ota_end(s_ota_handle); +#else + ret = esp_ota_end(s_ota_handle); +#endif + if (ret != ESP_OK) { + log_e("Zigbee - Failed to end OTA partition, status: %s", esp_err_to_name(ret)); + return ret; + } + ret = esp_ota_set_boot_partition(s_ota_partition); + if (ret != ESP_OK) { + log_e("Zigbee - Failed to set OTA boot partition, status: %s", esp_err_to_name(ret)); + return ret; + } + log_w("Zigbee - Prepare to restart system"); + esp_restart(); + break; + default: log_i("Zigbee - OTA status: %d", message->upgrade_status); break; + } + } + return ret; +} + +static esp_err_t zb_ota_upgrade_query_image_resp_handler(const esp_zb_zcl_ota_upgrade_query_image_resp_message_t *message) { + if (message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS) { + log_i("Zigbee - Queried OTA image from address: 0x%04hx, endpoint: %d", message->server_addr.u.short_addr, message->server_endpoint); + log_i("Zigbee - Image version: 0x%lx, manufacturer code: 0x%x, image size: %ld", message->file_version, message->manufacturer_code, message->image_size); + if (message->image_size == 0) { + log_i("Zigbee - Rejecting OTA image upgrade, image size is 0"); + return ESP_FAIL; + } + if (message->file_version == 0) { + log_i("Zigbee - Rejecting OTA image upgrade, file version is 0"); + return ESP_FAIL; + } + log_i("Zigbee - Approving OTA image upgrade"); + } else { + log_i("Zigbee - OTA image upgrade response status: 0x%x", message->info.status); + } + return ESP_OK; +} + static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message) { if (!message) { log_e("Empty message"); @@ -148,4 +397,4 @@ static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_m return ESP_OK; } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeAnalog.cpp b/libraries/Zigbee/src/ep/ZigbeeAnalog.cpp new file mode 100644 index 00000000000..417eeb6d98c --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeAnalog.cpp @@ -0,0 +1,125 @@ +#include "ZigbeeAnalog.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *zigbee_analog_clusters_create(zigbee_analog_cfg_t *analog_sensor) { + esp_zb_basic_cluster_cfg_t *basic_cfg = analog_sensor ? &(analog_sensor->basic_cfg) : NULL; + esp_zb_identify_cluster_cfg_t *identify_cfg = analog_sensor ? &(analog_sensor->identify_cfg) : NULL; + esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + return cluster_list; +} + +ZigbeeAnalog::ZigbeeAnalog(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID; + + //Create custom analog sensor configuration + zigbee_analog_cfg_t analog_cfg = ZIGBEE_DEFAULT_ANALOG_CONFIG(); + _cluster_list = zigbee_analog_clusters_create(&analog_cfg); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0}; +} + +void ZigbeeAnalog::addAnalogValue() { + esp_zb_cluster_list_add_analog_value_cluster(_cluster_list, esp_zb_analog_value_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + _analog_clusters |= ANALOG_VALUE; +} + +void ZigbeeAnalog::addAnalogInput() { + esp_zb_cluster_list_add_analog_input_cluster(_cluster_list, esp_zb_analog_input_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + _analog_clusters |= ANALOG_INPUT; +} + +void ZigbeeAnalog::addAnalogOutput() { + esp_zb_cluster_list_add_analog_output_cluster(_cluster_list, esp_zb_analog_output_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + _analog_clusters |= ANALOG_OUTPUT; +} + +//set attribute method -> method overridden in child class +void ZigbeeAnalog::zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) { + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ANALOG_OUTPUT) { + if (message->attribute.id == ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_PRESENT_VALUE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_SINGLE) { + float analog_output = *(float *)message->attribute.data.value; + analogOutputChanged(analog_output); + } else { + log_w("Received message ignored. Attribute ID: %d not supported for Analog Output", message->attribute.id); + } + } else { + log_w("Received message ignored. Cluster ID: %d not supported for Analog endpoint", message->info.cluster); + } +} + +void ZigbeeAnalog::analogOutputChanged(float analog_output) { + if (_on_analog_output_change) { + _on_analog_output_change(analog_output); + } else { + log_w("No callback function set for analog output change"); + } +} + +void ZigbeeAnalog::setAnalogValue(float analog) { + if (!(_analog_clusters & ANALOG_VALUE)) { + log_e("Analog Value cluster not added"); + return; + } + // float zb_analog = analog; + log_d("Setting analog value to %.1f", analog); + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID, &analog, false + ); + esp_zb_lock_release(); +} + +void ZigbeeAnalog::setAnalogInput(float analog) { + if (!(_analog_clusters & ANALOG_INPUT)) { + log_e("Analog Input cluster not added"); + return; + } + // float zb_analog = analog; + log_d("Setting analog input to %.1f", analog); + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID, &analog, false + ); + esp_zb_lock_release(); +} + +void ZigbeeAnalog::reportAnalogInput() { + /* Send report attributes command */ + esp_zb_zcl_report_attr_cmd_t report_attr_cmd; + report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT; + report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID; + report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; + report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_ANALOG_INPUT; + report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); + esp_zb_lock_release(); + log_v("Analog Input report sent"); +} + +void ZigbeeAnalog::setAnalogInputReporting(uint16_t min_interval, uint16_t max_interval, float delta) { + esp_zb_zcl_reporting_info_t reporting_info; + memset(&reporting_info, 0, sizeof(esp_zb_zcl_reporting_info_t)); + reporting_info.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV; + reporting_info.ep = _endpoint; + reporting_info.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_ANALOG_INPUT; + reporting_info.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE; + reporting_info.attr_id = ESP_ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID; + reporting_info.u.send_info.min_interval = min_interval; + reporting_info.u.send_info.max_interval = max_interval; + reporting_info.u.send_info.def_min_interval = min_interval; + reporting_info.u.send_info.def_max_interval = max_interval; + reporting_info.u.send_info.delta.s32 = delta; + reporting_info.dst.profile_id = ESP_ZB_AF_HA_PROFILE_ID; + reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_update_reporting_info(&reporting_info); + esp_zb_lock_release(); +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeAnalog.h b/libraries/Zigbee/src/ep/ZigbeeAnalog.h new file mode 100644 index 00000000000..8993c6ea1a4 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeAnalog.h @@ -0,0 +1,76 @@ +/* Class of Zigbee Analog sensor endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +// clang-format off +#define ZIGBEE_DEFAULT_ANALOG_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + } +// clang-format on + +//enum for bits set to check what analog cluster were added +enum zigbee_analog_clusters { + ANALOG_VALUE = 1, + ANALOG_INPUT = 2, + ANALOG_OUTPUT = 4 +}; + +typedef struct zigbee_analog_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; + esp_zb_identify_cluster_cfg_t identify_cfg; + esp_zb_analog_value_cluster_cfg_t analog_value_cfg; + esp_zb_analog_output_cluster_cfg_t analog_output_cfg; + esp_zb_analog_input_cluster_cfg_t analog_input_cfg; +} zigbee_analog_cfg_t; + +class ZigbeeAnalog : public ZigbeeEP { +public: + ZigbeeAnalog(uint8_t endpoint); + ~ZigbeeAnalog() {} + + // Add analog clusters + void addAnalogValue(); + void addAnalogInput(); + void addAnalogOutput(); + + // Use to set a cb function to be called on analog output change + void onAnalogOutputChange(void (*callback)(float analog)) { + _on_analog_output_change = callback; + } + + // Set the analog value / input + void setAnalogValue(float analog); + void setAnalogInput(float analog); + + // Report Analog Input + void reportAnalogInput(); + + // Set reporting for Analog Input + void setAnalogInputReporting(uint16_t min_interval, uint16_t max_interval, float delta); + +private: + void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) override; + + void (*_on_analog_output_change)(float); + void analogOutputChanged(float analog_output); + + uint8_t _analog_clusters; +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp b/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp index 5def43f4199..2718d9275c2 100644 --- a/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp @@ -1,5 +1,5 @@ #include "ZigbeeCarbonDioxideSensor.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED esp_zb_cluster_list_t *zigbee_carbon_dioxide_sensor_clusters_create(zigbee_carbon_dioxide_sensor_cfg_t *carbon_dioxide_sensor) { esp_zb_basic_cluster_cfg_t *basic_cfg = carbon_dioxide_sensor ? &(carbon_dioxide_sensor->basic_cfg) : NULL; @@ -11,7 +11,6 @@ esp_zb_cluster_list_t *zigbee_carbon_dioxide_sensor_clusters_create(zigbee_carbo esp_zb_cluster_list_add_carbon_dioxide_measurement_cluster( cluster_list, esp_zb_carbon_dioxide_measurement_cluster_create(carbon_dioxide_meas_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE ); - esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); return cluster_list; } @@ -38,13 +37,12 @@ void ZigbeeCarbonDioxideSensor::setTolerance(float tolerance) { float zb_tolerance = tolerance / 1000000.0f; esp_zb_attribute_list_t *carbon_dioxide_measure_cluster = esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); - esp_zb_temperature_meas_cluster_add_attr(carbon_dioxide_measure_cluster, ESP_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID, (void *)&zb_tolerance); + esp_zb_carbon_dioxide_measurement_cluster_add_attr( + carbon_dioxide_measure_cluster, ESP_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID, (void *)&zb_tolerance + ); } void ZigbeeCarbonDioxideSensor::setReporting(uint16_t min_interval, uint16_t max_interval, uint16_t delta) { - if (delta > 0) { - log_e("Delta reporting is currently not supported by the carbon dioxide sensor"); - } esp_zb_zcl_reporting_info_t reporting_info; memset(&reporting_info, 0, sizeof(esp_zb_zcl_reporting_info_t)); reporting_info.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV; @@ -87,6 +85,7 @@ void ZigbeeCarbonDioxideSensor::report() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -94,4 +93,4 @@ void ZigbeeCarbonDioxideSensor::report() { log_v("Carbon dioxide report sent"); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h b/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h index 7744fd02f00..41a9a4fb355 100644 --- a/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h +++ b/libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -58,4 +58,4 @@ class ZigbeeCarbonDioxideSensor : public ZigbeeEP { void report(); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp index f034daba54a..585b1549816 100644 --- a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp @@ -1,11 +1,20 @@ #include "ZigbeeColorDimmableLight.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED ZigbeeColorDimmableLight::ZigbeeColorDimmableLight(uint8_t endpoint) : ZigbeeEP(endpoint) { _device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID; - esp_zb_color_dimmable_light_cfg_t light_cfg = ESP_ZB_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG(); + esp_zb_color_dimmable_light_cfg_t light_cfg = ZIGBEE_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG(); _cluster_list = esp_zb_color_dimmable_light_clusters_create(&light_cfg); + + //Add support for hue and saturation + uint8_t hue = 0; + uint8_t saturation = 0; + + esp_zb_attribute_list_t *color_cluster = esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_color_control_cluster_add_attr(color_cluster, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID, &hue); + esp_zb_color_control_cluster_add_attr(color_cluster, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID, &saturation); + _ep_config = { .endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID, .app_device_version = 0 }; @@ -13,9 +22,7 @@ ZigbeeColorDimmableLight::ZigbeeColorDimmableLight(uint8_t endpoint) : ZigbeeEP( //set default values _current_state = false; _current_level = 255; - _current_red = 255; - _current_green = 255; - _current_blue = 255; + _current_color = {255, 255, 255}; } uint16_t ZigbeeColorDimmableLight::getCurrentColorX() { @@ -32,37 +39,18 @@ uint16_t ZigbeeColorDimmableLight::getCurrentColorY() { ->data_p); } -void ZigbeeColorDimmableLight::calculateRGB(uint16_t x, uint16_t y, uint8_t &red, uint8_t &green, uint8_t &blue) { - float r, g, b, color_x, color_y; - color_x = (float)x / 65535; - color_y = (float)y / 65535; - - float color_X = color_x / color_y; - float color_Z = (1 - color_x - color_y) / color_y; - - XYZ_TO_RGB(color_X, 1, color_Z, r, g, b); - - red = (uint8_t)(r * (float)255); - green = (uint8_t)(g * (float)255); - blue = (uint8_t)(b * (float)255); +uint8_t ZigbeeColorDimmableLight::getCurrentColorHue() { + return (*(uint8_t *)esp_zb_zcl_get_attribute( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID + ) + ->data_p); } -void ZigbeeColorDimmableLight::calculateXY(uint8_t red, uint8_t green, uint8_t blue, uint16_t &x, uint16_t &y) { - // Convert RGB to XYZ - float r = (float)red / 255.0f; - float g = (float)green / 255.0f; - float b = (float)blue / 255.0f; - - float X, Y, Z; - RGB_TO_XYZ(r, g, b, X, Y, Z); - - // Convert XYZ to xy chromaticity coordinates - float color_x = X / (X + Y + Z); - float color_y = Y / (X + Y + Z); - - // Convert normalized xy to 16-bit values - x = (uint16_t)(color_x * 65535.0f); - y = (uint16_t)(color_y * 65535.0f); +uint8_t ZigbeeColorDimmableLight::getCurrentColorSaturation() { + return (*(uint16_t *)esp_zb_zcl_get_attribute( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID + ) + ->data_p); } //set attribute method -> method overridden in child class @@ -94,11 +82,7 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me uint16_t light_color_x = (*(uint16_t *)message->attribute.data.value); uint16_t light_color_y = getCurrentColorY(); //calculate RGB from XY and call setColor() - uint8_t red, green, blue; - calculateRGB(light_color_x, light_color_y, red, green, blue); - _current_blue = blue; - _current_green = green; - _current_red = red; + _current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct lightChanged(); return; @@ -106,11 +90,17 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me uint16_t light_color_x = getCurrentColorX(); uint16_t light_color_y = (*(uint16_t *)message->attribute.data.value); //calculate RGB from XY and call setColor() - uint8_t red, green, blue; - calculateRGB(light_color_x, light_color_y, red, green, blue); - _current_blue = blue; - _current_green = green; - _current_red = red; + _current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct + lightChanged(); + return; + } else if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U8) { + uint8_t light_color_hue = (*(uint8_t *)message->attribute.data.value); + _current_color = espHsvToRgbColor(light_color_hue, getCurrentColorSaturation(), 255); + lightChanged(); + return; + } else if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U8) { + uint8_t light_color_saturation = (*(uint8_t *)message->attribute.data.value); + _current_color = espHsvToRgbColor(getCurrentColorHue(), light_color_saturation, 255); lightChanged(); return; } else { @@ -123,7 +113,7 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me void ZigbeeColorDimmableLight::lightChanged() { if (_on_light_change) { - _on_light_change(_current_state, _current_red, _current_green, _current_blue, _current_level); + _on_light_change(_current_state, _current_color.r, _current_color.g, _current_color.b, _current_level); } } @@ -131,12 +121,13 @@ void ZigbeeColorDimmableLight::setLight(bool state, uint8_t level, uint8_t red, //Update all attributes _current_state = state; _current_level = level; - _current_red = red; - _current_green = green; - _current_blue = blue; + _current_color = {red, green, blue}; lightChanged(); - log_v("Updating on/off light state to %d", state); + espXyColor_t xy_color = espRgbColorToXYColor(_current_color); + espHsvColor_t hsv_color = espRgbColorToHsvColor(_current_color); + + log_v("Updating light state: %d, level: %d, color: %d, %d, %d", state, level, red, green, blue); /* Update light clusters */ esp_zb_lock_acquire(portMAX_DELAY); //set on/off state @@ -147,28 +138,43 @@ void ZigbeeColorDimmableLight::setLight(bool state, uint8_t level, uint8_t red, esp_zb_zcl_set_attribute_val( _endpoint, ESP_ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_LEVEL_CONTROL_CURRENT_LEVEL_ID, &_current_level, false ); - //set color - uint16_t color_x, color_y; - calculateXY(red, green, blue, color_x, color_y); + //set xy color + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_X_ID, &xy_color.x, false + ); esp_zb_zcl_set_attribute_val( - _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_X_ID, &color_x, false + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_Y_ID, &xy_color.y, false ); + //set hsv color + uint8_t hue = (uint8_t)hsv_color.h; esp_zb_zcl_set_attribute_val( - _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_Y_ID, &color_y, false + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID, &hue, false + ); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID, &hsv_color.s, false ); esp_zb_lock_release(); } void ZigbeeColorDimmableLight::setLightState(bool state) { - setLight(state, _current_level, _current_red, _current_green, _current_blue); + setLight(state, _current_level, _current_color.r, _current_color.g, _current_color.b); } void ZigbeeColorDimmableLight::setLightLevel(uint8_t level) { - setLight(_current_state, level, _current_red, _current_green, _current_blue); + setLight(_current_state, level, _current_color.r, _current_color.g, _current_color.b); } void ZigbeeColorDimmableLight::setLightColor(uint8_t red, uint8_t green, uint8_t blue) { setLight(_current_state, _current_level, red, green, blue); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +void ZigbeeColorDimmableLight::setLightColor(espRgbColor_t rgb_color) { + setLight(_current_state, _current_level, rgb_color.r, rgb_color.g, rgb_color.b); +} + +void ZigbeeColorDimmableLight::setLightColor(espHsvColor_t hsv_color) { + espRgbColor_t rgb_color = espHsvColorToRgbColor(hsv_color); + setLight(_current_state, _current_level, rgb_color.r, rgb_color.g, rgb_color.b); +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.h b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.h index dad267c7b39..64df3565793 100644 --- a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.h +++ b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.h @@ -4,11 +4,52 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" +#define ZIGBEE_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .groups_cfg = \ + { \ + .groups_name_support_id = ESP_ZB_ZCL_GROUPS_NAME_SUPPORT_DEFAULT_VALUE, \ + }, \ + .scenes_cfg = \ + { \ + .scenes_count = ESP_ZB_ZCL_SCENES_SCENE_COUNT_DEFAULT_VALUE, \ + .current_scene = ESP_ZB_ZCL_SCENES_CURRENT_SCENE_DEFAULT_VALUE, \ + .current_group = ESP_ZB_ZCL_SCENES_CURRENT_GROUP_DEFAULT_VALUE, \ + .scene_valid = ESP_ZB_ZCL_SCENES_SCENE_VALID_DEFAULT_VALUE, \ + .name_support = ESP_ZB_ZCL_SCENES_NAME_SUPPORT_DEFAULT_VALUE, \ + }, \ + .on_off_cfg = \ + { \ + .on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE, \ + }, \ + .level_cfg = \ + { \ + .current_level = ESP_ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_DEFAULT_VALUE, \ + }, \ + .color_cfg = { \ + .current_x = ESP_ZB_ZCL_COLOR_CONTROL_CURRENT_X_DEF_VALUE, \ + .current_y = ESP_ZB_ZCL_COLOR_CONTROL_CURRENT_Y_DEF_VALUE, \ + .color_mode = ESP_ZB_ZCL_COLOR_CONTROL_COLOR_MODE_DEFAULT_VALUE, \ + .options = ESP_ZB_ZCL_COLOR_CONTROL_OPTIONS_DEFAULT_VALUE, \ + .enhanced_color_mode = ESP_ZB_ZCL_COLOR_CONTROL_ENHANCED_COLOR_MODE_DEFAULT_VALUE, \ + .color_capabilities = 0x0009, \ + }, \ + } + class ZigbeeColorDimmableLight : public ZigbeeEP { public: ZigbeeColorDimmableLight(uint8_t endpoint); @@ -24,6 +65,8 @@ class ZigbeeColorDimmableLight : public ZigbeeEP { void setLightState(bool state); void setLightLevel(uint8_t level); void setLightColor(uint8_t red, uint8_t green, uint8_t blue); + void setLightColor(espRgbColor_t rgb_color); + void setLightColor(espHsvColor_t hsv_color); void setLight(bool state, uint8_t level, uint8_t red, uint8_t green, uint8_t blue); bool getLightState() { @@ -32,23 +75,26 @@ class ZigbeeColorDimmableLight : public ZigbeeEP { uint8_t getLightLevel() { return _current_level; } + espRgbColor_t getLightColor() { + return _current_color; + } uint8_t getLightRed() { - return _current_red; + return _current_color.r; } uint8_t getLightGreen() { - return _current_green; + return _current_color.g; } uint8_t getLightBlue() { - return _current_blue; + return _current_color.b; } private: void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) override; - void calculateRGB(uint16_t x, uint16_t y, uint8_t &red, uint8_t &green, uint8_t &blue); - void calculateXY(uint8_t red, uint8_t green, uint8_t blue, uint16_t &x, uint16_t &y); uint16_t getCurrentColorX(); uint16_t getCurrentColorY(); + uint8_t getCurrentColorHue(); + uint8_t getCurrentColorSaturation(); void lightChanged(); //callback function to be called on light change (State, R, G, B, Level) @@ -56,9 +102,7 @@ class ZigbeeColorDimmableLight : public ZigbeeEP { bool _current_state; uint8_t _current_level; - uint16_t _current_red; - uint16_t _current_green; - uint16_t _current_blue; + espRgbColor_t _current_color; }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp b/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp index 4fd492a5477..68f287153cb 100644 --- a/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp @@ -1,5 +1,5 @@ #include "ZigbeeColorDimmerSwitch.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED // Initialize the static instance pointer ZigbeeColorDimmerSwitch *ZigbeeColorDimmerSwitch::_instance = nullptr; @@ -16,24 +16,6 @@ ZigbeeColorDimmerSwitch::ZigbeeColorDimmerSwitch(uint8_t endpoint) : ZigbeeEP(en }; } -void ZigbeeColorDimmerSwitch::calculateXY(uint8_t red, uint8_t green, uint8_t blue, uint16_t &x, uint16_t &y) { - // Convert RGB to XYZ - float r = (float)red / 255.0f; - float g = (float)green / 255.0f; - float b = (float)blue / 255.0f; - - float X, Y, Z; - RGB_TO_XYZ(r, g, b, X, Y, Z); - - // Convert XYZ to xy chromaticity coordinates - float color_x = X / (X + Y + Z); - float color_y = Y / (X + Y + Z); - - // Convert normalized xy to 16-bit values - x = (uint16_t)(color_x * 65535.0f); - y = (uint16_t)(color_y * 65535.0f); -} - void ZigbeeColorDimmerSwitch::bindCb(esp_zb_zdp_status_t zdo_status, void *user_ctx) { if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) { log_i("Bound successfully!"); @@ -417,15 +399,13 @@ void ZigbeeColorDimmerSwitch::setLightLevel(uint8_t level, uint8_t endpoint, esp void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t blue) { if (_is_bound) { - //Convert RGB to XY - uint16_t color_x, color_y; - calculateXY(red, green, blue, color_x, color_y); + espXyColor_t xy_color = espRgbToXYColor(red, green, blue); esp_zb_zcl_color_move_to_color_cmd_t cmd_req; cmd_req.zcl_basic_cmd.src_endpoint = _endpoint; cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT; - cmd_req.color_x = color_x; - cmd_req.color_y = color_y; + cmd_req.color_x = xy_color.x; + cmd_req.color_y = xy_color.y; cmd_req.transition_time = 0; log_v("Sending 'set light color' command"); esp_zb_lock_acquire(portMAX_DELAY); @@ -438,16 +418,14 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint16_t group_addr) { if (_is_bound) { - //Convert RGB to XY - uint16_t color_x, color_y; - calculateXY(red, green, blue, color_x, color_y); + espXyColor_t xy_color = espRgbToXYColor(red, green, blue); esp_zb_zcl_color_move_to_color_cmd_t cmd_req; cmd_req.zcl_basic_cmd.src_endpoint = _endpoint; cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = group_addr; cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT; - cmd_req.color_x = color_x; - cmd_req.color_y = color_y; + cmd_req.color_x = xy_color.x; + cmd_req.color_y = xy_color.y; cmd_req.transition_time = 0; log_v("Sending 'set light color' command to group address 0x%x", group_addr); esp_zb_lock_acquire(portMAX_DELAY); @@ -460,17 +438,15 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t endpoint, uint16_t short_addr) { if (_is_bound) { - //Convert RGB to XY - uint16_t color_x, color_y; - calculateXY(red, green, blue, color_x, color_y); + espXyColor_t xy_color = espRgbToXYColor(red, green, blue); esp_zb_zcl_color_move_to_color_cmd_t cmd_req; cmd_req.zcl_basic_cmd.src_endpoint = _endpoint; cmd_req.zcl_basic_cmd.dst_endpoint = endpoint; cmd_req.zcl_basic_cmd.dst_addr_u.addr_short = short_addr; cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT; - cmd_req.color_x = color_x; - cmd_req.color_y = color_y; + cmd_req.color_x = xy_color.x; + cmd_req.color_y = xy_color.y; cmd_req.transition_time = 0; log_v("Sending 'set light color' command to endpoint %d, address 0x%x", endpoint, short_addr); esp_zb_lock_acquire(portMAX_DELAY); @@ -483,17 +459,15 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr) { if (_is_bound) { - //Convert RGB to XY - uint16_t color_x, color_y; - calculateXY(red, green, blue, color_x, color_y); + espXyColor_t xy_color = espRgbToXYColor(red, green, blue); esp_zb_zcl_color_move_to_color_cmd_t cmd_req; cmd_req.zcl_basic_cmd.src_endpoint = _endpoint; cmd_req.zcl_basic_cmd.dst_endpoint = endpoint; cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; memcpy(cmd_req.zcl_basic_cmd.dst_addr_u.addr_long, ieee_addr, sizeof(esp_zb_ieee_addr_t)); - cmd_req.color_x = color_x; - cmd_req.color_y = color_y; + cmd_req.color_x = xy_color.x; + cmd_req.color_y = xy_color.y; cmd_req.transition_time = 0; log_v( "Sending 'set light color' command to endpoint %d, ieee address %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", endpoint, ieee_addr[7], ieee_addr[6], @@ -507,4 +481,4 @@ void ZigbeeColorDimmerSwitch::setLightColor(uint8_t red, uint8_t green, uint8_t } } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.h b/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.h index ca67fb4ba62..dbe50a20230 100644 --- a/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.h +++ b/libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -55,4 +55,4 @@ class ZigbeeColorDimmerSwitch : public ZigbeeEP { void calculateXY(uint8_t red, uint8_t green, uint8_t blue, uint16_t &x, uint16_t &y); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp b/libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp new file mode 100644 index 00000000000..6237315d5d9 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp @@ -0,0 +1,96 @@ +#include "ZigbeeContactSwitch.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *zigbee_contact_switch_clusters_create(zigbee_contact_switch_cfg_t *contact_switch) { + esp_zb_basic_cluster_cfg_t *basic_cfg = contact_switch ? &(contact_switch->basic_cfg) : NULL; + esp_zb_identify_cluster_cfg_t *identify_cfg = contact_switch ? &(contact_switch->identify_cfg) : NULL; + esp_zb_ias_zone_cluster_cfg_t *ias_zone_cfg = contact_switch ? &(contact_switch->ias_zone_cfg) : NULL; + esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_ias_zone_cluster(cluster_list, esp_zb_ias_zone_cluster_create(ias_zone_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + return cluster_list; +} + +ZigbeeContactSwitch::ZigbeeContactSwitch(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_IAS_ZONE_ID; + _zone_status = 0; + _zone_id = 0xff; + _ias_cie_endpoint = 1; + + //Create custom contact switch configuration + zigbee_contact_switch_cfg_t contact_switch_cfg = ZIGBEE_DEFAULT_CONTACT_SWITCH_CONFIG(); + _cluster_list = zigbee_contact_switch_clusters_create(&contact_switch_cfg); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_IAS_ZONE_ID, .app_device_version = 0}; +} + +void ZigbeeContactSwitch::setIASClientEndpoint(uint8_t ep_number) { + _ias_cie_endpoint = ep_number; +} + +void ZigbeeContactSwitch::setClosed() { + log_v("Setting Contact switch to closed"); + uint8_t closed = 0; // ALARM1 = 0, ALARM2 = 0 + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &closed, false + ); + esp_zb_lock_release(); + _zone_status = closed; + report(); +} + +void ZigbeeContactSwitch::setOpen() { + log_v("Setting Contact switch to open"); + uint8_t open = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1 | ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM2; // ALARM1 = 1, ALARM2 = 1 + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &open, false); + esp_zb_lock_release(); + _zone_status = open; + report(); +} + +void ZigbeeContactSwitch::report() { + /* Send IAS Zone status changed notification command */ + + esp_zb_zcl_ias_zone_status_change_notif_cmd_t status_change_notif_cmd; + status_change_notif_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; + status_change_notif_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + status_change_notif_cmd.zcl_basic_cmd.dst_endpoint = _ias_cie_endpoint; //default is 1 + memcpy(status_change_notif_cmd.zcl_basic_cmd.dst_addr_u.addr_long, _ias_cie_addr, sizeof(esp_zb_ieee_addr_t)); + + status_change_notif_cmd.zone_status = _zone_status; + status_change_notif_cmd.extend_status = 0; + status_change_notif_cmd.zone_id = _zone_id; + status_change_notif_cmd.delay = 0; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_ias_zone_status_change_notif_cmd_req(&status_change_notif_cmd); + esp_zb_lock_release(); + log_v("IAS Zone status changed notification sent"); +} + +void ZigbeeContactSwitch::zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) { + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE) { + log_v("IAS Zone Enroll Response: zone id(%d), status(%d)", message->zone_id, message->response_code); + if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) { + log_v("IAS Zone Enroll Response: success"); + esp_zb_lock_acquire(portMAX_DELAY); + memcpy( + _ias_cie_addr, + (*(esp_zb_ieee_addr_t *) + esp_zb_zcl_get_attribute(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID) + ->data_p), + sizeof(esp_zb_ieee_addr_t) + ); + esp_zb_lock_release(); + _zone_id = message->zone_id; + } + + } else { + log_w("Received message ignored. Cluster ID: %d not supported for On/Off Light", message->info.cluster); + } +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeContactSwitch.h b/libraries/Zigbee/src/ep/ZigbeeContactSwitch.h new file mode 100644 index 00000000000..f44ce1cec40 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeContactSwitch.h @@ -0,0 +1,67 @@ +/* Class of Zigbee contact switch (IAS Zone) endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +// clang-format off +#define ZIGBEE_DEFAULT_CONTACT_SWITCH_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .ias_zone_cfg = \ + { \ + .zone_state = ESP_ZB_ZCL_IAS_ZONE_ZONESTATE_NOT_ENROLLED, \ + .zone_type = ESP_ZB_ZCL_IAS_ZONE_ZONETYPE_CONTACT_SWITCH, \ + .zone_status = 0, \ + .ias_cie_addr = ESP_ZB_ZCL_ZONE_IAS_CIE_ADDR_DEFAULT, \ + .zone_id = 0xff, \ + .zone_ctx = {0, 0, 0, 0}, \ + }, \ + } +// clang-format on + +typedef struct zigbee_contact_switch_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; + esp_zb_identify_cluster_cfg_t identify_cfg; + esp_zb_ias_zone_cluster_cfg_t ias_zone_cfg; +} zigbee_contact_switch_cfg_t; + +class ZigbeeContactSwitch : public ZigbeeEP { +public: + ZigbeeContactSwitch(uint8_t endpoint); + ~ZigbeeContactSwitch() {} + + // Set the IAS Client endpoint number (default is 1) + void setIASClientEndpoint(uint8_t ep_number); + + // Set the contact switch value to closed + void setClosed(); + + // Set the contact switch value to open + void setOpen(); + + // Report the contact switch value, done automatically after setting the position + void report(); + +private: + void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) override; + uint8_t _zone_status; + uint8_t _zone_id; + esp_zb_ieee_addr_t _ias_cie_addr; + uint8_t _ias_cie_endpoint; +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeDimmableLight.cpp b/libraries/Zigbee/src/ep/ZigbeeDimmableLight.cpp index 00d3aac3752..34622d1d2db 100644 --- a/libraries/Zigbee/src/ep/ZigbeeDimmableLight.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeDimmableLight.cpp @@ -1,6 +1,6 @@ #include "ZigbeeDimmableLight.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "esp_zigbee_cluster.h" diff --git a/libraries/Zigbee/src/ep/ZigbeeDimmableLight.h b/libraries/Zigbee/src/ep/ZigbeeDimmableLight.h index 6f92c3315e4..45c3e97c00b 100644 --- a/libraries/Zigbee/src/ep/ZigbeeDimmableLight.h +++ b/libraries/Zigbee/src/ep/ZigbeeDimmableLight.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" diff --git a/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp b/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp new file mode 100644 index 00000000000..70008fbab10 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp @@ -0,0 +1,108 @@ +#include "ZigbeeDoorWindowHandle.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *zigbee_door_window_handle_clusters_create(zigbee_door_window_handle_cfg_t *door_window_handle) { + esp_zb_basic_cluster_cfg_t *basic_cfg = door_window_handle ? &(door_window_handle->basic_cfg) : NULL; + esp_zb_identify_cluster_cfg_t *identify_cfg = door_window_handle ? &(door_window_handle->identify_cfg) : NULL; + esp_zb_ias_zone_cluster_cfg_t *ias_zone_cfg = door_window_handle ? &(door_window_handle->ias_zone_cfg) : NULL; + esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_ias_zone_cluster(cluster_list, esp_zb_ias_zone_cluster_create(ias_zone_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + return cluster_list; +} + +ZigbeeDoorWindowHandle::ZigbeeDoorWindowHandle(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_IAS_ZONE_ID; + _zone_status = 0; + _zone_id = 0xff; + _ias_cie_endpoint = 1; + + //Create custom door window handle configuration + zigbee_door_window_handle_cfg_t door_window_handle_cfg = ZIGBEE_DEFAULT_DOOR_WINDOW_HANDLE_CONFIG(); + _cluster_list = zigbee_door_window_handle_clusters_create(&door_window_handle_cfg); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_IAS_ZONE_ID, .app_device_version = 0}; +} + +void ZigbeeDoorWindowHandle::setIASClientEndpoint(uint8_t ep_number) { + _ias_cie_endpoint = ep_number; +} + +void ZigbeeDoorWindowHandle::setClosed() { + log_v("Setting Door/Window handle to closed"); + uint8_t closed = 0; // ALARM1 = 0, ALARM2 = 0 + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &closed, false + ); + esp_zb_lock_release(); + _zone_status = closed; + report(); +} + +void ZigbeeDoorWindowHandle::setOpen() { + log_v("Setting Door/Window handle to open"); + uint8_t open = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1 | ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM2; // ALARM1 = 1, ALARM2 = 1 + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &open, false); + esp_zb_lock_release(); + _zone_status = open; + report(); +} + +void ZigbeeDoorWindowHandle::setTilted() { + log_v("Setting Door/Window handle to tilted"); + uint8_t tilted = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1; // ALARM1 = 1, ALARM2 = 0 + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &tilted, false + ); + esp_zb_lock_release(); + _zone_status = tilted; + report(); +} + +void ZigbeeDoorWindowHandle::report() { + /* Send IAS Zone status changed notification command */ + + esp_zb_zcl_ias_zone_status_change_notif_cmd_t status_change_notif_cmd; + status_change_notif_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; + status_change_notif_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + status_change_notif_cmd.zcl_basic_cmd.dst_endpoint = _ias_cie_endpoint; //default is 1 + memcpy(status_change_notif_cmd.zcl_basic_cmd.dst_addr_u.addr_long, _ias_cie_addr, sizeof(esp_zb_ieee_addr_t)); + + status_change_notif_cmd.zone_status = _zone_status; + status_change_notif_cmd.extend_status = 0; + status_change_notif_cmd.zone_id = _zone_id; + status_change_notif_cmd.delay = 0; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_ias_zone_status_change_notif_cmd_req(&status_change_notif_cmd); + esp_zb_lock_release(); + log_v("IAS Zone status changed notification sent"); +} + +void ZigbeeDoorWindowHandle::zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) { + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE) { + log_v("IAS Zone Enroll Response: zone id(%d), status(%d)", message->zone_id, message->response_code); + if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) { + log_v("IAS Zone Enroll Response: success"); + esp_zb_lock_acquire(portMAX_DELAY); + memcpy( + _ias_cie_addr, + (*(esp_zb_ieee_addr_t *) + esp_zb_zcl_get_attribute(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID) + ->data_p), + sizeof(esp_zb_ieee_addr_t) + ); + esp_zb_lock_release(); + _zone_id = message->zone_id; + } + + } else { + log_w("Received message ignored. Cluster ID: %d not supported for On/Off Light", message->info.cluster); + } +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.h b/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.h new file mode 100644 index 00000000000..8d4eff9e45a --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.h @@ -0,0 +1,71 @@ +/* Class of Zigbee door window handle (IAS Zone) endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +#define ESP_ZB_ZCL_IAS_ZONE_ZONETYPE_DOOR_WINDOW_HANDLE 0x0016 +// clang-format off +#define ZIGBEE_DEFAULT_DOOR_WINDOW_HANDLE_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .ias_zone_cfg = \ + { \ + .zone_state = ESP_ZB_ZCL_IAS_ZONE_ZONESTATE_NOT_ENROLLED, \ + .zone_type = ESP_ZB_ZCL_IAS_ZONE_ZONETYPE_DOOR_WINDOW_HANDLE, \ + .zone_status = 0, \ + .ias_cie_addr = ESP_ZB_ZCL_ZONE_IAS_CIE_ADDR_DEFAULT, \ + .zone_id = 0xff, \ + .zone_ctx = {0, 0, 0, 0}, \ + }, \ + } +// clang-format on + +typedef struct zigbee_door_window_handle_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; + esp_zb_identify_cluster_cfg_t identify_cfg; + esp_zb_ias_zone_cluster_cfg_t ias_zone_cfg; +} zigbee_door_window_handle_cfg_t; + +class ZigbeeDoorWindowHandle : public ZigbeeEP { +public: + ZigbeeDoorWindowHandle(uint8_t endpoint); + ~ZigbeeDoorWindowHandle() {} + + // Set the IAS Client endpoint number (default is 1) + void setIASClientEndpoint(uint8_t ep_number); + + // Set the door/window handle value to closed + void setClosed(); + + // Set the door/window handle value to open + void setOpen(); + + // Set the door/window handle value to tilted + void setTilted(); + + // Report the door/window handle value, done automatically after setting the position + void report(); + +private: + void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) override; + uint8_t _zone_status; + uint8_t _zone_id; + esp_zb_ieee_addr_t _ias_cie_addr; + uint8_t _ias_cie_endpoint; +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp b/libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp index 75196e78543..11fbf7c906b 100644 --- a/libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp @@ -1,5 +1,5 @@ #include "ZigbeeFlowSensor.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED esp_zb_cluster_list_t *zigbee_flow_sensor_clusters_create(zigbee_flow_sensor_cfg_t *flow_sensor) { esp_zb_basic_cluster_cfg_t *basic_cfg = flow_sensor ? &(flow_sensor->basic_cfg) : NULL; @@ -9,7 +9,6 @@ esp_zb_cluster_list_t *zigbee_flow_sensor_clusters_create(zigbee_flow_sensor_cfg esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_flow_meas_cluster(cluster_list, esp_zb_flow_meas_cluster_create(flow_meas_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); - esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); return cluster_list; } @@ -80,6 +79,7 @@ void ZigbeeFlowSensor::report() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_FLOW_MEASUREMENT; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -87,4 +87,4 @@ void ZigbeeFlowSensor::report() { log_v("Flow report sent"); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeFlowSensor.h b/libraries/Zigbee/src/ep/ZigbeeFlowSensor.h index 7d5ec26f7ec..5e9e20e4d1a 100644 --- a/libraries/Zigbee/src/ep/ZigbeeFlowSensor.h +++ b/libraries/Zigbee/src/ep/ZigbeeFlowSensor.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -57,4 +57,4 @@ class ZigbeeFlowSensor : public ZigbeeEP { void report(); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeGateway.cpp b/libraries/Zigbee/src/ep/ZigbeeGateway.cpp new file mode 100644 index 00000000000..b0be81395ca --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeGateway.cpp @@ -0,0 +1,15 @@ +#include "ZigbeeGateway.h" +#if CONFIG_ZB_ENABLED + +ZigbeeGateway::ZigbeeGateway(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_HOME_GATEWAY_DEVICE_ID; + + _cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(_cluster_list, esp_zb_identify_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(_cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_HOME_GATEWAY_DEVICE_ID, .app_device_version = 0}; +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeGateway.h b/libraries/Zigbee/src/ep/ZigbeeGateway.h new file mode 100644 index 00000000000..3925630c0b8 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeGateway.h @@ -0,0 +1,18 @@ +/* Class of Zigbee Gateway endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +class ZigbeeGateway : public ZigbeeEP { +public: + ZigbeeGateway(uint8_t endpoint); + ~ZigbeeGateway() {} +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeLight.cpp b/libraries/Zigbee/src/ep/ZigbeeLight.cpp index 100efe34a86..2a87db71287 100644 --- a/libraries/Zigbee/src/ep/ZigbeeLight.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeLight.cpp @@ -1,5 +1,5 @@ #include "ZigbeeLight.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED ZigbeeLight::ZigbeeLight(uint8_t endpoint) : ZigbeeEP(endpoint) { _device_id = ESP_ZB_HA_ON_OFF_LIGHT_DEVICE_ID; @@ -46,4 +46,4 @@ void ZigbeeLight::setLight(bool state) { esp_zb_lock_release(); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeLight.h b/libraries/Zigbee/src/ep/ZigbeeLight.h index 8cf8c35f781..807802be9b3 100644 --- a/libraries/Zigbee/src/ep/ZigbeeLight.h +++ b/libraries/Zigbee/src/ep/ZigbeeLight.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -38,4 +38,4 @@ class ZigbeeLight : public ZigbeeEP { bool _current_state; }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp b/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp index 3a7acee040c..31a1f7e90e1 100644 --- a/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.cpp @@ -1,5 +1,5 @@ #include "ZigbeeOccupancySensor.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED esp_zb_cluster_list_t *zigbee_occupancy_sensor_clusters_create(zigbee_occupancy_sensor_cfg_t *occupancy_sensor) { esp_zb_basic_cluster_cfg_t *basic_cfg = occupancy_sensor ? &(occupancy_sensor->basic_cfg) : NULL; @@ -9,7 +9,6 @@ esp_zb_cluster_list_t *zigbee_occupancy_sensor_clusters_create(zigbee_occupancy_ esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_occupancy_sensing_cluster(cluster_list, esp_zb_occupancy_sensing_cluster_create(occupancy_meas_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); - esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); return cluster_list; } @@ -50,6 +49,7 @@ void ZigbeeOccupancySensor::report() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_OCCUPANCY_SENSING; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -57,4 +57,4 @@ void ZigbeeOccupancySensor::report() { log_v("Occupancy report sent"); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.h b/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.h index 40c5eddbbdd..fa622d5a707 100644 --- a/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.h +++ b/libraries/Zigbee/src/ep/ZigbeeOccupancySensor.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -51,4 +51,4 @@ class ZigbeeOccupancySensor : public ZigbeeEP { void report(); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp b/libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp index 24b4efb127e..21456a51511 100644 --- a/libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp +++ b/libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp @@ -1,5 +1,5 @@ #include "ZigbeePressureSensor.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED esp_zb_cluster_list_t *zigbee_pressure_sensor_clusters_create(zigbee_pressure_sensor_cfg_t *pressure_sensor) { esp_zb_basic_cluster_cfg_t *basic_cfg = pressure_sensor ? &(pressure_sensor->basic_cfg) : NULL; @@ -9,7 +9,6 @@ esp_zb_cluster_list_t *zigbee_pressure_sensor_clusters_create(zigbee_pressure_se esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_pressure_meas_cluster(cluster_list, esp_zb_pressure_meas_cluster_create(pressure_meas_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); - esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); return cluster_list; } @@ -34,7 +33,7 @@ void ZigbeePressureSensor::setMinMaxValue(int16_t min, int16_t max) { void ZigbeePressureSensor::setTolerance(uint16_t tolerance) { esp_zb_attribute_list_t *pressure_measure_cluster = esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); - esp_zb_temperature_meas_cluster_add_attr(pressure_measure_cluster, ESP_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID, (void *)&tolerance); + esp_zb_pressure_meas_cluster_add_attr(pressure_measure_cluster, ESP_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID, (void *)&tolerance); } void ZigbeePressureSensor::setReporting(uint16_t min_interval, uint16_t max_interval, uint16_t delta) { @@ -59,7 +58,7 @@ void ZigbeePressureSensor::setReporting(uint16_t min_interval, uint16_t max_inte void ZigbeePressureSensor::setPressure(int16_t pressure) { log_v("Updating pressure sensor value..."); - /* Update temperature sensor measured value */ + /* Update pressure sensor measured value */ log_d("Setting pressure to %d hPa", pressure); esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_set_attribute_val( @@ -76,6 +75,7 @@ void ZigbeePressureSensor::report() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -83,4 +83,4 @@ void ZigbeePressureSensor::report() { log_v("Pressure report sent"); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeePressureSensor.h b/libraries/Zigbee/src/ep/ZigbeePressureSensor.h index 2d72ef04c06..db14dd1c341 100644 --- a/libraries/Zigbee/src/ep/ZigbeePressureSensor.h +++ b/libraries/Zigbee/src/ep/ZigbeePressureSensor.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -57,4 +57,4 @@ class ZigbeePressureSensor : public ZigbeeEP { void report(); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeRangeExtender.cpp b/libraries/Zigbee/src/ep/ZigbeeRangeExtender.cpp new file mode 100644 index 00000000000..20db20d758a --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeRangeExtender.cpp @@ -0,0 +1,15 @@ +#include "ZigbeeRangeExtender.h" +#if CONFIG_ZB_ENABLED + +ZigbeeRangeExtender::ZigbeeRangeExtender(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_RANGE_EXTENDER_DEVICE_ID; + + _cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(_cluster_list, esp_zb_identify_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(_cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_RANGE_EXTENDER_DEVICE_ID, .app_device_version = 0}; +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeRangeExtender.h b/libraries/Zigbee/src/ep/ZigbeeRangeExtender.h new file mode 100644 index 00000000000..f9e4a963164 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeRangeExtender.h @@ -0,0 +1,18 @@ +/* Class of Zigbee Range Extender endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +class ZigbeeRangeExtender : public ZigbeeEP { +public: + ZigbeeRangeExtender(uint8_t endpoint); + ~ZigbeeRangeExtender() {} +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeSwitch.cpp b/libraries/Zigbee/src/ep/ZigbeeSwitch.cpp index f6b36d7f0d4..86c68ae1870 100644 --- a/libraries/Zigbee/src/ep/ZigbeeSwitch.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeSwitch.cpp @@ -1,5 +1,5 @@ #include "ZigbeeSwitch.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED // Initialize the static instance pointer ZigbeeSwitch *ZigbeeSwitch::_instance = nullptr; @@ -313,4 +313,4 @@ void ZigbeeSwitch::lightOnWithTimedOff(uint8_t on_off_control, uint16_t time_on, } } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeSwitch.h b/libraries/Zigbee/src/ep/ZigbeeSwitch.h index b638bfe823a..5c527bec6e3 100644 --- a/libraries/Zigbee/src/ep/ZigbeeSwitch.h +++ b/libraries/Zigbee/src/ep/ZigbeeSwitch.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -43,4 +43,4 @@ class ZigbeeSwitch : public ZigbeeEP { static void findCb(esp_zb_zdp_status_t zdo_status, uint16_t addr, uint8_t endpoint, void *user_ctx); }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp b/libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp index d419fb14adc..b3ff03f0a6b 100644 --- a/libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp @@ -1,5 +1,5 @@ #include "ZigbeeTempSensor.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED ZigbeeTempSensor::ZigbeeTempSensor(uint8_t endpoint) : ZigbeeEP(endpoint) { _device_id = ESP_ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID; @@ -48,7 +48,8 @@ void ZigbeeTempSensor::setReporting(uint16_t min_interval, uint16_t max_interval reporting_info.u.send_info.def_max_interval = max_interval; reporting_info.u.send_info.delta.u16 = (uint16_t)(delta * 100); // Convert delta to ZCL uint16_t reporting_info.dst.profile_id = ESP_ZB_AF_HA_PROFILE_ID; - reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC, esp_zb_lock_acquire(portMAX_DELAY); + reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; + esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_update_reporting_info(&reporting_info); esp_zb_lock_release(); } @@ -73,6 +74,7 @@ void ZigbeeTempSensor::reportTemperature() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -115,6 +117,7 @@ void ZigbeeTempSensor::reportHumidity() { report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT; report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; esp_zb_lock_acquire(portMAX_DELAY); esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); @@ -149,4 +152,4 @@ void ZigbeeTempSensor::report() { } } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeTempSensor.h b/libraries/Zigbee/src/ep/ZigbeeTempSensor.h index e610ff8d356..41da03d9db8 100644 --- a/libraries/Zigbee/src/ep/ZigbeeTempSensor.h +++ b/libraries/Zigbee/src/ep/ZigbeeTempSensor.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -48,4 +48,4 @@ class ZigbeeTempSensor : public ZigbeeEP { bool _humidity_sensor; }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeThermostat.cpp b/libraries/Zigbee/src/ep/ZigbeeThermostat.cpp index f8957f073a5..357bcaed1bc 100644 --- a/libraries/Zigbee/src/ep/ZigbeeThermostat.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeThermostat.cpp @@ -1,5 +1,5 @@ #include "ZigbeeThermostat.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED static float zb_s16_to_temperature(int16_t value) { return 1.0 * value / 100; @@ -202,4 +202,4 @@ void ZigbeeThermostat::setTemperatureReporting(uint16_t min_interval, uint16_t m esp_zb_lock_release(); } -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeThermostat.h b/libraries/Zigbee/src/ep/ZigbeeThermostat.h index 669ed9ab50a..7895115e1d1 100644 --- a/libraries/Zigbee/src/ep/ZigbeeThermostat.h +++ b/libraries/Zigbee/src/ep/ZigbeeThermostat.h @@ -4,7 +4,7 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" -#if SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#if CONFIG_ZB_ENABLED #include "ZigbeeEP.h" #include "ha/esp_zigbee_ha_standard.h" @@ -62,4 +62,4 @@ class ZigbeeThermostat : public ZigbeeEP { void zbAttributeRead(uint16_t cluster_id, const esp_zb_zcl_attribute_t *attribute) override; }; -#endif //SOC_IEEE802154_SUPPORTED && CONFIG_ZB_ENABLED +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.cpp b/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.cpp new file mode 100644 index 00000000000..9fc75297262 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.cpp @@ -0,0 +1,86 @@ +#include "ZigbeeVibrationSensor.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *zigbee_vibration_sensor_clusters_create(zigbee_vibration_sensor_cfg_t *vibration_sensor) { + esp_zb_basic_cluster_cfg_t *basic_cfg = vibration_sensor ? &(vibration_sensor->basic_cfg) : NULL; + esp_zb_identify_cluster_cfg_t *identify_cfg = vibration_sensor ? &(vibration_sensor->identify_cfg) : NULL; + esp_zb_ias_zone_cluster_cfg_t *ias_zone_cfg = vibration_sensor ? &(vibration_sensor->ias_zone_cfg) : NULL; + esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_ias_zone_cluster(cluster_list, esp_zb_ias_zone_cluster_create(ias_zone_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + return cluster_list; +} + +ZigbeeVibrationSensor::ZigbeeVibrationSensor(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_IAS_ZONE_ID; + _zone_status = 0; + _zone_id = 0xff; + _ias_cie_endpoint = 1; + + //Create custom vibration sensor configuration + zigbee_vibration_sensor_cfg_t vibration_sensor_cfg = ZIGBEE_DEFAULT_VIBRATION_SENSOR_CONFIG(); + _cluster_list = zigbee_vibration_sensor_clusters_create(&vibration_sensor_cfg); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_IAS_ZONE_ID, .app_device_version = 0}; +} + +void ZigbeeVibrationSensor::setIASClientEndpoint(uint8_t ep_number) { + _ias_cie_endpoint = ep_number; +} + +void ZigbeeVibrationSensor::setVibration(bool sensed) { + log_v("Setting Vibration sensor to %s", sensed ? "sensed" : "not sensed"); + uint8_t vibration = (uint8_t)sensed; + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &vibration, false + ); + esp_zb_lock_release(); + _zone_status = vibration; + report(); +} + +void ZigbeeVibrationSensor::report() { + /* Send IAS Zone status changed notification command */ + + esp_zb_zcl_ias_zone_status_change_notif_cmd_t status_change_notif_cmd; + status_change_notif_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT; + status_change_notif_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + status_change_notif_cmd.zcl_basic_cmd.dst_endpoint = _ias_cie_endpoint; //default is 1 + memcpy(status_change_notif_cmd.zcl_basic_cmd.dst_addr_u.addr_long, _ias_cie_addr, sizeof(esp_zb_ieee_addr_t)); + + status_change_notif_cmd.zone_status = _zone_status; + status_change_notif_cmd.extend_status = 0; + status_change_notif_cmd.zone_id = _zone_id; + status_change_notif_cmd.delay = 0; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_ias_zone_status_change_notif_cmd_req(&status_change_notif_cmd); + esp_zb_lock_release(); + log_v("IAS Zone status changed notification sent"); +} + +void ZigbeeVibrationSensor::zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) { + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE) { + log_v("IAS Zone Enroll Response: zone id(%d), status(%d)", message->zone_id, message->response_code); + if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) { + log_v("IAS Zone Enroll Response: success"); + esp_zb_lock_acquire(portMAX_DELAY); + memcpy( + _ias_cie_addr, + (*(esp_zb_ieee_addr_t *) + esp_zb_zcl_get_attribute(_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID) + ->data_p), + sizeof(esp_zb_ieee_addr_t) + ); + esp_zb_lock_release(); + _zone_id = message->zone_id; + } + + } else { + log_w("Received message ignored. Cluster ID: %d not supported for On/Off Light", message->info.cluster); + } +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.h b/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.h new file mode 100644 index 00000000000..1ee3740dcc3 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeVibrationSensor.h @@ -0,0 +1,64 @@ +/* Class of Zigbee contact switch (IAS Zone) endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +// clang-format off +#define ZIGBEE_DEFAULT_VIBRATION_SENSOR_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .ias_zone_cfg = \ + { \ + .zone_state = ESP_ZB_ZCL_IAS_ZONE_ZONESTATE_NOT_ENROLLED, \ + .zone_type = ESP_ZB_ZCL_IAS_ZONE_ZONETYPE_VIBRATION_MOVEMENT, \ + .zone_status = 0, \ + .ias_cie_addr = ESP_ZB_ZCL_ZONE_IAS_CIE_ADDR_DEFAULT, \ + .zone_id = 0xff, \ + .zone_ctx = {0, 0, 0, 0}, \ + }, \ + } +// clang-format on + +typedef struct zigbee_vibration_sensor_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; + esp_zb_identify_cluster_cfg_t identify_cfg; + esp_zb_ias_zone_cluster_cfg_t ias_zone_cfg; +} zigbee_vibration_sensor_cfg_t; + +class ZigbeeVibrationSensor : public ZigbeeEP { +public: + ZigbeeVibrationSensor(uint8_t endpoint); + ~ZigbeeVibrationSensor() {} + + // Set the IAS Client endpoint number (default is 1) + void setIASClientEndpoint(uint8_t ep_number); + + // Set the vibration sensor value (true = sensed, false = not sensed) + void setVibration(bool sensed); + + // Report the vibration sensor value, done automatically after setting the sensed value + void report(); + +private: + void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) override; + uint8_t _zone_status; + uint8_t _zone_id; + esp_zb_ieee_addr_t _ias_cie_addr; + uint8_t _ias_cie_endpoint; +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp b/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp new file mode 100644 index 00000000000..d93b02adbc3 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp @@ -0,0 +1,98 @@ +#include "ZigbeeWindSpeedSensor.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *zigbee_wind_speed_sensor_clusters_create(zigbee_wind_speed_sensor_cfg_t *wind_speed_sensor) { + esp_zb_basic_cluster_cfg_t *basic_cfg = wind_speed_sensor ? &(wind_speed_sensor->basic_cfg) : NULL; + esp_zb_identify_cluster_cfg_t *identify_cfg = wind_speed_sensor ? &(wind_speed_sensor->identify_cfg) : NULL; + esp_zb_wind_speed_measurement_cluster_cfg_t *wind_speed_cfg = wind_speed_sensor ? &(wind_speed_sensor->wind_speed_meas_cfg) : NULL; + esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(cluster_list, esp_zb_basic_cluster_create(basic_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(identify_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_wind_speed_measurement_cluster( + cluster_list, esp_zb_wind_speed_measurement_cluster_create(wind_speed_cfg), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE + ); + return cluster_list; +} + +// There is no device_id for wind speed sensor, we use a generic one +ZigbeeWindSpeedSensor::ZigbeeWindSpeedSensor(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID; + + zigbee_wind_speed_sensor_cfg_t windspeed_sensor_cfg = ZIGBEE_DEFAULT_WIND_SPEED_SENSOR_CONFIG(); + _cluster_list = zigbee_wind_speed_sensor_clusters_create(&windspeed_sensor_cfg); + + _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0}; +} + +static uint16_t zb_windspeed_to_u16(float windspeed) { + return (uint16_t)(windspeed * 100); +} + +void ZigbeeWindSpeedSensor::setMinMaxValue(float min, float max) { + uint16_t zb_min = zb_windspeed_to_u16(min); + uint16_t zb_max = zb_windspeed_to_u16(max); + esp_zb_attribute_list_t *windspeed_measure_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WIND_SPEED_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + // + esp_zb_cluster_update_attr(windspeed_measure_cluster, ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_MIN_MEASURED_VALUE_ID, (void *)&zb_min); + esp_zb_cluster_update_attr(windspeed_measure_cluster, ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_MAX_MEASURED_VALUE_ID, (void *)&zb_max); +} + +void ZigbeeWindSpeedSensor::setTolerance(float tolerance) { + // Convert tolerance to ZCL uint16_t + uint16_t zb_tolerance = zb_windspeed_to_u16(tolerance); + esp_zb_attribute_list_t *windspeed_measure_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WIND_SPEED_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_wind_speed_measurement_cluster_add_attr(windspeed_measure_cluster, ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_TOLERANCE_ID, (void *)&zb_tolerance); +} + +void ZigbeeWindSpeedSensor::setReporting(uint16_t min_interval, uint16_t max_interval, float delta) { + esp_zb_zcl_reporting_info_t reporting_info; + memset(&reporting_info, 0, sizeof(esp_zb_zcl_reporting_info_t)); + reporting_info.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV; + reporting_info.ep = _endpoint; + reporting_info.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_WIND_SPEED_MEASUREMENT; + reporting_info.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE; + reporting_info.attr_id = ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_MEASURED_VALUE_ID; + reporting_info.u.send_info.min_interval = min_interval; + reporting_info.u.send_info.max_interval = max_interval; + reporting_info.u.send_info.def_min_interval = min_interval; + reporting_info.u.send_info.def_max_interval = max_interval; + reporting_info.u.send_info.delta.u16 = (uint16_t)(delta * 100); // Convert delta to ZCL uint16_t + reporting_info.dst.profile_id = ESP_ZB_AF_HA_PROFILE_ID; + reporting_info.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_update_reporting_info(&reporting_info); + esp_zb_lock_release(); +} + +void ZigbeeWindSpeedSensor::setWindSpeed(float windspeed) { + uint16_t zb_windspeed = zb_windspeed_to_u16(windspeed); + log_v("Updating windspeed sensor value..."); + /* Update windspeed sensor measured value */ + log_d("Setting windspeed to %d", zb_windspeed); + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WIND_SPEED_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_MEASURED_VALUE_ID, + &zb_windspeed, false + ); + esp_zb_lock_release(); +} + +void ZigbeeWindSpeedSensor::reportWindSpeed() { + /* Send report attributes command */ + esp_zb_zcl_report_attr_cmd_t report_attr_cmd; + report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT; + report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_WIND_SPEED_MEASUREMENT_MEASURED_VALUE_ID; + report_attr_cmd.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_CLI; + report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_WIND_SPEED_MEASUREMENT; + report_attr_cmd.zcl_basic_cmd.src_endpoint = _endpoint; + report_attr_cmd.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC; + + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd); + esp_zb_lock_release(); + log_v("Wind speed measurement report sent"); +} + +#endif //CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.h b/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.h new file mode 100644 index 00000000000..e091d3ae548 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.h @@ -0,0 +1,56 @@ +/* Class of Zigbee WindSpeed sensor endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +#define ZIGBEE_DEFAULT_WIND_SPEED_SENSOR_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .wind_speed_meas_cfg = { \ + .measured_value = ESP_ZB_ZCL_WIND_SPEED_MEASUREMENT_MEASURED_VALUE_DEFAULT, \ + .min_measured_value = ESP_ZB_ZCL_WIND_SPEED_MEASUREMENT_MIN_MEASURED_VALUE_DEFAULT, \ + .max_measured_value = ESP_ZB_ZCL_WIND_SPEED_MEASUREMENT_MAX_MEASURED_VALUE_DEFAULT, \ + }, \ + } + +typedef struct zigbee_wind_speed_sensor_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; /*!< Basic cluster configuration, @ref esp_zb_basic_cluster_cfg_s */ + esp_zb_identify_cluster_cfg_t identify_cfg; /*!< Identify cluster configuration, @ref esp_zb_identify_cluster_cfg_s */ + esp_zb_wind_speed_measurement_cluster_cfg_t + wind_speed_meas_cfg; /*!< Wind speed measurement cluster configuration, @ref esp_zb_wind_speed_measurement_cluster_cfg_s */ +} zigbee_wind_speed_sensor_cfg_t; + +class ZigbeeWindSpeedSensor : public ZigbeeEP { +public: + ZigbeeWindSpeedSensor(uint8_t endpoint); + ~ZigbeeWindSpeedSensor() {} + + // Set the WindSpeed value in 0,01 m/s + void setWindSpeed(float value); + + // Set the min and max value for the WindSpeed sensor + void setMinMaxValue(float min, float max); + + // Set the tolerance value for the WindSpeed sensor + void setTolerance(float tolerance); + + // Set the reporting interval for WindSpeed measurement in seconds and delta + void setReporting(uint16_t min_interval, uint16_t max_interval, float delta); + void reportWindSpeed(); +}; + +#endif //CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeWindowCovering.cpp b/libraries/Zigbee/src/ep/ZigbeeWindowCovering.cpp new file mode 100644 index 00000000000..f6d6ec268ea --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeWindowCovering.cpp @@ -0,0 +1,308 @@ + +#include "ZigbeeWindowCovering.h" +#if CONFIG_ZB_ENABLED + +esp_zb_cluster_list_t *ZigbeeWindowCovering::zigbee_window_covering_clusters_create(zigbee_window_covering_cfg_t *window_covering_cfg) { + esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_basic_cluster_create(&window_covering_cfg->basic_cfg); + esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_identify_cluster_create(&window_covering_cfg->identify_cfg); + esp_zb_attribute_list_t *esp_zb_groups_cluster = esp_zb_groups_cluster_create(&window_covering_cfg->groups_cfg); + esp_zb_attribute_list_t *esp_zb_scenes_cluster = esp_zb_scenes_cluster_create(&window_covering_cfg->scenes_cfg); + esp_zb_attribute_list_t *esp_zb_window_covering_cluster = esp_zb_window_covering_cluster_create(&window_covering_cfg->window_covering_cfg); + + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID, &_current_lift_percentage + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID, &_current_tilt_percentage + ); + esp_zb_window_covering_cluster_add_attr(esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID, &_current_lift_position); + esp_zb_window_covering_cluster_add_attr(esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID, &_current_lift_position); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID, &_installed_open_limit_lift + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID, &_installed_open_limit_tilt + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID, &_installed_closed_limit_lift + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID, &_installed_closed_limit_tilt + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_PHYSICAL_CLOSED_LIMIT_LIFT_ID, &_physical_closed_limit_lift + ); + esp_zb_window_covering_cluster_add_attr( + esp_zb_window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_PHY_CLOSED_LIMIT_TILT_ID, &_physical_closed_limit_lift + ); + + // ------------------------------ Create cluster list ------------------------------ + esp_zb_cluster_list_t *esp_zb_cluster_list = esp_zb_zcl_cluster_list_create(); + esp_zb_cluster_list_add_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_identify_cluster(esp_zb_cluster_list, esp_zb_identify_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_groups_cluster(esp_zb_cluster_list, esp_zb_groups_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_scenes_cluster(esp_zb_cluster_list, esp_zb_scenes_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_list_add_window_covering_cluster(esp_zb_cluster_list, esp_zb_window_covering_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + + return esp_zb_cluster_list; +} + +ZigbeeWindowCovering::ZigbeeWindowCovering(uint8_t endpoint) : ZigbeeEP(endpoint) { + _device_id = ESP_ZB_HA_WINDOW_COVERING_DEVICE_ID; + + // set default values for window covering attributes + _current_lift_percentage = ESP_ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_DEFAULT_VALUE; + _current_tilt_percentage = ESP_ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_DEFAULT_VALUE; + _installed_open_limit_lift = ESP_ZB_ZCL_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_DEFAULT_VALUE; + _installed_closed_limit_lift = ESP_ZB_ZCL_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_DEFAULT_VALUE; + _installed_open_limit_tilt = ESP_ZB_ZCL_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_DEFAULT_VALUE; + _installed_closed_limit_tilt = ESP_ZB_ZCL_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_DEFAULT_VALUE; + _current_lift_position = ESP_ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_DEFAULT_VALUE; + _current_tilt_position = ESP_ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_DEFAULT_VALUE; + _physical_closed_limit_lift = ESP_ZB_ZCL_WINDOW_COVERING_PHYSICAL_CLOSED_LIMIT_LIFT_DEFAULT_VALUE; + _physical_closed_limit_tilt = ESP_ZB_ZCL_WINDOW_COVERING_PHY_CLOSED_LIMIT_TILT_DEFAULT_VALUE; + + // Create custom window covering configuration + zigbee_window_covering_cfg_t window_covering_cfg = ZIGBEE_DEFAULT_WINDOW_COVERING_CONFIG(); + _cluster_list = zigbee_window_covering_clusters_create(&window_covering_cfg); + + _ep_config = { + .endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_WINDOW_COVERING_DEVICE_ID, .app_device_version = 0 + }; +} + +// Configuration methods for window covering +void ZigbeeWindowCovering::setCoveringType(ZigbeeWindowCoveringType covering_type) { + esp_zb_attribute_list_t *window_covering_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_WINDOW_COVERING_TYPE_ID, (void *)&covering_type); +} + +void ZigbeeWindowCovering::setConfigStatus( + bool operational, bool online, bool commands_reversed, bool lift_closed_loop, bool tilt_closed_loop, bool lift_encoder_controlled, + bool tilt_encoder_controlled +) { + uint8_t config_status = (operational ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_OPERATIONAL : 0) | (online ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_ONLINE : 0) + | (commands_reversed ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_REVERSE_COMMANDS : 0) + | (lift_closed_loop ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_LIFT_CONTROL_IS_CLOSED_LOOP : 0) + | (tilt_closed_loop ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_TILT_CONTROL_IS_CLOSED_LOOP : 0) + | (lift_encoder_controlled ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_LIFT_ENCODER_CONTROLLED : 0) + | (tilt_encoder_controlled ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_TILT_ENCODER_CONTROLLED : 0); + + log_v("Updating window covering config status to %d", config_status); + + esp_zb_attribute_list_t *window_covering_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID, (void *)&config_status); +} + +void ZigbeeWindowCovering::setMode(bool motor_reversed, bool calibration_mode, bool maintenance_mode, bool leds_on) { + uint8_t mode = (motor_reversed ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_REVERSED_MOTOR_DIRECTION : 0) + | (calibration_mode ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_RUN_IN_CALIBRATION_MODE : 0) + | (maintenance_mode ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_MOTOR_IS_RUNNING_IN_MAINTENANCE_MODE : 0) + | (leds_on ? ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_LEDS_WILL_DISPLAY_FEEDBACK : 0); + + log_v("Updating window covering mode to %d", mode); + + esp_zb_attribute_list_t *window_covering_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID, (void *)&mode); +} + +void ZigbeeWindowCovering::setLimits( + uint16_t installed_open_limit_lift, uint16_t installed_closed_limit_lift, uint16_t installed_open_limit_tilt, uint16_t installed_closed_limit_tilt +) { + _installed_open_limit_lift = installed_open_limit_lift; + _installed_closed_limit_lift = installed_closed_limit_lift; + _physical_closed_limit_lift = installed_closed_limit_lift; + _installed_open_limit_tilt = installed_open_limit_tilt; + _installed_closed_limit_tilt = installed_closed_limit_tilt; + _physical_closed_limit_tilt = installed_closed_limit_tilt; + + esp_zb_attribute_list_t *window_covering_cluster = + esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID, (void *)&_installed_open_limit_lift); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID, (void *)&_installed_closed_limit_lift); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID, (void *)&_installed_open_limit_tilt); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID, (void *)&_installed_closed_limit_tilt); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_PHYSICAL_CLOSED_LIMIT_LIFT_ID, (void *)&_physical_closed_limit_lift); + esp_zb_cluster_update_attr(window_covering_cluster, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_PHY_CLOSED_LIMIT_TILT_ID, (void *)&_physical_closed_limit_tilt); +} + +// Callback for handling incoming messages and commands +void ZigbeeWindowCovering::zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) { + //check the data and call right method + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING) { + log_v("Received attribute id: 0x%x / data.type: 0x%x", message->attribute.id, message->attribute.data.type); + if (message->attribute.id == ESP_ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_8BITMAP) { + uint8_t mode = *(uint8_t *)message->attribute.data.value; + bool motor_reversed = mode & ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_REVERSED_MOTOR_DIRECTION; + bool calibration_mode = mode & ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_RUN_IN_CALIBRATION_MODE; + bool maintenance_mode = mode & ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_MOTOR_IS_RUNNING_IN_MAINTENANCE_MODE; + bool leds_on = mode & ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_LEDS_WILL_DISPLAY_FEEDBACK; + log_v( + "Updating window covering mode to motor reversed: %d, calibration mode: %d, maintenance mode: %d, leds on: %d", motor_reversed, calibration_mode, + maintenance_mode, leds_on + ); + setMode(motor_reversed, calibration_mode, maintenance_mode, leds_on); + //Update Configuration status with motor reversed status + uint8_t config_status; + config_status = (*(uint8_t *)esp_zb_zcl_get_attribute( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID + ) + ->data_p); + config_status = motor_reversed ? config_status | ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_REVERSE_COMMANDS + : config_status & ~ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_REVERSE_COMMANDS; + log_v("Updating window covering config status to %d", config_status); + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID, &config_status, + false + ); + esp_zb_lock_release(); + return; + } + } else { + log_w("Received message ignored. Cluster ID: %d not supported for Window Covering", message->info.cluster); + } +} + +void ZigbeeWindowCovering::zbWindowCoveringMovementCmd(const esp_zb_zcl_window_covering_movement_message_t *message) { + // check the data and call right method + if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING) { + if (message->command == ESP_ZB_ZCL_CMD_WINDOW_COVERING_UP_OPEN) { + open(); + return; + } else if (message->command == ESP_ZB_ZCL_CMD_WINDOW_COVERING_DOWN_CLOSE) { + close(); + return; + } else if (message->command == ESP_ZB_ZCL_CMD_WINDOW_COVERING_STOP) { + stop(); + return; + } else if (message->command == ESP_ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE) { + if (_current_lift_percentage != message->payload.percentage_lift_value) { + _current_lift_percentage = message->payload.percentage_lift_value; + goToLiftPercentage(_current_lift_percentage); + } + return; + } else if (message->command == ESP_ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE) { + if (_current_tilt_percentage != message->payload.percentage_tilt_value) { + _current_tilt_percentage = message->payload.percentage_tilt_value; + goToTiltPercentage(_current_tilt_percentage); + } + } else { + log_w("Received message ignored. Command: %d not supported for Window Covering", message->command); + } + } else { + log_w("Received message ignored. Cluster ID: %d not supported for Window Covering", message->info.cluster); + } +} + +void ZigbeeWindowCovering::open() { + if (_on_open) { + _on_open(); + } +} + +void ZigbeeWindowCovering::close() { + if (_on_close) { + _on_close(); + } +} + +void ZigbeeWindowCovering::goToLiftPercentage(uint8_t lift_percentage) { + if (_on_go_to_lift_percentage) { + _on_go_to_lift_percentage(lift_percentage); + } +} + +void ZigbeeWindowCovering::goToTiltPercentage(uint8_t tilt_percentage) { + if (_on_go_to_tilt_percentage) { + _on_go_to_tilt_percentage(tilt_percentage); + } +} + +void ZigbeeWindowCovering::stop() { + if (_on_stop) { + _on_stop(); + } +} + +// Methods to control window covering from user application +void ZigbeeWindowCovering::setLiftPosition(uint16_t lift_position) { + // Update both lift attributes + _current_lift_position = lift_position; + _current_lift_percentage = ((lift_position - _installed_open_limit_lift) * 100) / (_installed_closed_limit_lift - _installed_open_limit_lift); + + log_v("Updating window covering lift position to %d (%d%)", _current_lift_position, _current_lift_percentage); + // set lift state + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID, + &_current_lift_position, false + ); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID, + &_current_lift_percentage, false + ); + esp_zb_lock_release(); +} + +void ZigbeeWindowCovering::setLiftPercentage(uint8_t lift_percentage) { + // Update both lift attributes + _current_lift_percentage = lift_percentage; + _current_lift_position = _installed_open_limit_lift + ((_installed_closed_limit_lift - _installed_open_limit_lift) * lift_percentage) / 100; + + log_v("Updating window covering lift position to %d (%d%)", _current_lift_position, _current_lift_percentage); + // set lift state + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID, + &_current_lift_position, false + ); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID, + &_current_lift_percentage, false + ); + esp_zb_lock_release(); +} + +void ZigbeeWindowCovering::setTiltPosition(uint16_t tilt_position) { + // Update both tilt attributes + _current_tilt_position = tilt_position; + _current_tilt_percentage = ((tilt_position - _installed_open_limit_tilt) * 100) / (_installed_closed_limit_tilt - _installed_open_limit_tilt); + + log_v("Updating window covering tilt position to %d (%d%)", _current_tilt_position, _current_tilt_percentage); + // set lift state + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID, + &_current_tilt_position, false + ); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID, + &_current_tilt_percentage, false + ); + esp_zb_lock_release(); +} + +void ZigbeeWindowCovering::setTiltPercentage(uint8_t tilt_percentage) { + // Update both tilt attributes + _current_tilt_percentage = tilt_percentage; + _current_tilt_position = _installed_open_limit_lift + ((_installed_closed_limit_tilt - _installed_open_limit_tilt) * tilt_percentage) / 100; + + log_v("Updating window covering tilt position to %d (%d%)", _current_tilt_position, _current_tilt_percentage); + // set lift state + esp_zb_lock_acquire(portMAX_DELAY); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID, + &_current_tilt_position, false + ); + esp_zb_zcl_set_attribute_val( + _endpoint, ESP_ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID, + &_current_tilt_percentage, false + ); + esp_zb_lock_release(); +} + +#endif // CONFIG_ZB_ENABLED diff --git a/libraries/Zigbee/src/ep/ZigbeeWindowCovering.h b/libraries/Zigbee/src/ep/ZigbeeWindowCovering.h new file mode 100644 index 00000000000..f3a368370c4 --- /dev/null +++ b/libraries/Zigbee/src/ep/ZigbeeWindowCovering.h @@ -0,0 +1,147 @@ +/* Class of Zigbee Window Covering endpoint inherited from common EP class */ + +#pragma once + +#include "soc/soc_caps.h" +#include "sdkconfig.h" +#if CONFIG_ZB_ENABLED + +#include "ZigbeeEP.h" +#include "ha/esp_zigbee_ha_standard.h" + +// Window covering types supported by Zigbee Window Covering cluster +enum ZigbeeWindowCoveringType { + ROLLERSHADE = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE, // LIFT support + ROLLERSHADE_2_MOTOR = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_2_MOTOR, // LIFT support + ROLLERSHADE_EXTERIOR = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_EXTERIOR, // LIFT support + ROLLERSHADE_EXTERIOR_2_MOTOR = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_EXTERIOR_2_MOTOR, // LIFT support + DRAPERY = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_DRAPERY, // LIFT support + AWNING = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_AWNING, // LIFT support + SHUTTER = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_SHUTTER, // TILT support + BLIND_TILT_ONLY = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_TILT_BLIND_TILT_ONLY, // TILT support + BLIND_LIFT_AND_TILT = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_TILT_BLIND_LIFT_AND_TILT, // LIFT and TILT support + PROJECTOR_SCREEN = ESP_ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_PROJECTOR_SCREEN, // LIFT support +}; + +// clang-format off +#define ZIGBEE_DEFAULT_WINDOW_COVERING_CONFIG() \ + { \ + .basic_cfg = \ + { \ + .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \ + .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \ + }, \ + .identify_cfg = \ + { \ + .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \ + }, \ + .groups_cfg = \ + { \ + .groups_name_support_id = ESP_ZB_ZCL_GROUPS_NAME_SUPPORT_DEFAULT_VALUE, \ + }, \ + .scenes_cfg = \ + { \ + .scenes_count = ESP_ZB_ZCL_SCENES_SCENE_COUNT_DEFAULT_VALUE, \ + .current_scene = ESP_ZB_ZCL_SCENES_CURRENT_SCENE_DEFAULT_VALUE, \ + .current_group = ESP_ZB_ZCL_SCENES_CURRENT_GROUP_DEFAULT_VALUE, \ + .scene_valid = ESP_ZB_ZCL_SCENES_SCENE_VALID_DEFAULT_VALUE, \ + .name_support = ESP_ZB_ZCL_SCENES_NAME_SUPPORT_DEFAULT_VALUE, \ + }, \ + .window_covering_cfg = \ + { \ + .covering_type = ESP_ZB_ZCL_WINDOW_COVERING_WINDOW_COVERING_TYPE_DEFAULT_VALUE, \ + .covering_status = ESP_ZB_ZCL_WINDOW_COVERING_CONFIG_STATUS_DEFAULT_VALUE, \ + .covering_mode = ESP_ZB_ZCL_WINDOW_COVERING_MODE_DEFAULT_VALUE, \ + }, \ + } +// clang-format on + +typedef struct zigbee_window_covering_cfg_s { + esp_zb_basic_cluster_cfg_t basic_cfg; + esp_zb_identify_cluster_cfg_t identify_cfg; + esp_zb_groups_cluster_cfg_t groups_cfg; + esp_zb_scenes_cluster_cfg_t scenes_cfg; + esp_zb_window_covering_cluster_cfg_t window_covering_cfg; +} zigbee_window_covering_cfg_t; + +class ZigbeeWindowCovering : public ZigbeeEP { +public: + ZigbeeWindowCovering(uint8_t endpoint); + ~ZigbeeWindowCovering() {} + + // Set the callback functions for the window covering commands + void onOpen(void (*callback)()) { + _on_open = callback; + } + void onClose(void (*callback)()) { + _on_close = callback; + } + void onGoToLiftPercentage(void (*callback)(uint8_t)) { + _on_go_to_lift_percentage = callback; + } + void onGoToTiltPercentage(void (*callback)(uint8_t)) { + _on_go_to_tilt_percentage = callback; + } + void onStop(void (*callback)()) { + _on_stop = callback; + } + + // Set the window covering position in centimeters or percentage (0-100) + void setLiftPosition(uint16_t lift_position); + void setLiftPercentage(uint8_t lift_percentage); + void setTiltPosition(uint16_t tilt_position); + void setTiltPercentage(uint8_t tilt_percentage); + + // Set the window covering type (see ZigbeeWindowCoveringType) + void setCoveringType(ZigbeeWindowCoveringType covering_type); + + // Set window covering config/status, for more info see esp_zb_zcl_window_covering_config_status_t + void setConfigStatus( + bool operational, bool online, bool commands_reversed, bool lift_closed_loop, bool tilt_closed_loop, bool lift_encoder_controlled, + bool tilt_encoder_controlled + ); + + // Set configuration mode of window covering, for more info see esp_zb_zcl_window_covering_mode_t + void setMode(bool motor_reversed, bool calibration_mode, bool maintenance_mode, bool leds_on); + + // Set limits of motion, for more info see esp_zb_zcl_window_covering_info_attr_t + void setLimits( + uint16_t installed_open_limit_lift, uint16_t installed_closed_limit_lift, uint16_t installed_open_limit_tilt, uint16_t installed_closed_limit_tilt + ); + +private: + void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) override; + void zbWindowCoveringMovementCmd(const esp_zb_zcl_window_covering_movement_message_t *message) override; + + // Create window covering cluster list + esp_zb_cluster_list_t *zigbee_window_covering_clusters_create(zigbee_window_covering_cfg_t *window_covering_cfg); + + void open(); + void close(); + void goToLiftPercentage(uint8_t); + void goToTiltPercentage(uint8_t); + void stop(); + + // callback function to be called on lift percentage change (lift percentage) + void (*_on_open)(); + void (*_on_close)(); + void (*_on_go_to_lift_percentage)(uint8_t); + void (*_on_go_to_tilt_percentage)(uint8_t); + void (*_on_stop)(); + + // Widows covering lift attributes + uint8_t _current_lift_percentage; + uint16_t _current_lift_position; + uint16_t _installed_open_limit_lift; + uint16_t _installed_closed_limit_lift; + uint16_t _physical_closed_limit_lift; + + // Windows covering tilt attributes + uint8_t _current_tilt_percentage; + uint16_t _current_tilt_position; + uint16_t _installed_open_limit_tilt; + uint16_t _installed_closed_limit_tilt; + uint16_t _physical_closed_limit_tilt; +}; + +#endif // CONFIG_ZB_ENABLED diff --git a/package.json b/package.json index 742b1154d63..9c918733209 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "framework-arduinoespressif32", - "version": "3.1.1", + "version": "3.2.0", "description": "Arduino Wiring-based Framework for the Espressif ESP32, ESP32-P4, ESP32-S and ESP32-C series of SoCs", "keywords": [ "framework", diff --git a/package/package_esp32_index.template.json b/package/package_esp32_index.template.json index ad031a4d155..249ab43acc6 100644 --- a/package/package_esp32_index.template.json +++ b/package/package_esp32_index.template.json @@ -42,12 +42,12 @@ { "packager": "esp32", "name": "esp32-arduino-libs", - "version": "idf-release_v5.3-cfea4f7c-v1" + "version": "idf-release_v5.4-d4aa25a3-v1" }, { "packager": "esp32", "name": "xtensa-esp-elf-gcc", - "version": "esp-13.2.0_20240530" + "version": "esp-14.2.0_20241119" }, { "packager": "esp32", @@ -57,7 +57,7 @@ { "packager": "esp32", "name": "riscv32-esp-elf-gcc", - "version": "esp-13.2.0_20240530" + "version": "esp-14.2.0_20241119" }, { "packager": "esp32", @@ -95,125 +95,125 @@ "tools": [ { "name": "esp32-arduino-libs", - "version": "idf-release_v5.3-cfea4f7c-v1", + "version": "idf-release_v5.4-d4aa25a3-v1", "systems": [ { "host": "i686-mingw32", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "x86_64-mingw32", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "arm64-apple-darwin", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "x86_64-apple-darwin", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "x86_64-pc-linux-gnu", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "i686-pc-linux-gnu", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "aarch64-linux-gnu", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" }, { "host": "arm-linux-gnueabihf", - "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.3/esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "archiveFileName": "esp32-arduino-libs-idf-release_v5.3-cfea4f7c-v1.zip", - "checksum": "SHA-256:1099291229a9be453c771c5867b8487a0266db9246b672417337b8f511d7f820", - "size": "341118284" + "url": "https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.4/esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "archiveFileName": "esp32-arduino-libs-idf-release_v5.4-d4aa25a3-v1.zip", + "checksum": "SHA-256:81101d580ebafb78f71bd494f4f5162fd829279d18634282c0f8f95c9e928335", + "size": "350941396" } ] }, { "name": "xtensa-esp-elf-gcc", - "version": "esp-13.2.0_20240530", + "version": "esp-14.2.0_20241119", "systems": [ { "host": "x86_64-pc-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-x86_64-linux-gnu.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-x86_64-linux-gnu.tar.gz", - "checksum": "SHA-256:bce77e8480701d5a90545369d1b5848f6048eb39c0022d2446d1e33a8e127490", - "size": "208911713" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.gz", + "checksum": "SHA-256:b1859df334a85541ae746e1b86439f59180d87f8cf1cc04c2e770fadf9f006e9", + "size": "323678089" }, { "host": "aarch64-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-aarch64-linux-gnu.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-aarch64-linux-gnu.tar.gz", - "checksum": "SHA-256:7c9e3c1adc733d042ed87b92daa1d6396e1b441c1755f1fa14cb88855719ba88", - "size": "202519931" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.gz", + "checksum": "SHA-256:7ff023033a5c00e55b9fc0a0b26d18fb0e476c24e24c5b0459bcb2e05a3729f1", + "size": "320064691" }, { "host": "arm-linux-gnueabihf", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-arm-linux-gnueabi.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-arm-linux-gnueabi.tar.gz", - "checksum": "SHA-256:d6955e8ea6af91574bf9213b92f32ca09eb8640103446b7fa19a63cfeeec5421", - "size": "202206516" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.gz", + "checksum": "SHA-256:bb11dbf3ed25d4e0cc9e938749519e8236cfa2609e85742d311f1d869111805a", + "size": "319454139" }, { "host": "i686-pc-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-i586-linux-gnu.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-i586-linux-gnu.tar.gz", - "checksum": "SHA-256:3666ee74ecb693ee6488f11469802630a7b0d32608184045a4f35cb413f59e3d", - "size": "213304863" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.gz", + "checksum": "SHA-256:5ac611dca62ec791d413d1f417d566c444b006d2a4f97bd749b15f782d87249b", + "size": "328335914" }, { "host": "x86_64-apple-darwin", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-x86_64-apple-darwin.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-x86_64-apple-darwin.tar.gz", - "checksum": "SHA-256:948cf57b6eecc898b5f70e06ad08ba88c08b627be570ec631dfcd72f6295194a", - "size": "221357024" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-apple-darwin_signed.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-x86_64-apple-darwin_signed.tar.gz", + "checksum": "SHA-256:15b3e60362028eaeff9156dc82dac3f1436b4aeef3920b28d7650974d8c34751", + "size": "336215844" }, { "host": "arm64-apple-darwin", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-aarch64-apple-darwin.tar.gz", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-aarch64-apple-darwin.tar.gz", - "checksum": "SHA-256:6f03fdf0cc14a7f3900ee59977f62e8626d8b7c208506e52f1fd883ac223427a", - "size": "199689745" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-aarch64-apple-darwin_signed.tar.gz", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-aarch64-apple-darwin_signed.tar.gz", + "checksum": "SHA-256:45c475518735133789bacccad31f872318b7ecc0b31cc9b7924aad880034f0bf", + "size": "318797396" }, { "host": "i686-mingw32", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-i686-w64-mingw32_hotfix.zip", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-i686-w64-mingw32_hotfix.zip", - "checksum": "SHA-256:d6b227c50e3c8e21d62502b3140e5ab74a4cb502c2b4169c36238b9858a8fb88", - "size": "266042967" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip", + "checksum": "SHA-256:b30e450e0af279783c54a9ae77c3b367dd556b78eda930a92ec7b784a74c28c8", + "size": "382457717" }, { "host": "x86_64-mingw32", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/xtensa-esp-elf-13.2.0_20240530-x86_64-w64-mingw32_hotfix.zip", - "archiveFileName": "xtensa-esp-elf-13.2.0_20240530-x86_64-w64-mingw32_hotfix.zip", - "checksum": "SHA-256:155ee97b531236e6a7c763395c68ca793e55e74d2cb4d38a23057a153e01e7d0", - "size": "269831985" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/xtensa-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip", + "archiveFileName": "xtensa-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip", + "checksum": "SHA-256:62ae704777d73c30689efff6e81178632a1ca44d1a2d60f4621eb997e040e028", + "size": "386316009" } ] }, @@ -281,63 +281,63 @@ }, { "name": "riscv32-esp-elf-gcc", - "version": "esp-13.2.0_20240530", + "version": "esp-14.2.0_20241119", "systems": [ { "host": "x86_64-pc-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-x86_64-linux-gnu.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-x86_64-linux-gnu.tar.gz", - "checksum": "SHA-256:e7fbfffbb19dcd3764a9848a141bf44e19ad0b48e0bd1515912345c26fe52fba", - "size": "294346758" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-x86_64-linux-gnu.tar.gz", + "checksum": "SHA-256:a16942465d33c7f0334c16e83bc6feb62e06eeb79cf19099293480bb8d48c0cd", + "size": "593721156" }, { "host": "aarch64-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-aarch64-linux-gnu.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-aarch64-linux-gnu.tar.gz", - "checksum": "SHA-256:a178a895b807ed2e87d5d62153c36a6aae048581f527c0eb152f0a02b8de9571", - "size": "288374597" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-aarch64-linux-gnu.tar.gz", + "checksum": "SHA-256:22486233d0e0fd58a54ae453b701f195f1432fc6f2e17085b9d6c8d5d9acefb7", + "size": "587879927" }, { "host": "arm-linux-gnueabihf", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-arm-linux-gnueabi.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-arm-linux-gnueabi.tar.gz", - "checksum": "SHA-256:4a2f176d0f5bc8a70645975e2a08ea94145fb69b7225c5cdcbd6024a4836aaf5", - "size": "287737495" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-arm-linux-gnueabi.tar.gz", + "checksum": "SHA-256:27a72d5d96cdb56dae2a1da5dfde1717c18a8c1f9a1454c8e34a8bd34abe662d", + "size": "586531522" }, { "host": "i686-pc-linux-gnu", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-i586-linux-gnu.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-i586-linux-gnu.tar.gz", - "checksum": "SHA-256:7a6f02f1b2effafb18600bbf602818f6923fd320f000fb8659f34acbfda8812f", - "size": "299138540" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-i586-linux-gnu.tar.gz", + "checksum": "SHA-256:b7bd6e4cd53a4c55831d48e96a3d500bfffb091bec84a30bc8c3ad687e3eb3a2", + "size": "597070471" }, { "host": "x86_64-apple-darwin", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-x86_64-apple-darwin.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-x86_64-apple-darwin.tar.gz", - "checksum": "SHA-256:a193b4f025d0d836b0a9d9cbe760af1c53e53af66fc332fe98952bc4c456dd9a", - "size": "305025700" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-apple-darwin_signed.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-x86_64-apple-darwin_signed.tar.gz", + "checksum": "SHA-256:5f8b571e1aedbe9f856f3bdeca6600cd5510ccff1ca102c4f001421eda560585", + "size": "602343061" }, { "host": "arm64-apple-darwin", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-aarch64-apple-darwin.tar.gz", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-aarch64-apple-darwin.tar.gz", - "checksum": "SHA-256:7082dd2e2123dea5609a24092d19ac6612ae7e219df1d298de6b2f64cb4af0df", - "size": "285458443" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-aarch64-apple-darwin_signed.tar.gz", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-aarch64-apple-darwin_signed.tar.gz", + "checksum": "SHA-256:a7276042a7eb2d33c2dff7167539e445c32c07d43a2c6827e86d035642503e0b", + "size": "578521565" }, { "host": "i686-mingw32", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-i686-w64-mingw32.zip", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-i686-w64-mingw32.zip", - "checksum": "SHA-256:590bfb10576702639825581cc00c445da6e577012840a787137417e80d15f46d", - "size": "366573064" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-i686-w64-mingw32.zip", + "checksum": "SHA-256:54193a97bd75205678ead8d11f00b351cfa3c2a6e5ab5d966341358b9f9422d7", + "size": "672055172" }, { "host": "x86_64-mingw32", - "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-13.2.0_20240530/riscv32-esp-elf-13.2.0_20240530-x86_64-w64-mingw32.zip", - "archiveFileName": "riscv32-esp-elf-13.2.0_20240530-x86_64-w64-mingw32.zip", - "checksum": "SHA-256:413eb9f6adf8fdaf25544d014c850fc09eb38bb93a2fc5ebd107ab1b0de1bb3a", - "size": "369820297" + "url": "https://github.com/espressif/crosstool-NG/releases/download/esp-14.2.0_20241119/riscv32-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip", + "archiveFileName": "riscv32-esp-elf-14.2.0_20241119-x86_64-w64-mingw32.zip", + "checksum": "SHA-256:24c8407fa467448d394e0639436a5ede31caf1838e35e8435e19df58ebed438c", + "size": "677812937" } ] }, diff --git a/platform.txt b/platform.txt index cc9608a4f9d..65be05b3bf4 100644 --- a/platform.txt +++ b/platform.txt @@ -1,5 +1,5 @@ name=ESP32 Arduino -version=3.1.1 +version=3.2.0 tools.esp32-arduino-libs.path={runtime.platform.path}/tools/esp32-arduino-libs tools.esp32-arduino-libs.path.windows={runtime.platform.path}\tools\esp32-arduino-libs diff --git a/tests/requirements.txt b/tests/requirements.txt index cef0bf17881..b2bae3b86d0 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,8 @@ -cryptography==43.0.1 +cryptography==44.0.1 --only-binary cryptography pytest-cov==5.0.0 pytest-embedded-serial-esp==1.12.0 pytest-embedded-arduino==1.12.0 pytest-embedded-wokwi==1.12.0 pytest-embedded-qemu==1.12.0 +esptool==4.8.1 diff --git a/tests/validation/democfg/ci.json b/tests/validation/democfg/ci.json index e4f275a4bca..cf5c796644e 100644 --- a/tests/validation/democfg/ci.json +++ b/tests/validation/democfg/ci.json @@ -14,17 +14,18 @@ "platforms": { "hardware": true, "qemu": false, - "wokwi": true + "wokwi": false }, "requires": [ "CONFIG_SOC_UART_SUPPORTED=y" ], "targets": { "esp32": true, - "esp32c3": true, + "esp32c3": false, "esp32c6": true, "esp32h2": false, "esp32s2": true, - "esp32s3": true + "esp32s3": true, + "esp32p4": false } } diff --git a/tests/validation/gpio/ci.json b/tests/validation/gpio/ci.json index f03ec83b39d..7bc6a6ed163 100644 --- a/tests/validation/gpio/ci.json +++ b/tests/validation/gpio/ci.json @@ -1,7 +1,6 @@ { "platforms": { "hardware": false, - "qemu": false, - "wokwi": false + "qemu": false } } diff --git a/tests/validation/gpio/diagram.esp32p4.json b/tests/validation/gpio/diagram.esp32p4.json new file mode 100644 index 00000000000..ffb0cde2775 --- /dev/null +++ b/tests/validation/gpio/diagram.esp32p4.json @@ -0,0 +1,28 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-p4-function-ev", + "id": "esp32", + "top": -66.32, + "left": -277.63, + "attrs": {} + }, + { + "type": "wokwi-pushbutton", + "id": "btn1", + "top": -128.2, + "left": -19.2, + "attrs": { "color": "green", "bounce": "1" } + } + ], + "connections": [ + [ "esp32:38", "$serialMonitor:TX", "", [] ], + [ "esp32:37", "$serialMonitor:RX", "", [] ], + [ "btn1:2.r", "esp32:GND.3", "black", [ "h19.4", "v29" ] ], + [ "esp32:0", "btn1:1.l", "blue", [ "h-48", "v-67.2" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/gpio/scenario.yaml b/tests/validation/gpio/scenario.yaml index a915b546b49..957f58b2176 100644 --- a/tests/validation/gpio/scenario.yaml +++ b/tests/validation/gpio/scenario.yaml @@ -6,31 +6,31 @@ steps: - wait-serial: "Button test" # Need for 1s delay for scenario to run properly - - delay: 1000ms + - delay: 5000ms # Press once - set-control: part-id: btn1 control: pressed value: 1 - - delay: 200ms + - delay: 2000ms - set-control: part-id: btn1 control: pressed value: 0 - - delay: 300ms + - delay: 3000ms # Press 2nd time - set-control: part-id: btn1 control: pressed value: 1 - - delay: 200ms + - delay: 2000ms - set-control: part-id: btn1 control: pressed value: 0 - - delay: 300ms + - delay: 3000ms # Press for the 3rd time - set-control: diff --git a/tests/validation/i2c_master/ci.json b/tests/validation/i2c_master/ci.json new file mode 100644 index 00000000000..2b8792cd131 --- /dev/null +++ b/tests/validation/i2c_master/ci.json @@ -0,0 +1,9 @@ +{ + "platforms": { + "hardware": false, + "qemu": false + }, + "requires": [ + "CONFIG_SOC_I2C_SUPPORTED=y" + ] +} diff --git a/tests/validation/i2c_master/diagram.esp32.json b/tests/validation/i2c_master/diagram.esp32.json new file mode 100644 index 00000000000..28e5d2e9c23 --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-devkit-c-v4", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "esp32:22", "rtc1:SCL", "green", [ "h38.4", "v-9.6" ] ], + [ "esp32:21", "rtc1:SDA", "blue", [ "h48", "v-28.8", "h19.2" ] ], + [ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ], + [ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32c3.json b/tests/validation/i2c_master/diagram.esp32c3.json new file mode 100644 index 00000000000..a7471ec3ca1 --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32c3.json @@ -0,0 +1,25 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-c3-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ], + [ "esp32:5V.1", "rtc1:5V", "red", [ "h-18.22", "v-144.3", "h153.6", "v48" ] ], + [ "esp32:GND.10", "rtc1:GND", "black", [ "h56.16", "v9.3" ] ], + [ "esp32:8", "rtc1:SDA", "green", [ "h17.76", "v-19.5" ] ], + [ "esp32:9", "rtc1:SCL", "blue", [ "h0" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32c6.json b/tests/validation/i2c_master/diagram.esp32c6.json new file mode 100644 index 00000000000..9c759682ae5 --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32c6.json @@ -0,0 +1,26 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-c6-devkitc-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ], + [ "esp32:5V.1", "rtc1:5V", "red", [ "h-18.22", "v-144.3", "h153.6", "v48" ] ], + [ "esp32:GND.10", "rtc1:GND", "black", [ "h56.16", "v9.3" ] ], + [ "esp32:23", "rtc1:SDA", "green", [ "h17.38", "v-23.51" ] ], + [ "esp32:GND.4", "rtc1:GND", "black", [ "h55.78", "v-4.31" ] ], + [ "esp32:22", "rtc1:SCL", "blue", [ "h26.98", "v-23.51" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32h2.json b/tests/validation/i2c_master/diagram.esp32h2.json new file mode 100644 index 00000000000..d2a2acfecd7 --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32h2.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-h2-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "esp32:GND.6", "rtc1:GND", "black", [ "h0" ] ], + [ "esp32:5V", "rtc1:5V", "red", [ "h-29.14", "v-160.97", "h172.8", "v48" ] ], + [ "esp32:12", "rtc1:SDA", "green", [ "h36.58", "v-36.17" ] ], + [ "esp32:22", "rtc1:SCL", "blue", [ "v-7.37", "h46.18", "v-38.4" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32p4.json b/tests/validation/i2c_master/diagram.esp32p4.json new file mode 100644 index 00000000000..ab250c2aafd --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32p4.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-p4-function-ev", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -197.4, "left": 57.7, "attrs": {} } + ], + "connections": [ + [ "esp32:38", "$serialMonitor:TX", "", [] ], + [ "esp32:37", "$serialMonitor:RX", "", [] ], + [ "esp32:5V.1", "rtc1:5V", "red", [ "v0" ] ], + [ "esp32:GND.1", "rtc1:GND", "black", [ "v-133.52", "h5.53" ] ], + [ "esp32:7", "rtc1:SDA", "green", [ "v0" ] ], + [ "esp32:8", "rtc1:SCL", "blue", [ "h15.13", "v-114.12" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32s2.json b/tests/validation/i2c_master/diagram.esp32s2.json new file mode 100644 index 00000000000..c34a176bd7e --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32s2.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s2-devkitm-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ], + [ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ], + [ "esp32:8", "rtc1:SDA", "green", [ "h-19.47", "v-119.51", "h144", "v57.6" ] ], + [ "esp32:9", "rtc1:SCL", "blue", [ "h-29.07", "v-138.71", "h144", "v76.8" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/diagram.esp32s3.json b/tests/validation/i2c_master/diagram.esp32s3.json new file mode 100644 index 00000000000..6d168fb42e6 --- /dev/null +++ b/tests/validation/i2c_master/diagram.esp32s3.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s3-devkitc-1", + "id": "esp32", + "top": -57.6, + "left": -177.56, + "attrs": {} + }, + { "type": "wokwi-ds1307", "id": "rtc1", "top": -43.8, "left": -19.1, "attrs": {} } + ], + "connections": [ + [ "esp32:RX", "$serialMonitor:TX", "", [] ], + [ "esp32:TX", "$serialMonitor:RX", "", [] ], + [ "esp32:GND.2", "rtc1:GND", "black", [ "v0" ] ], + [ "rtc1:5V", "esp32:5V", "red", [ "h-28.8", "v-67.6", "h-172.8", "v230.4" ] ], + [ "esp32:8", "rtc1:SDA", "green", [ "h-19.47", "v-119.51", "h144", "v32.93", "h38.35" ] ], + [ "esp32:9", "rtc1:SCL", "blue", [ "h-29.07", "v-138.71", "h144", "v32.93", "h47.95" ] ] + ], + "dependencies": {} +} diff --git a/tests/validation/i2c_master/i2c_master.ino b/tests/validation/i2c_master/i2c_master.ino new file mode 100644 index 00000000000..41e7d2ae5f9 --- /dev/null +++ b/tests/validation/i2c_master/i2c_master.ino @@ -0,0 +1,319 @@ +/* + I2C Master Test for +*/ + +#include +#include +#include +#include +#include +#include + +#include "sdkconfig.h" + +/* DS1307 functions */ + +const uint8_t DS1307_ADDR = 0x68; +const uint8_t start_sec = 1; +const uint8_t start_min = 2; +const uint8_t start_hour = 3; +const uint8_t start_day = 4; +const uint8_t start_month = 5; +const uint16_t start_year = 2020; + +static uint8_t read_sec = 0; +static uint8_t read_min = 0; +static uint8_t read_hour = 0; +static uint8_t read_day = 0; +static uint8_t read_month = 0; +static uint16_t read_year = 0; +static int peek_data = -1; + +const char *ssid = "Wokwi-GUEST"; +const char *password = ""; + +const auto BCD2DEC = [](uint8_t num) -> uint8_t { + return ((num / 16 * 10) + (num % 16)); +}; + +const auto DEC2BCD = [](uint8_t num) -> uint8_t { + return ((num / 10 * 16) + (num % 10)); +}; + +void reset_read_values() { + read_sec = 0; + read_min = 0; + read_hour = 0; + read_day = 0; + read_month = 0; + read_year = 0; +} + +void ds1307_start(void) { + uint8_t sec; + + //Get seconds + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.endTransmission(); + Wire.requestFrom(DS1307_ADDR, 1); + sec = Wire.read() & 0x7F; //Seconds without halt bit + + //Set seconds and start clock + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.write(sec); + Wire.endTransmission(); +} + +void ds1307_stop(void) { + uint8_t sec; + + //Get seconds + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.endTransmission(); + Wire.requestFrom(DS1307_ADDR, 1); + sec = Wire.read() | 0x80; //Seconds with halt bit + + //Set seconds and halt clock + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.write(sec); + Wire.endTransmission(); +} + +void ds1307_get_time(uint8_t *sec, uint8_t *min, uint8_t *hour, uint8_t *day, uint8_t *month, uint16_t *year) { + //Get time + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.endTransmission(); + Wire.requestFrom(DS1307_ADDR, 7); + + TEST_ASSERT_EQUAL(7, Wire.available()); + + if (peek_data == -1 && Wire.peek() != -1) { + peek_data = Wire.peek(); + } + + *sec = BCD2DEC(Wire.read() & 0x7F); //Seconds without halt bit + *min = BCD2DEC(Wire.read()); + *hour = BCD2DEC(Wire.read() & 0x3F); + Wire.read(); //Ignore day of week + *day = BCD2DEC(Wire.read()); + *month = BCD2DEC(Wire.read()); + *year = BCD2DEC(Wire.read()) + 2000; +} + +void ds1307_set_time(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, uint16_t year) { + Wire.beginTransmission(DS1307_ADDR); + Wire.write(0x00); + Wire.write(DEC2BCD(sec)); + Wire.write(DEC2BCD(min)); + Wire.write(DEC2BCD(hour)); + Wire.write(DEC2BCD(0)); //Ignore day of week + Wire.write(DEC2BCD(day)); + Wire.write(DEC2BCD(month)); + Wire.write(DEC2BCD(year - 2000)); + Wire.endTransmission(); +} + +/* Unity functions */ + +// This function is automatically called by unity before each test is run +void setUp(void) { + reset_read_values(); + Wire.begin(); +} + +// This function is automatically called by unity after each test is run +void tearDown(void) { + //Reset time + ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year); + + Wire.end(); +} + +void rtc_set_time() { + //Set time + ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year); + + //Get time + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_EQUAL(start_sec, read_sec); + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); +} + +void rtc_run_clock() { + uint8_t old_sec = 0; + + //Run clock for 5 seconds + ds1307_start(); + delay(5000); + ds1307_stop(); + + //Get time + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_NOT_EQUAL(start_sec, read_sec); //Seconds should have changed + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); + + old_sec = read_sec; + reset_read_values(); + + //Get time again to check that clock is stopped + delay(2000); + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_EQUAL(old_sec, read_sec); + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); +} + +void change_clock() { + //Get time + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_EQUAL(start_sec, read_sec); + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); + + Wire.setClock(400000); + reset_read_values(); + + TEST_ASSERT_EQUAL(400000, Wire.getClock()); + + //Get time + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_EQUAL(start_sec, read_sec); + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); +} + +void swap_pins() { + Wire.setPins(SCL, SDA); + Wire.begin(); + //Set time + ds1307_set_time(start_sec, start_min, start_hour, start_day, start_month, start_year); + + //Get time + ds1307_get_time(&read_sec, &read_min, &read_hour, &read_day, &read_month, &read_year); + + //Check time + TEST_ASSERT_EQUAL(start_sec, read_sec); + TEST_ASSERT_EQUAL(start_min, read_min); + TEST_ASSERT_EQUAL(start_hour, read_hour); + TEST_ASSERT_EQUAL(start_day, read_day); + TEST_ASSERT_EQUAL(start_month, read_month); + TEST_ASSERT_EQUAL(start_year, read_year); + + Wire.setPins(SDA, SCL); +} + +void test_api() { + int integer_ret; + + // Set Buffer Size + integer_ret = Wire.setBufferSize(32); + TEST_ASSERT_EQUAL(32, integer_ret); + integer_ret = Wire.setBufferSize(I2C_BUFFER_LENGTH); + TEST_ASSERT_EQUAL(I2C_BUFFER_LENGTH, integer_ret); + + // Set TimeOut + Wire.setTimeOut(100); + TEST_ASSERT_EQUAL(100, Wire.getTimeOut()); + + // Check if buffer can be peeked + TEST_ASSERT_GREATER_THAN(-1, peek_data); + + Wire.flush(); +} + +bool device_found() { + uint8_t err; + + for (uint8_t address = 1; address < 127; ++address) { + Wire.beginTransmission(address); + err = Wire.endTransmission(); + log_d("Address: 0x%02X, Error: %d", address, err); + if (err == 0) { + log_i("Found device at address: 0x%02X", address); + } else if (address == DS1307_ADDR) { + log_e("Failed to find DS1307"); + return false; + } + } + + return true; +} + +void scan_bus() { + TEST_ASSERT_TRUE(device_found()); +} + +#if SOC_WIFI_SUPPORTED +void scan_bus_with_wifi() { + // delete old config + WiFi.disconnect(true, true, 1000); + delay(1000); + WiFi.begin(ssid, password); + delay(5000); + bool found = device_found(); + WiFi.disconnect(true, true, 1000); + + TEST_ASSERT_TRUE(found); +} +#endif + +/* Main */ + +void setup() { + Serial.begin(115200); + while (!Serial) { + delay(10); + } + + log_d("Starting I2C Master"); + Wire.begin(); + + log_d("Starting tests"); + UNITY_BEGIN(); + RUN_TEST(scan_bus); +#if SOC_WIFI_SUPPORTED + RUN_TEST(scan_bus_with_wifi); +#endif + RUN_TEST(rtc_set_time); + RUN_TEST(rtc_run_clock); + RUN_TEST(change_clock); + RUN_TEST(swap_pins); + RUN_TEST(test_api); + UNITY_END(); +} + +void loop() { + vTaskDelete(NULL); +} diff --git a/tests/validation/i2c_master/test_i2c_master.py b/tests/validation/i2c_master/test_i2c_master.py new file mode 100644 index 00000000000..da5f790c0f8 --- /dev/null +++ b/tests/validation/i2c_master/test_i2c_master.py @@ -0,0 +1,2 @@ +def test_i2c_master(dut): + dut.expect_unity_test_output(timeout=240) diff --git a/tests/validation/nvs/ci.json b/tests/validation/nvs/ci.json index bddf221e3c0..7f8ce83ec54 100644 --- a/tests/validation/nvs/ci.json +++ b/tests/validation/nvs/ci.json @@ -28,6 +28,12 @@ "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio120", "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=dio" + ], + "esp32p4": [ + "espressif:esp32:esp32p4:PSRAM=enabled,USBMode=default,PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32p4:PSRAM=enabled,USBMode=default,PartitionScheme=huge_app,FlashMode=dio,FlashFreq=40", + "espressif:esp32:esp32p4:PSRAM=enabled,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32p4:PSRAM=enabled,USBMode=default,PartitionScheme=huge_app,FlashMode=qio,FlashFreq=40" ] }, "platforms": { diff --git a/tests/validation/psram/ci.json b/tests/validation/psram/ci.json index 341df103671..999d3be953e 100644 --- a/tests/validation/psram/ci.json +++ b/tests/validation/psram/ci.json @@ -1,7 +1,6 @@ { "platforms": { - "qemu": false, - "wokwi": false + "qemu": false }, "requires": [ "CONFIG_SPIRAM=y" diff --git a/tests/validation/psram/diagram.esp32s3.json b/tests/validation/psram/diagram.esp32s3.json new file mode 100644 index 00000000000..837ff1eed33 --- /dev/null +++ b/tests/validation/psram/diagram.esp32s3.json @@ -0,0 +1,24 @@ +{ + "version": 1, + "author": "lucasssvaz", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s3-devkitc-1", + "id": "esp", + "attrs": { "psramType": "octal" } + } + ], + "connections": [ + [ + "esp:TX", + "$serialMonitor:RX", + "" + ], + [ + "esp:RX", + "$serialMonitor:TX", + "" + ] + ] +} diff --git a/tests/validation/psram/psram.ino b/tests/validation/psram/psram.ino index 1304fe85cc1..7bf7bc11c5d 100644 --- a/tests/validation/psram/psram.ino +++ b/tests/validation/psram/psram.ino @@ -4,6 +4,12 @@ #define MAX_TEST_SIZE 512 * 1024 // 512KB void *buf = NULL; +uint32_t psram_size = 0; + +void psram_found(void) { + psram_size = ESP.getPsramSize(); + TEST_ASSERT_TRUE(psram_size > 0); +} void test_malloc_success(void) { buf = ps_malloc(MAX_TEST_SIZE); @@ -96,6 +102,13 @@ void setup() { } UNITY_BEGIN(); + RUN_TEST(psram_found); + + if (psram_size == 0) { + UNITY_END(); + return; + } + RUN_TEST(test_malloc_success); RUN_TEST(test_malloc_fail); RUN_TEST(test_calloc_success); @@ -104,8 +117,11 @@ void setup() { RUN_TEST(test_memset_all_zeroes); RUN_TEST(test_memset_all_ones); RUN_TEST(test_memset_alternating); +#ifndef CONFIG_IDF_TARGET_ESP32P4 + // These tests are taking too long on ESP32-P4 in Wokwi RUN_TEST(test_memset_random); RUN_TEST(test_memcpy); +#endif UNITY_END(); } diff --git a/tests/validation/uart/uart.ino b/tests/validation/uart/uart.ino index 27bd95da7f8..358276c00b4 100644 --- a/tests/validation/uart/uart.ino +++ b/tests/validation/uart/uart.ino @@ -399,7 +399,8 @@ void auto_baudrate_test(void) { if (TEST_UART_NUM == 1) { selected_serial = &Serial1; - uart_internal_loopback(0, RX1); + // UART1 pins were swapped because of ESP32-P4 + uart_internal_loopback(0, /*RX1*/ TX1); } else { #ifdef RX2 selected_serial = &Serial2; diff --git a/variants/Geekble_ESP32C3/pins_arduino.h b/variants/Geekble_ESP32C3/pins_arduino.h index 4eec3aa2f68..660313ce849 100644 --- a/variants/Geekble_ESP32C3/pins_arduino.h +++ b/variants/Geekble_ESP32C3/pins_arduino.h @@ -27,6 +27,6 @@ static const uint8_t A1 = 1; static const uint8_t A2 = 2; static const uint8_t A3 = 3; static const uint8_t A4 = 4; -static const uint8_t A5 = 5; +//static const uint8_t A5 = 5; // ADC1 no longer supported #endif /* Pins_Arduino_h */ diff --git a/variants/Geekble_Nano_ESP32S3/pins_arduino.h b/variants/Geekble_Nano_ESP32S3/pins_arduino.h new file mode 100644 index 00000000000..657c0d5d51b --- /dev/null +++ b/variants/Geekble_Nano_ESP32S3/pins_arduino.h @@ -0,0 +1,74 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x82C5 +#define USB_MANUFACTURER "Geekble" +#define USB_PRODUCT "Geekble nano ESP32-S3" +#define USB_SERIAL "" // Empty string for MAC address + +static const uint8_t D0 = 44; // also RX +static const uint8_t D1 = 43; // also TX +static const uint8_t D2 = 5; +static const uint8_t D3 = 6; // also CTS +static const uint8_t D4 = 7; // also DSR +static const uint8_t D5 = 8; +static const uint8_t D6 = 9; +static const uint8_t D7 = 10; +static const uint8_t D8 = 17; +static const uint8_t D9 = 18; +static const uint8_t D10 = 21; // also SS +static const uint8_t D11 = 38; // also MOSI +static const uint8_t D12 = 47; // also MISO +static const uint8_t D13 = 48; // also SCK, LED_BUILTIN + +static const uint8_t A0 = 1; // also DTR +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 11; // also SDA +static const uint8_t A5 = 12; // also SCL +static const uint8_t A6 = 13; +static const uint8_t A7 = 14; + +// alternate pin functions + +static const uint8_t LED_BUILTIN = D13; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN + +static const uint8_t SW_BUILTIN = 0; + +static const uint8_t TX = D1; +static const uint8_t RX = D0; +static const uint8_t RTS = 45; +static const uint8_t CTS = D3; +static const uint8_t DTR = A0; +static const uint8_t DSR = D4; + +static const uint8_t SS = D10; +static const uint8_t MOSI = D11; +static const uint8_t MISO = D12; +static const uint8_t SCK = D13; + +static const uint8_t SDA = A4; +static const uint8_t SCL = A5; + +// Touch input capable pins on the header +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; + +#define PIN_I2S_SCK D7 +#define PIN_I2S_FS D8 +#define PIN_I2S_SD D9 +#define PIN_I2S_SD_OUT D9 // same as bidir +#define PIN_I2S_SD_IN D10 + +#endif /* Pins_Arduino_h */ diff --git a/variants/XIAO_ESP32S3_Plus/bootloader-tinyuf2.bin b/variants/XIAO_ESP32S3_Plus/bootloader-tinyuf2.bin new file mode 100644 index 00000000000..b11e5b236f0 Binary files /dev/null and b/variants/XIAO_ESP32S3_Plus/bootloader-tinyuf2.bin differ diff --git a/variants/XIAO_ESP32S3_Plus/partitions-8MB.csv b/variants/XIAO_ESP32S3_Plus/partitions-8MB.csv new file mode 100644 index 00000000000..4026378b6fb --- /dev/null +++ b/variants/XIAO_ESP32S3_Plus/partitions-8MB.csv @@ -0,0 +1,10 @@ +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +# bootloader.bin,, 0x1000, 32K +# partition table,, 0x8000, 4K +nvs, data, nvs, 0x9000, 20K, +otadata, data, ota, 0xe000, 8K, +ota_0, 0, ota_0, 0x10000, 2048K, +ota_1, 0, ota_1, 0x210000, 2048K, +uf2, app, factory,0x410000, 256K, +ffat, data, fat, 0x450000, 3776K, diff --git a/variants/XIAO_ESP32S3_Plus/pins_arduino.h b/variants/XIAO_ESP32S3_Plus/pins_arduino.h new file mode 100644 index 00000000000..fb887287e35 --- /dev/null +++ b/variants/XIAO_ESP32S3_Plus/pins_arduino.h @@ -0,0 +1,90 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x2886 +#define USB_PID 0x0056 + +static const uint8_t LED_BUILTIN = 21; +#define BUILTIN_LED LED_BUILTIN // backward compatibility +#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t TX1 = 42; +static const uint8_t RX1 = 41; + +static const uint8_t SDA = 5; +static const uint8_t SCL = 6; + +static const uint8_t SS = 44; +static const uint8_t MOSI = 9; +static const uint8_t MISO = 8; +static const uint8_t SCK = 7; + +static const uint8_t MOSI1 = 11; +static const uint8_t MISO1 = 12; +static const uint8_t SCK1 = 13; + +static const uint8_t I2S_SCK = 39; +static const uint8_t I2S_SD = 38; +static const uint8_t I2S_WS = 40; + +static const uint8_t MTCK = 39; +static const uint8_t MTDO = 40; +static const uint8_t MTDI = 41; +static const uint8_t MTMS = 42; + +static const uint8_t DVP_Y8 = 11; +static const uint8_t DVP_YP = 12; +static const uint8_t DVP_PCLK = 13; +static const uint8_t DVP_VSYNC = 38; +static const uint8_t CAM_SCL = 39; +static const uint8_t CAM_SDA = 40; +static const uint8_t XMCLK = 10; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A8 = 7; +static const uint8_t A9 = 8; +static const uint8_t A10 = 9; +static const uint8_t ADC_BAT = 10; + +static const uint8_t D0 = 1; +static const uint8_t D1 = 2; +static const uint8_t D2 = 3; +static const uint8_t D3 = 4; +static const uint8_t D4 = 5; +static const uint8_t D5 = 6; +static const uint8_t D6 = 43; +static const uint8_t D7 = 44; +static const uint8_t D8 = 7; +static const uint8_t D9 = 8; +static const uint8_t D10 = 9; +static const uint8_t D11 = 38; +static const uint8_t D12 = 39; +static const uint8_t D13 = 40; +static const uint8_t D14 = 41; +static const uint8_t D15 = 42; +static const uint8_t D16 = 10; +static const uint8_t D17 = 13; +static const uint8_t D18 = 12; +static const uint8_t D19 = 11; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; + +#endif /* Pins_Arduino_h */ diff --git a/variants/XIAO_ESP32S3_Plus/tinyuf2.bin b/variants/XIAO_ESP32S3_Plus/tinyuf2.bin new file mode 100644 index 00000000000..86d981f8019 Binary files /dev/null and b/variants/XIAO_ESP32S3_Plus/tinyuf2.bin differ diff --git a/variants/cyobot_v2_esp32s3/pins_arduino.h b/variants/cyobot_v2_esp32s3/pins_arduino.h new file mode 100644 index 00000000000..45f0968ef2a --- /dev/null +++ b/variants/cyobot_v2_esp32s3/pins_arduino.h @@ -0,0 +1,52 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_MANUFACTURER "CYOBot" +#define USB_PRODUCT "CYOBrain ESP32S3" +#define USB_SERIAL "" // Empty string for MAC address + +static const uint8_t BUTTON0 = 4; +static const uint8_t BUTTON1 = 38; +static const uint8_t LED = 24; + +static const uint8_t BAT_MEAS = 6; +static const uint8_t CHAR_DET = 23; + +static const uint8_t NEO_BASE = 7; +static const uint8_t NEO_BRAIN = 15; + +static const uint8_t I2S0_MCLK = 16; +static const uint8_t I2S0_DSDIN = 8; +static const uint8_t I2S0_SCLK = 9; +static const uint8_t I2S0_LRCK = 45; + +static const uint8_t SDA = 17; +static const uint8_t SCL = 18; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 2; +static const uint8_t MISO = 42; +static const uint8_t SCK = 41; + +static const uint8_t ENCODER1_A = 39; +static const uint8_t ENCODER1_B = 40; +static const uint8_t ENCODER2_B = 19; +static const uint8_t ENCODER2_A = 20; + +static const uint8_t UART1_RXD = 3; +static const uint8_t UART1_TXD = 1; + +static const uint8_t GPIO46 = 46; +static const uint8_t ESP_IO0 = 0; + +static const uint8_t SD_OUT = 10; +static const uint8_t SD_SPI_MOSI = 11; +static const uint8_t SD_SPI_CLK = 12; +static const uint8_t SD_SPI_MISO = 13; +static const uint8_t SD_SPI_CS = 14; + +static const uint8_t PA_CTRL = 25; + +#endif /* Pins_Arduino_h */ diff --git a/variants/esp32c6/pins_arduino.h b/variants/esp32c6/pins_arduino.h index 55afea91565..348db9f907e 100644 --- a/variants/esp32c6/pins_arduino.h +++ b/variants/esp32c6/pins_arduino.h @@ -32,4 +32,9 @@ static const uint8_t A4 = 4; static const uint8_t A5 = 5; static const uint8_t A6 = 6; +// LP I2C Pins are fixed on ESP32-C6 +#define WIRE1_PIN_DEFINED +static const uint8_t SDA1 = 6; +static const uint8_t SCL1 = 7; + #endif /* Pins_Arduino_h */ diff --git a/variants/huidu_hd_wf2/pins_arduino.h b/variants/huidu_hd_wf2/pins_arduino.h index 97d72dcc0f3..6068e4d6371 100644 --- a/variants/huidu_hd_wf2/pins_arduino.h +++ b/variants/huidu_hd_wf2/pins_arduino.h @@ -58,19 +58,4 @@ static const uint8_t MOSI = 11; static const uint8_t MISO = 13; static const uint8_t SCK = 12; -static const uint8_t T1 = WF2_X1_R1_PIN; -static const uint8_t T2 = WF2_X1_R2_PIN; -static const uint8_t T3 = WF2_X1_G1_PIN; -static const uint8_t T4 = WF2_X1_G2_PIN; -static const uint8_t T5 = WF2_X1_B1_PIN; -static const uint8_t T6 = WF2_X1_B2_PIN; -static const uint8_t T7 = WF2_A_PIN; -static const uint8_t T8 = WF2_B_PIN; -static const uint8_t T9 = WF2_C_PIN; -static const uint8_t T10 = WF2_D_PIN; -static const uint8_t T11 = WF2_X1_E_PIN; -static const uint8_t T12 = WF2_OE_PIN; -static const uint8_t T13 = WF2_CLK_PIN; -static const uint8_t T14 = WF2_LAT_PIN; - #endif /* Pins_Arduino_h */ diff --git a/variants/huidu_hd_wf4/pins_arduino.h b/variants/huidu_hd_wf4/pins_arduino.h index cd96db6c445..5b8667477bf 100644 --- a/variants/huidu_hd_wf4/pins_arduino.h +++ b/variants/huidu_hd_wf4/pins_arduino.h @@ -19,7 +19,7 @@ #define WF4_CLK_PIN 34 #define WF4_LAT_PIN 33 -// X1 +// X1 HUB75 #define WF4_X1_R1_PIN 2 #define WF4_X1_R2_PIN 3 #define WF4_X1_G1_PIN 6 @@ -28,7 +28,7 @@ #define WF4_X1_B2_PIN 11 #define WF4_X1_CS_PIN 45 // CS gpio must be set HIGH to enable X1 output -// X2 +// X2 HUB75 #define WF4_X2_R1_PIN 4 #define WF4_X2_R2_PIN 5 #define WF4_X2_G1_PIN 8 @@ -37,7 +37,7 @@ #define WF4_X2_B2_PIN 13 #define WF4_X2_CS_PIN WF4_X1_CS_PIN // CS gpio must be set HIGH to enable X2 output -// X3 +// X3 HUB75 #define WF4_X3_R1_PIN 2 #define WF4_X3_R2_PIN 3 #define WF4_X3_G1_PIN 6 @@ -46,7 +46,7 @@ #define WF4_X3_B2_PIN 11 #define WF4_X3_CS_PIN 14 // CS gpio must be set HIGH to enable X3 output -// X4 +// X4 HUB75 #define WF4_X4_R1_PIN 4 #define WF4_X4_R2_PIN 5 #define WF4_X4_G1_PIN 8 @@ -55,52 +55,57 @@ #define WF4_X4_B2_PIN 13 #define WF4_X4_CS_PIN WF4_X3_CS_PIN // CS gpio must be set HIGH to enable X4 output -//#define WF4_P1_PIN UART -#define WF4_P2_DATA_PIN 0 // GPIO0 boot -#define WF4_P5_DATA_PIN 16 // temperature -//#define WF4_P7_PIN VCC/GND -#define WF4_P11_DATA_PIN 15 // IR +// P1 is a UART connector +#define WF4_P1_RX_PIN 44 +#define WF4_P1_TX_PIN 43 + +// P2: PCB holes gpio/gnd +#define WF4_P2_DATA_PIN 0 // GPIO0 boot + +// P5: temperature sensor connector +#define WF4_P5_DATA_PIN 16 + +// P7: VCC/GPIO holes on PCB +#define WF4_P7_DATA_PIN 1 + +// P11: IR connector +#define WF4_P11_DATA_PIN 15 + +// P12: two gpio's, Vcc, GND #define WF4_P12_DATA1_PIN 47 #define WF4_P12_DATA2_PIN 18 -#define WF4_S1_DATA_PIN 17 // Button -#define WF4_S2_DATA_PIN 48 -#define WF4_S3_DATA_PIN 26 -#define WF4_S4_DATA_PIN 46 + +// S1 Button +#define WF4_S1_DATA_PIN 17 + +// S2-S3 PCB holes +#define WF4_S2_DATA_PIN 48 +#define WF4_S3_DATA_PIN 26 +#define WF4_S4_DATA_PIN 46 #define WF4_BUTTON_TEST WF4_S1_PIN // Test key button on PCB, 1=normal, 0=pressed #define WF4_LED_RUN_PIN 40 // Status LED on PCB #define WF4_BM8563_I2C_SDA 41 // RTC BM8563 I2C port #define WF4_BM8563_I2C_SCL 42 -#define WF4_USB_DM_PIN 19 -#define WF4_USB_DP_PIN 20 +#define WF4_USB_DN_PIN 19 // USB-A D- +#define WF4_USB_DP_PIN 20 // USB-A D+ #define LED_BUILTIN WF4_LED_RUN_PIN #define BUILTIN_LED LED_BUILTIN // backward compatibility -static const uint8_t TX = 43; -static const uint8_t RX = 44; +static const uint8_t TX = WF4_P1_TX_PIN; +static const uint8_t RX = WF4_P1_RX_PIN; static const uint8_t SDA = WF4_BM8563_I2C_SDA; static const uint8_t SCL = WF4_BM8563_I2C_SCL; -static const uint8_t SS = 10; -static const uint8_t MOSI = 11; -static const uint8_t MISO = 13; -static const uint8_t SCK = 12; - -static const uint8_t T1 = WF4_X1_R1_PIN; -static const uint8_t T2 = WF4_X1_R2_PIN; -static const uint8_t T3 = WF4_X1_G1_PIN; -static const uint8_t T4 = WF4_X1_G2_PIN; -static const uint8_t T5 = WF4_X1_B1_PIN; -static const uint8_t T6 = WF4_X1_B2_PIN; -static const uint8_t T7 = WF4_A_PIN; -static const uint8_t T8 = WF4_B_PIN; -static const uint8_t T9 = WF4_C_PIN; -static const uint8_t T10 = WF4_D_PIN; -static const uint8_t T11 = WF4_E_PIN; -static const uint8_t T12 = WF4_OE_PIN; -static const uint8_t T13 = WF4_CLK_PIN; -static const uint8_t T14 = WF4_LAT_PIN; +// there is no dedicated SPI connector on board, but SPI could be accessed via PCB holes +static const uint8_t SS = WF4_S2_DATA_PIN; +static const uint8_t MOSI = WF4_S3_DATA_PIN; +static const uint8_t MISO = WF4_S4_DATA_PIN; +static const uint8_t SCK = WF4_P7_DATA_PIN; + +// touch pins are mostly busy with HUB75 ports +static const uint8_t T1 = WF4_P7_DATA_PIN; #endif /* Pins_Arduino_h */ diff --git a/variants/um_feathers3/pins_arduino.h b/variants/um_feathers3/pins_arduino.h index 8de87c688a9..1c81339c88e 100644 --- a/variants/um_feathers3/pins_arduino.h +++ b/variants/um_feathers3/pins_arduino.h @@ -16,6 +16,10 @@ static const uint8_t RX = 44; static const uint8_t SDA = 8; static const uint8_t SCL = 9; +#define WIRE1_PIN_DEFINED 1 // See Wire.cpp at bool TwoWire::initPins(int sdaPin, int sclPin) +static const uint8_t SDA1 = 16; +static const uint8_t SCL1 = 15; + static const uint8_t SS = 5; static const uint8_t MOSI = 35; static const uint8_t MISO = 37;