pioarduino Arduino Core 3.0.5
pioarduino Arduino Core 3.0.5
This commit is contained in:
@@ -1 +0,0 @@
|
||||
custom: https://platformio.org/donate
|
||||
@@ -0,0 +1,9 @@
|
||||
## Description:
|
||||
|
||||
**Related issue (if applicable):** fixes #<issue number goes here>
|
||||
|
||||
## Checklist:
|
||||
- [ ] The pull request is done against the latest develop branch
|
||||
- [ ] Only relevant files were touched
|
||||
- [ ] Only one feature/fix was added per PR, more changes are allowed when changing boards.json
|
||||
- [ ] I accept the [CLA](https://github.com/pioarduino/platform-espressif32/blob/develop/CONTRIBUTING.md).
|
||||
@@ -0,0 +1,11 @@
|
||||
# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot
|
||||
|
||||
# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic
|
||||
# Anything higher than this threshold will be marked as toxic and commented on
|
||||
sentimentBotToxicityThreshold: .7
|
||||
|
||||
# *Required* Comment to reply with
|
||||
sentimentBotReplyComment: >
|
||||
Please be sure to review the code of conduct and be respectful of other users.
|
||||
|
||||
# Note: the bot will only work if your repository has a Code of Conduct
|
||||
@@ -18,6 +18,10 @@ jobs:
|
||||
- "examples/arduino-rmt-blink"
|
||||
- "examples/arduino-usb-keyboard"
|
||||
- "examples/arduino-wifiscan"
|
||||
#- "examples/arduino-zigbee-light"
|
||||
#- "examples/arduino-zigbee-switch"
|
||||
- "examples/espidf-arduino-h2zero-BLE_scan"
|
||||
#- "examples/espidf-arduino-matter-light" # Windows compile fails -> Path length limit
|
||||
- "examples/espidf-arduino-blink"
|
||||
- "examples/espidf-arduino-littlefs"
|
||||
- "examples/espidf-blink"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: "Mark or close stale issues and PRs"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 * * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: 25
|
||||
days-before-close: 5
|
||||
stale-issue-message: "This issue has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions."
|
||||
stale-pr-message: "This PR has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions."
|
||||
close-issue-message: "This issue was automatically closed because of being stale. Feel free to open a new one if you still experience this problem."
|
||||
close-pr-message: "This PR was automatically closed because of being stale."
|
||||
stale-pr-label: "stale"
|
||||
stale-issue-label: "stale"
|
||||
exempt-issue-labels: "bug,enhancement,pinned,security"
|
||||
exempt-pr-labels: "bug,enhancement,pinned,security"
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
# Contributing
|
||||
|
||||
**Any contribution helps our team and makes pioarduino better for the entire community!**
|
||||
|
||||
Everybody is welcome and invited to contribute to pioarduino Project by:
|
||||
|
||||
* Testing newly released features and reporting issues.
|
||||
* Providing Pull Requests (Features, Proof of Concepts or Fixes)
|
||||
* Contributing missing documentation for features in our (not yet existing ;-)) documentation
|
||||
|
||||
This document describes rules that are in effect for this repository, meant for handling issues by contributors in the issue tracker and PRs.
|
||||
|
||||
## Opening New Issues
|
||||
|
||||
**Issue tracker is NOT a general discussion forum!**
|
||||
1. Opening an issue means that a problem exists in the code and should be addressed by the project contributors.
|
||||
2. When opening an issue, provide as much as possible infos. The information is important! With insufficient info about the provided issue, the issue may be closed.
|
||||
3. Questions of type "How do I..." or "Can you please help me with..." WILL NOT be handled here. Such questions should be directed to pioarduino Support Chat. All issues of this type will be closed with a simple reference to this contributing policy.
|
||||
4. Issues about topics already handled in the documentation will be closed in a similar manner.
|
||||
5. Issues for unmerged PRs will be closed. If there is an issue with a PR, the explanation should be added to the PR itself.
|
||||
6. Issues with accompanied investigation that shows the root of the problem should be given priority.
|
||||
7. Duplicate issues will be closed.
|
||||
|
||||
## Triaging of Issues/PR's
|
||||
|
||||
1. Any contributor to the project can participate in the triaging process, if he/she/them chooses to do so.
|
||||
2. An issue that needs to be closed, either due to not complying with this policy, or for other reasons, should be closed by a contributor.
|
||||
3. Issues that are accepted should be marked with appropriate labels.
|
||||
4. Issues that could impact functionality for many users should be considered severe.
|
||||
5. Issues with feature requests should be discussed for viability/desirability.
|
||||
6. Feature requests or changes that are meant to address a very specific/limited use case, may be denied, or may be required to be redesigned, generalized, or simplified.
|
||||
7. Feature requests that are not accompanied by a PR:
|
||||
* could be closed immediately (denied).
|
||||
* could be closed after some predetermined period of time (left as candidate for somebody to pick up).
|
||||
8. In some cases, feedback may be requested from the issue reporter, either as additional info for clarification, additional testing, or other. If no feedback is provided, the issue may be closed by a contributor or after 30 days by the STALE bot.
|
||||
|
||||
## Pull requests
|
||||
|
||||
A Pull Request (PR) is the process where code modifications are managed in GitHub.
|
||||
|
||||
The process is straight-forward.
|
||||
|
||||
- Read [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews) by Kubernetes (but skip step 0)
|
||||
- Fork the pioarduino platform-espressif32 Repository [git repository](https://github.com/pioarduino/platform-espressif32).
|
||||
- Write/Change the code in your Fork for a new feature, bug fix, optimization, etc.
|
||||
- Ensure tests work.
|
||||
- Create a Pull Request against the [**develop**](https://github.com/pioarduino/platform-espressif32/tree/develop) branch of pioarduino.
|
||||
|
||||
1. All pull requests must be done against the develop branch.
|
||||
2. Only relevant files should be touched (Also beware if your editor has auto-formatting feature enabled).
|
||||
3. Only one feature/fix should be added per PR. A PR for mass changes in boards manifest is allowed.
|
||||
4. PRs that don't compile (fail in CI Tests) or cause coding errors will not be merged. Please fix the issue. Same goes for PRs that are raised against older commit in develop - you might need to rebase and resolve conflicts.
|
||||
5. All pull requests should undergo peer review by at least one contributor other than the creator, excepts for the owner.
|
||||
6. All pull requests should consider updates to the documentation.
|
||||
7. Pull requests that address an outstanding issue, particularly an issue deemed to be severe, should be given priority.
|
||||
8. If a PR is accepted, then it should undergo review and updated based on the feedback provided, then merged.
|
||||
9. By submitting a PR, it is needed to use the provided PR template and check all boxes, performing the required tasks and accepting the CLA.
|
||||
10. Pull requests that don't meet the above will be denied and closed.
|
||||
|
||||
--------------------------------------
|
||||
|
||||
## Contributor License Agreement (CLA)
|
||||
|
||||
```
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the GPL-3.0 license; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the GPL-3.0 license; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it) is maintained indefinitely
|
||||
and may be redistributed consistent with this project or the open
|
||||
source license(s) involved.
|
||||
```
|
||||
|
||||
This Contributor License Agreement (CLA) was adopted on April 1st, 2019.
|
||||
|
||||
The text of this license is available under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/). It is based on the Linux [Developer Certificate Of Origin](http://elinux.org/Developer_Certificate_Of_Origin), but is modified to explicitly use the GPL-3.0 license and not mention sign-off (due to GitHub.com keeps an historial, with your user name, of PRs' commits and all editions on PR's comments).
|
||||
|
||||
To accept the CLA it is required to put a x between [ ] on `[ ] I accept the CLA` in the PR template when submitting it. The [ ] is an opt-in box, so you have to manually accept it.
|
||||
|
||||
**Why a CLA ?**
|
||||
|
||||
_"A Contributor License Agreement (CLA) is strongly recommended when accepting third party contributions to an open development project, such as an open source software project. In order to redistribute contributions, it is necessary to ensure that the project has the necessary rights to do so. A Contributor License Agreement is a lightweight agreement, signed by the copyright holder, that grants the necessary rights for the contribution to be redistributed as part of the project."_ [OSS Watch](http://oss-watch.ac.uk/resources/cla)
|
||||
|
||||
A CLA is a legal document in which you state _you are entitled to contribute the code/documentation/translation to the project_ you’re contributing to and that _you are willing to have it used in distributions and derivative works_. This means that should there be any kind of legal issue in the future as to the origins and ownership of any particular piece of code, then that project has the necessary forms on file from the contributor(s) saying they were permitted to make this contribution.
|
||||
|
||||
CLA is a safety because it also ensures that once you have provided a contribution, you cannot try to withdraw permission for its use at a later date. People can therefore use that software, confident that they will not be asked to stop using pieces of the code at a later date.
|
||||
|
||||
A __license__ grants "outbound" rights to the user of project.
|
||||
|
||||
A __CLA__ enables a contributor to grant "inbound" rights to a project.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Other>
|
||||
<A table should be maintained for relating maintainers and components. When triaging, this is essential to figure out if someone in particular should be consulted about specific changes.>
|
||||
<A stable release cadence should be established, e.g.: every month.>
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DARDUINO_ADAFRUIT_FEATHER_ESP32C6",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1"
|
||||
],
|
||||
"f_cpu": "160000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"mcu": "esp32c6",
|
||||
"variant": "adafruit_feather_esp32c6"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"zigbee",
|
||||
"thread"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32c6.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Adafruit Feather ESP32-C6",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.adafruit.com/product/5933",
|
||||
"vendor": "Adafruit"
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
"variant": "esp32c6"
|
||||
},
|
||||
"connectivity": [
|
||||
"bluetooth",
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DARDUINO_ESP32_DEV -DARDUINO_USB_CDC_ON_BOOT=0 -DCORE32SOLO1",
|
||||
"f_cpu": "80000000L",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
]
|
||||
],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "heltec_wifi_kit_32_v3"
|
||||
"variant": "heltec_wifi_kit_32_V3"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32_out.ld",
|
||||
"partitions": "default_8MB.csv"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DARDUINO_HELTEC_WIFI_KIT_32",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
"variant": "heltec_wifi_kit_32"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"ethernet",
|
||||
"can"
|
||||
],
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Heltec WiFi Kit 32 (V2)",
|
||||
"upload": {
|
||||
"flash_size": "8MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 8388608,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "http://www.heltec.cn/project/wifi-kit-32/?lang=en",
|
||||
"vendor": "Heltec Automation"
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino":{
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DARDUINO_M5Stick_C",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
"variant": "m5stick_c"
|
||||
"variant": "m5stack_stickc"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"build": {
|
||||
"core": "esp32",
|
||||
"f_cpu": "160000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"mcu": "esp32c6",
|
||||
"variant": "sparkfun_esp32c6_thing_plus",
|
||||
"extra_flags": [
|
||||
"-DARDUINO_ESP32C6_THING_PLUS",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"-DARDUINO_USB_MODE=1"
|
||||
]
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"zigbee",
|
||||
"thread"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32c6.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "Sparkfun ESP32-C6 Thing Plus",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.sparkfun.com/products/22924",
|
||||
"vendor": "Sparkfun"
|
||||
}
|
||||
+26
-14
@@ -21,7 +21,7 @@ from platformio.proc import where_is_program, exec_command
|
||||
|
||||
from SCons.Script import Import
|
||||
|
||||
Import("env sdk_config project_config idf_variant")
|
||||
Import("env sdk_config project_config app_includes idf_variant")
|
||||
|
||||
ulp_env = env.Clone()
|
||||
platform = ulp_env.PioPlatform()
|
||||
@@ -37,22 +37,24 @@ def prepare_ulp_env_vars(env):
|
||||
|
||||
toolchain_path = platform.get_package_dir(
|
||||
"toolchain-xtensa-%s" % idf_variant
|
||||
if idf_variant not in ("esp32c6", "esp32p4")
|
||||
else "toolchain-riscv32-esp"
|
||||
)
|
||||
|
||||
toolchain_path_ulp = platform.get_package_dir(
|
||||
"toolchain-esp32ulp"
|
||||
if sdk_config.get("ULP_COPROC_TYPE_FSM", False)
|
||||
else ""
|
||||
)
|
||||
|
||||
additional_packages = [
|
||||
toolchain_path,
|
||||
os.path.join(
|
||||
platform.get_package_dir("toolchain-esp32ulp"),
|
||||
"bin",
|
||||
),
|
||||
toolchain_path_ulp,
|
||||
platform.get_package_dir("tool-ninja"),
|
||||
os.path.join(platform.get_package_dir("tool-cmake"), "bin"),
|
||||
os.path.dirname(where_is_program("python")),
|
||||
]
|
||||
|
||||
# if "windows" in get_systype():
|
||||
# additional_packages.append(platform.get_package_dir("tool-mconf"))
|
||||
|
||||
for package in additional_packages:
|
||||
ulp_env.PrependENVPath("PATH", package)
|
||||
|
||||
@@ -81,6 +83,19 @@ def get_component_includes(target_config):
|
||||
def generate_ulp_config(target_config):
|
||||
def _generate_ulp_configuration_action(env, target, source):
|
||||
riscv_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_RISCV", False)
|
||||
lp_core_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_LP_CORE", False)
|
||||
|
||||
if lp_core_ulp_enabled == False:
|
||||
ulp_toolchain = "toolchain-%sulp%s.cmake"% (
|
||||
"" if riscv_ulp_enabled else idf_variant + "-",
|
||||
"-riscv" if riscv_ulp_enabled else "",
|
||||
)
|
||||
else:
|
||||
ulp_toolchain = "toolchain-lp-core-riscv.cmake"
|
||||
|
||||
comp_includes = ";".join(get_component_includes(target_config))
|
||||
plain_includes = ";".join(app_includes["plain_includes"])
|
||||
comp_includes = comp_includes + plain_includes
|
||||
|
||||
cmd = (
|
||||
os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),
|
||||
@@ -91,21 +106,18 @@ def generate_ulp_config(target_config):
|
||||
"components",
|
||||
"ulp",
|
||||
"cmake",
|
||||
"toolchain-%sulp%s.cmake"
|
||||
% (
|
||||
"" if riscv_ulp_enabled else idf_variant + "-",
|
||||
"-riscv" if riscv_ulp_enabled else "",
|
||||
),
|
||||
ulp_toolchain,
|
||||
),
|
||||
"-DULP_S_SOURCES=%s" % ";".join([fs.to_unix_path(s.get_abspath()) for s in source]),
|
||||
"-DULP_APP_NAME=ulp_main",
|
||||
"-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"),
|
||||
"-DCOMPONENT_INCLUDES=%s" % ";".join(get_component_includes(target_config)),
|
||||
"-DCOMPONENT_INCLUDES=" + comp_includes,
|
||||
"-DIDF_TARGET=%s" % idf_variant,
|
||||
"-DIDF_PATH=" + fs.to_unix_path(FRAMEWORK_DIR),
|
||||
"-DSDKCONFIG_HEADER=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"),
|
||||
"-DPYTHON=" + env.subst("$PYTHONEXE"),
|
||||
"-DULP_COCPU_IS_RISCV=%s" % ("ON" if riscv_ulp_enabled else "OFF"),
|
||||
"-DULP_COCPU_IS_LP_CORE=%s" % ("ON" if lp_core_ulp_enabled else "OFF"),
|
||||
"-GNinja",
|
||||
"-B",
|
||||
ULP_BUILD_DIR,
|
||||
|
||||
@@ -256,9 +256,6 @@ env.Replace(
|
||||
if mcu in ("esp32c2", "esp32c3", "esp32c6")
|
||||
else "tool-xtensa-esp-elf-gdb"
|
||||
)
|
||||
or "",
|
||||
"bin",
|
||||
"%s-elf-gdb" % toolchain_arch,
|
||||
),
|
||||
OBJCOPY=join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
|
||||
RANLIB="%s-elf-gcc-ranlib" % toolchain_arch,
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[pioarduino](https://github.com/pioarduino/platform-espressif32/issues/new/choose).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# Arduino-ESP32 Zigbee On/Off Light Example
|
||||
|
||||
This example shows how to configure the Zigbee end device 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
|
||||
|
||||
* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with Zigbee_On_Off_switch example)
|
||||
* A USB cable for power supply and programming
|
||||
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the Zigbee_On_Off_Light example
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Set the LED GPIO by changing the `LED_PIN` definition. By default, the LED_PIN is `RGB_BUILTIN`.
|
||||
By default, the `neoPixelWrite` 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.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the End device flashed with this example is not connecting to the coordinator, erase the flash before flashing it to the board. It is recommended to do this if you did changes to 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`
|
||||
* In the sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
|
||||
|
||||
By default, the coordinator network is open for 180s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
|
||||
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.
|
||||
|
||||
***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)
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -0,0 +1,20 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
[env:esp32-h2-devkitm-1]
|
||||
platform = https://github.com/pioarduino/platform-espressif32.git#develop
|
||||
framework = arduino
|
||||
board = esp32-h2-devkitm-1
|
||||
monitor_speed = 115200
|
||||
board_build.partitions = zigbee.csv
|
||||
board_build.filesystem = spiffs
|
||||
build_flags =
|
||||
-DZIGBEE_MODE_ED
|
||||
-DCORE_DEBUG_LEVEL=5
|
||||
@@ -0,0 +1,89 @@
|
||||
// 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 simple Zigbee light bulb.
|
||||
*
|
||||
* The example demonstrates how to use Zigbee library to create a end device light bulb.
|
||||
* 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 "ZigbeeCore.h"
|
||||
#include "ep/ZigbeeLight.h"
|
||||
|
||||
#define LED_PIN RGB_BUILTIN
|
||||
#define BUTTON_PIN 9 // C6/H2 Boot button
|
||||
#define ZIGBEE_LIGHT_ENDPOINT 10 /* esp light bulb device endpoint, used to process light controlling commands */
|
||||
|
||||
class MyZigbeeLight : public ZigbeeLight {
|
||||
public:
|
||||
// Constructor that passes parameters to the base class constructor
|
||||
MyZigbeeLight(uint8_t endpoint) : ZigbeeLight(endpoint) {}
|
||||
|
||||
// Override the set_on_off function
|
||||
void setOnOff(bool value) override {
|
||||
rgbLedWrite(LED_PIN, 255 * value, 255 * value, 255 * value); // Toggle light
|
||||
}
|
||||
};
|
||||
|
||||
MyZigbeeLight zbLight = MyZigbeeLight(ZIGBEE_LIGHT_ENDPOINT);
|
||||
|
||||
/********************* Arduino functions **************************/
|
||||
void setup() {
|
||||
// Init RMT and leave light OFF
|
||||
rgbLedWrite(LED_PIN, 0, 0, 0);
|
||||
|
||||
// Init button for factory reset
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
|
||||
//Optional: set Zigbee device name and model
|
||||
zbLight.setManufacturerAndModel("Espressif", "ZBLightBulb");
|
||||
|
||||
//Add endpoint to Zigbee Core
|
||||
log_d("Adding ZigbeeLight endpoint to Zigbee Core");
|
||||
Zigbee.addEndpoint(&zbLight);
|
||||
|
||||
// When all EPs are registered, start Zigbee. By default acts as ZIGBEE_END_DEVICE
|
||||
log_d("Calling Zigbee.begin()");
|
||||
Zigbee.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Cheking 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("Reseting Zigbee to factory settings, reboot.\n");
|
||||
Zigbee.factoryReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -0,0 +1,65 @@
|
||||
# Arduino-ESP32 Zigbee On/Off Light Switch Example
|
||||
|
||||
This example shows how to configure Zigbee Coordinator and use it as a Home Automation (HA) on/off light switch.
|
||||
|
||||
# Supported Targets
|
||||
|
||||
Currently, this example supports the following targets.
|
||||
|
||||
| Supported Targets | ESP32-C6 | ESP32-H2 |
|
||||
| ----------------- | -------- | -------- |
|
||||
|
||||
## Hardware Required
|
||||
|
||||
* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee end device (loaded with Zigbee_On_Off_Light example).
|
||||
* A USB cable for power supply and programming.
|
||||
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee coordinator and upload the Zigbee_On_Off_Switch example.
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the pin `9` (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 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 info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the End device flashed with the example `Zigbee_Light_Bulb` 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`.
|
||||
* In the `Zigbee_Light_Bulb` example sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
|
||||
|
||||
By default, the coordinator network is open for 180s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
|
||||
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.
|
||||
|
||||
***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)
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -0,0 +1,20 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
[env:esp32-c6-devkitc-1]
|
||||
platform = https://github.com/pioarduino/platform-espressif32.git#develop
|
||||
framework = arduino
|
||||
board = esp32-c6-devkitc-1
|
||||
monitor_speed = 115200
|
||||
board_build.partitions = zigbee_zczr.csv
|
||||
board_build.filesystem = spiffs
|
||||
build_flags =
|
||||
-DZIGBEE_MODE_ZCZR
|
||||
-DCORE_DEBUG_LEVEL=5
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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 simple Zigbee light switch.
|
||||
*
|
||||
* The example demonstrates how to use Zigbee library to control a light bulb.
|
||||
* The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator (Switch).
|
||||
* Button switch and Zigbee runs in separate tasks.
|
||||
*
|
||||
* 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 mode is not selected in Tools->Zigbee mode"
|
||||
#endif
|
||||
|
||||
#include "ZigbeeCore.h"
|
||||
#include "ep/ZigbeeSwitch.h"
|
||||
|
||||
#define SWITCH_ENDPOINT_NUMBER 5
|
||||
|
||||
/* Switch configuration */
|
||||
#define GPIO_INPUT_IO_TOGGLE_SWITCH 9
|
||||
#define PAIR_SIZE(TYPE_STR_PAIR) (sizeof(TYPE_STR_PAIR) / sizeof(TYPE_STR_PAIR[0]))
|
||||
|
||||
typedef enum {
|
||||
SWITCH_ON_CONTROL,
|
||||
SWITCH_OFF_CONTROL,
|
||||
SWITCH_ONOFF_TOGGLE_CONTROL,
|
||||
SWITCH_LEVEL_UP_CONTROL,
|
||||
SWITCH_LEVEL_DOWN_CONTROL,
|
||||
SWITCH_LEVEL_CYCLE_CONTROL,
|
||||
SWITCH_COLOR_CONTROL,
|
||||
} SwitchFunction;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pin;
|
||||
SwitchFunction func;
|
||||
} SwitchData;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_IDLE,
|
||||
SWITCH_PRESS_ARMED,
|
||||
SWITCH_PRESS_DETECTED,
|
||||
SWITCH_PRESSED,
|
||||
SWITCH_RELEASE_DETECTED,
|
||||
} SwitchState;
|
||||
|
||||
static SwitchData buttonFunctionPair[] = {{GPIO_INPUT_IO_TOGGLE_SWITCH, SWITCH_ONOFF_TOGGLE_CONTROL}};
|
||||
|
||||
/* Zigbee switch */
|
||||
class MyZigbeeSwitch : public ZigbeeSwitch {
|
||||
public:
|
||||
// Constructor that passes parameters to the base class constructor
|
||||
MyZigbeeSwitch(uint8_t endpoint) : ZigbeeSwitch(endpoint) {}
|
||||
|
||||
// Override the set_on_off function
|
||||
void readManufacturer(char* manufacturer) override {
|
||||
//Do what you want with the manufacturer string
|
||||
Serial.printf("Manufacturer: %s\n", manufacturer);
|
||||
}
|
||||
void readModel(char* model) override {
|
||||
//Do what you want with the model string
|
||||
Serial.printf("Model: %s\n", model);
|
||||
}
|
||||
};
|
||||
|
||||
MyZigbeeSwitch zbSwitch = MyZigbeeSwitch(SWITCH_ENDPOINT_NUMBER);
|
||||
|
||||
/********************* Zigbee functions **************************/
|
||||
static void onZbButton(SwitchData *button_func_pair) {
|
||||
if (button_func_pair->func == SWITCH_ONOFF_TOGGLE_CONTROL) {
|
||||
// Send toggle command to the light
|
||||
zbSwitch.lightToggle();
|
||||
}
|
||||
}
|
||||
|
||||
/********************* GPIO functions **************************/
|
||||
static QueueHandle_t gpio_evt_queue = NULL;
|
||||
|
||||
static void IRAM_ATTR onGpioInterrupt(void *arg) {
|
||||
xQueueSendFromISR(gpio_evt_queue, (SwitchData *)arg, NULL);
|
||||
}
|
||||
|
||||
static void enableGpioInterrupt(bool enabled) {
|
||||
for (int i = 0; i < PAIR_SIZE(buttonFunctionPair); ++i) {
|
||||
if (enabled) {
|
||||
enableInterrupt((buttonFunctionPair[i]).pin);
|
||||
} else {
|
||||
disableInterrupt((buttonFunctionPair[i]).pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************* Arduino functions **************************/
|
||||
void setup() {
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
//Optional: set Zigbee device name and model
|
||||
zbSwitch.setManufacturerAndModel("Espressif", "ZigbeeSwitch");
|
||||
|
||||
//Optional to allow multiple light to bind to the switch
|
||||
zbSwitch.allowMultipleBinding(true);
|
||||
|
||||
//Add endpoint to Zigbee Core
|
||||
log_d("Adding ZigbeeSwitch endpoint to Zigbee Core");
|
||||
Zigbee.addEndpoint(&zbSwitch);
|
||||
|
||||
//Open network for 180 seconds after boot
|
||||
Zigbee.setRebootOpenNetwork(180);
|
||||
|
||||
|
||||
// Init button switch
|
||||
for (int i = 0; i < PAIR_SIZE(buttonFunctionPair); i++) {
|
||||
pinMode(buttonFunctionPair[i].pin, INPUT_PULLUP);
|
||||
/* create a queue to handle gpio event from isr */
|
||||
gpio_evt_queue = xQueueCreate(10, sizeof(SwitchData));
|
||||
if (gpio_evt_queue == 0) {
|
||||
log_e("Queue was not created and must not be used");
|
||||
while (1);
|
||||
}
|
||||
attachInterruptArg(buttonFunctionPair[i].pin, onGpioInterrupt, (void *)(buttonFunctionPair + i), FALLING);
|
||||
}
|
||||
|
||||
// When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
|
||||
log_d("Calling Zigbee.begin()");
|
||||
Zigbee.begin(ZIGBEE_COORDINATOR);
|
||||
|
||||
Serial.println("Waiting for Light to bound to the switch");
|
||||
//Wait for switch to bound to a light:
|
||||
while(!zbSwitch.isBound())
|
||||
{
|
||||
Serial.printf(".");
|
||||
delay(500);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Handle button switch in loop()
|
||||
uint8_t pin = 0;
|
||||
SwitchData buttonSwitch;
|
||||
static SwitchState buttonState = SWITCH_IDLE;
|
||||
bool eventFlag = false;
|
||||
|
||||
|
||||
/* check if there is any queue received, if yes read out the buttonSwitch */
|
||||
if (xQueueReceive(gpio_evt_queue, &buttonSwitch, portMAX_DELAY)) {
|
||||
pin = buttonSwitch.pin;
|
||||
enableGpioInterrupt(false);
|
||||
eventFlag = true;
|
||||
}
|
||||
while (eventFlag) {
|
||||
bool value = digitalRead(pin);
|
||||
switch (buttonState) {
|
||||
case SWITCH_IDLE: buttonState = (value == LOW) ? SWITCH_PRESS_DETECTED : SWITCH_IDLE; break;
|
||||
case SWITCH_PRESS_DETECTED: buttonState = (value == LOW) ? SWITCH_PRESS_DETECTED : SWITCH_RELEASE_DETECTED; break;
|
||||
case SWITCH_RELEASE_DETECTED:
|
||||
buttonState = SWITCH_IDLE;
|
||||
/* callback to button_handler */
|
||||
(*onZbButton)(&buttonSwitch);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (buttonState == SWITCH_IDLE) {
|
||||
enableGpioInterrupt(true);
|
||||
eventFlag = false;
|
||||
break;
|
||||
}
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
// print the bound lights every 10 seconds
|
||||
static uint32_t lastPrint = 0;
|
||||
if (millis() - lastPrint > 10000) {
|
||||
lastPrint = millis();
|
||||
zbSwitch.printBoundDevices();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -0,0 +1,2 @@
|
||||
.pio
|
||||
.vscode
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
add_compile_definitions(ARDUINO_ARCH_ESP32=1)
|
||||
project(Arduino_IDF_BLE_scan)
|
||||
@@ -0,0 +1,7 @@
|
||||
# Arduino_IDF_BLE_scan example using 3rd party NimBLE stack
|
||||
|
||||
BLE scan example, using the great h2zero NimBLE implementation. The needed NimBLE lib is loaded via the IDF component manager -> `idf_component.yml`.
|
||||
Mandantory not to forget to switch Arduino included BLE libs.
|
||||
Done in `sdkconfig.defaults`
|
||||
|
||||
Thx @h2zero for the great BLE library.
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -0,0 +1,27 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
monitor_speed = 115200
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
lib_ignore =
|
||||
BLE
|
||||
BluetoothSerial
|
||||
SimpleBLE
|
||||
WiFiProv
|
||||
|
||||
[env:esp32]
|
||||
board = esp32dev
|
||||
@@ -0,0 +1,34 @@
|
||||
# CONFIG_AUTOSTART_ARDUINO is not set
|
||||
# CONFIG_WS2812_LED_ENABLE is not set
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_MBEDTLS_PSK_MODES=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||
|
||||
# Override some defaults so BT stack is enabled
|
||||
# in this example
|
||||
#
|
||||
# BT config
|
||||
#
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
CONFIG_BT_BLUEDROID_ENABLED=n
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
|
||||
#
|
||||
# Arduino Configuration
|
||||
#
|
||||
#
|
||||
# Disable all Arduino included BLE libraries
|
||||
#
|
||||
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
|
||||
# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
|
||||
# end of Arduino Configuration
|
||||
@@ -0,0 +1,6 @@
|
||||
# This file was automatically generated for projects
|
||||
# without default 'CMakeLists.txt' file.
|
||||
|
||||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources})
|
||||
@@ -0,0 +1,40 @@
|
||||
dependencies:
|
||||
# Required IDF version
|
||||
idf: ">=4.4"
|
||||
|
||||
esp-nimble-cpp:
|
||||
git: https://github.com/h2zero/esp-nimble-cpp.git
|
||||
|
||||
|
||||
# # Defining a dependency from the registry:
|
||||
# # https://components.espressif.com/component/example/cmp
|
||||
# example/cmp: "^3.3.3" # Automatically update minor releases
|
||||
#
|
||||
# # Other ways to define dependencies
|
||||
#
|
||||
# # For components maintained by Espressif only name can be used.
|
||||
# # Same as `espressif/cmp`
|
||||
# component: "~1.0.0" # Automatically update bugfix releases
|
||||
#
|
||||
# # Or in a longer form with extra parameters
|
||||
# component2:
|
||||
# version: ">=2.0.0"
|
||||
#
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect for the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
#
|
||||
# # For components hosted on non-default registry:
|
||||
# service_url: "https://componentregistry.company.com"
|
||||
#
|
||||
# # For components in git repository:
|
||||
# test_component:
|
||||
# path: test_component
|
||||
# git: ssh://git@gitlab.com/user/components.git
|
||||
#
|
||||
# # For test projects during component development
|
||||
# # components can be used from a local directory
|
||||
# # with relative or absolute path
|
||||
# some_local_component:
|
||||
# path: ../../projects/component
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
|
||||
Ported to Arduino ESP32 by Evandro Copercini
|
||||
Refactored back to IDF by H2zero
|
||||
*/
|
||||
|
||||
/** NimBLE differences highlighted in comment blocks **/
|
||||
|
||||
/*******original********
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEUtils.h>
|
||||
#include <BLEScan.h>
|
||||
#include <BLEAdvertisedDevice.h>
|
||||
***********************/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <NimBLEDevice.h>
|
||||
|
||||
extern "C"{void app_main(void);}
|
||||
|
||||
int scanTime = 5 * 1000; // In milliseconds, 0 = scan forever
|
||||
BLEScan* pBLEScan;
|
||||
|
||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||
void onResult(BLEAdvertisedDevice* advertisedDevice) {
|
||||
printf("Advertised Device: %s \n", advertisedDevice->toString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
void scanTask (void * parameter){
|
||||
for(;;) {
|
||||
// put your main code here, to run repeatedly:
|
||||
BLEScanResults foundDevices = pBLEScan->getResults(scanTime, false);
|
||||
printf("Devices found: %d\n", foundDevices.getCount());
|
||||
printf("Scan done!\n");
|
||||
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
|
||||
vTaskDelay(2000/portTICK_PERIOD_MS); // Delay a second between loops.
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
printf("Scanning...\n");
|
||||
|
||||
BLEDevice::init("");
|
||||
pBLEScan = BLEDevice::getScan(); //create new scan
|
||||
pBLEScan->setScanCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
||||
pBLEScan->setInterval(100);
|
||||
pBLEScan->setWindow(99); // less or equal setInterval value
|
||||
xTaskCreate(scanTask, "scanTask", 5000, NULL, 1, NULL);
|
||||
}
|
||||
@@ -11,14 +11,17 @@
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
board_build.filesystem = littlefs
|
||||
board_build.partitions = partitions_custom.csv
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
board_build.filesystem = littlefs
|
||||
board_build.partitions = partitions_custom.csv
|
||||
[env:esp32-c2-devkitm-1]
|
||||
board = esp32-c2-devkitm-1
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(PROJECT_VER "1.0")
|
||||
set(PROJECT_VER_NUMBER 1)
|
||||
|
||||
project(matter-light)
|
||||
|
||||
|
||||
# WARNING: This is just an example for using key for decrypting the encrypted OTA image
|
||||
# Please do not use it as is.
|
||||
if(CONFIG_ENABLE_ENCRYPTED_OTA)
|
||||
target_add_binary_data(light.elf "esp_image_encryption_key.pem" TEXT)
|
||||
endif()
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32C2)
|
||||
include(relinker)
|
||||
endif()
|
||||
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
|
||||
# For RISCV chips, project_include.cmake sets -Wno-format, but does not clear various
|
||||
# flags that depend on -Wformat
|
||||
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND)
|
||||
@@ -0,0 +1,68 @@
|
||||
| Supported Targets | ESP32-S3 | ESP32-C3 | ESP32-C6 |
|
||||
| ----------------- | -------- | -------- | -------- |
|
||||
|
||||
|
||||
# Managed Component Light
|
||||
|
||||
This example is configured by default to work with the ESP32-S3, which has the RGB LED GPIO set as pin 48 and the BOOT button on GPIO 0.
|
||||
|
||||
This example creates a Color Temperature Light device using the esp_matter component downloaded from the [Espressif Component Registry](https://components.espressif.com/) instead of an extra component locally, so the example can work without setting up the esp-matter environment.
|
||||
|
||||
See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about building and flashing the firmware.
|
||||
|
||||
The code is based on the Arduino API and uses Arduino as an IDF Component.
|
||||
|
||||
## How to use it
|
||||
|
||||
Once the device runs for the first time, it must be commissioned to the Matter Fabric of the available Matter Environment.
|
||||
Possible Matter Environments are:
|
||||
- Amazon Alexa
|
||||
- Google Home Assistant (*)
|
||||
- Apple Home
|
||||
- Open Source Home Assistant
|
||||
|
||||
(*) Google Home Assistant requires the user to set up a Matter Light using the [Google Home Developer Console](https://developers.home.google.com/codelabs/matter-device#2). It is necessary to create a Matter Light device with VID = 0xFFF1 and PID = 0x8000. Otherwise, the Light won't show up in the GHA APP. This action is necessary because the Firmware uses Testing credentials and Google requires the user to create the testing device before using it.
|
||||
|
||||
There is no QR Code to be used when the Smartphone APP wants to add the Matter Device.
|
||||
Please enter the code manually: `34970112332`
|
||||
|
||||
The devboard has a built-in LED that will be used as the Matter Light.
|
||||
The default setting of the code uses pin 48 for the ESP32-S3.
|
||||
Please change it in `main/matter_accessory_driver.h` or in the `sdkconfig.defaults.<SOC>` file.
|
||||
|
||||
## LED Status and Factory Mode
|
||||
|
||||
The WS2812b built-in LED will turn purple as soon as the device is flashed and runs for the first time.
|
||||
The purple color indicates that the Matter Accessory has not been commissioned yet.
|
||||
After using a Matter provider Smartphone APP to add a Matter device to your Home Application, it may turn orange to indicate that it has no WiFi connection.
|
||||
|
||||
Once it connects to the WiFi network, the LED will turn white to indicate that Matter is working and the device is connected to the Matter Environment.
|
||||
Please note that Matter over WiFi using an ESP32 device will connect to a 2.4GHz WiFi SSID, therefore the Commissioner APP Smartphone shall be connected to this SSID.
|
||||
|
||||
The Matter and WiFi configuration will be stored in NVS to ensure that it will connect to the Matter Fabric and WiFi Network again once it is reset.
|
||||
|
||||
The Matter Smartphone APP will control the light state (ON/OFF), temperature (Warm/Cold White), and brightness.
|
||||
|
||||
## On Board Light toggle button
|
||||
|
||||
The built-in BOOT button will toggle On/Off and replicate the new state to the Matter Environment, making it visible in the Matter Smartphone APP as well.
|
||||
|
||||
## Returning to the Factory State
|
||||
|
||||
Holding the BOOT button pressed for more than 10 seconds and then releasing it will erase all Matter and WiFi configuration, forcing it to reset to factory state. After that, the device needs to be commissioned again. Previous setups done in the Smartphone APP won't work again; therefore, the virtual device shall be removed from the APP.
|
||||
|
||||
## Building the Application using WiFi and Matter
|
||||
|
||||
Use ESP-IDF 5.1.4 from https://github.com/espressif/esp-idf/tree/release/v5.1
|
||||
This example has been tested with Arduino Core 3.0.4
|
||||
|
||||
There is a configuration file for these SoC: esp32s3, esp32c3, esp32c6.
|
||||
Those are the tested devices that have a WS2812 RGB LED and can run BLE, WiFi and Matter.
|
||||
|
||||
In case it is necessary to change the Button Pin or the REG LED Pin, please use the `menuconfig` and change the Menu Option `Light Matter Accessory`
|
||||
|
||||
## Using OpenThread with Matter
|
||||
|
||||
This is possible with the ESP32-C6.
|
||||
It is neessasy to have a Thread Border Routed in the Matter Environment. Check you matter hardware provider.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -0,0 +1,9 @@
|
||||
# This file was automatically generated for projects
|
||||
# without default 'CMakeLists.txt' file.
|
||||
|
||||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/main/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources})
|
||||
|
||||
#set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
|
||||
#target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
|
||||
@@ -0,0 +1,102 @@
|
||||
menu "Light Matter Accessory"
|
||||
menu "On Board Light ON/OFF Button"
|
||||
config BUTTON_PIN
|
||||
int
|
||||
prompt "Button 1 GPIO"
|
||||
default ENV_GPIO_BOOT_BUTTON
|
||||
range -1 ENV_GPIO_IN_RANGE_MAX
|
||||
help
|
||||
The GPIO pin for button that will be used to turn on/off the Matter Light. It shall be connected to a push button. It can use the BOOT button of the development board.
|
||||
endmenu
|
||||
|
||||
|
||||
menu "LEDs"
|
||||
config WS2812_PIN
|
||||
int
|
||||
prompt "WS2812 RGB LED GPIO"
|
||||
default ENV_GPIO_RGB_LED
|
||||
range -1 ENV_GPIO_OUT_RANGE_MAX
|
||||
help
|
||||
The GPIO pin for the Matter Light that will be driven by RMT. It shall be connected to one single WS2812 RGB LED.
|
||||
endmenu
|
||||
|
||||
# TARGET CONFIGURATION
|
||||
if IDF_TARGET_ESP32C3
|
||||
config ENV_GPIO_RANGE_MIN
|
||||
int
|
||||
default 0
|
||||
|
||||
config ENV_GPIO_RANGE_MAX
|
||||
int
|
||||
default 19
|
||||
# GPIOs 20/21 are always used by UART in examples
|
||||
|
||||
config ENV_GPIO_IN_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_OUT_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_BOOT_BUTTON
|
||||
int
|
||||
default 9
|
||||
|
||||
config ENV_GPIO_RGB_LED
|
||||
int
|
||||
default 8
|
||||
endif
|
||||
if IDF_TARGET_ESP32C6
|
||||
config ENV_GPIO_RANGE_MIN
|
||||
int
|
||||
default 0
|
||||
|
||||
config ENV_GPIO_RANGE_MAX
|
||||
int
|
||||
default 30
|
||||
# GPIOs 16/17 are always used by UART in examples
|
||||
|
||||
config ENV_GPIO_IN_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_OUT_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_BOOT_BUTTON
|
||||
int
|
||||
default 9
|
||||
|
||||
config ENV_GPIO_RGB_LED
|
||||
int
|
||||
default 8
|
||||
endif
|
||||
if IDF_TARGET_ESP32S3
|
||||
config ENV_GPIO_RANGE_MIN
|
||||
int
|
||||
default 0
|
||||
|
||||
config ENV_GPIO_RANGE_MAX
|
||||
int
|
||||
default 48
|
||||
|
||||
config ENV_GPIO_IN_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_OUT_RANGE_MAX
|
||||
int
|
||||
default ENV_GPIO_RANGE_MAX
|
||||
|
||||
config ENV_GPIO_BOOT_BUTTON
|
||||
int
|
||||
default 0
|
||||
|
||||
config ENV_GPIO_RGB_LED
|
||||
int
|
||||
default 48
|
||||
endif
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
This will implement the onboard WS2812b LED as a LED indicator
|
||||
It can be used to indicate some state or status of the device
|
||||
The LED can be controlled using RGB, HSV or color temperature, brightness
|
||||
|
||||
In this example, the LED Indicator class is used as the Matter light accessory
|
||||
*/
|
||||
|
||||
#include "builtinLED.h"
|
||||
|
||||
typedef struct {
|
||||
uint16_t hue;
|
||||
uint8_t saturation;
|
||||
} HS_color_t;
|
||||
|
||||
static const HS_color_t temperatureTable[] = {
|
||||
{4, 100}, {8, 100}, {11, 100}, {14, 100}, {16, 100}, {18, 100}, {20, 100}, {22, 100}, {24, 100}, {25, 100},
|
||||
{27, 100}, {28, 100}, {30, 100}, {31, 100}, {31, 95}, {30, 89}, {30, 85}, {29, 80}, {29, 76}, {29, 73},
|
||||
{29, 69}, {28, 66}, {28, 63}, {28, 60}, {28, 57}, {28, 54}, {28, 52}, {27, 49}, {27, 47}, {27, 45},
|
||||
{27, 43}, {27, 41}, {27, 39}, {27, 37}, {27, 35}, {27, 33}, {27, 31}, {27, 30}, {27, 28}, {27, 26},
|
||||
{27, 25}, {27, 23}, {27, 22}, {27, 21}, {27, 19}, {27, 18}, {27, 17}, {27, 15}, {28, 14}, {28, 13},
|
||||
{28, 12}, {29, 10}, {29, 9}, {30, 8}, {31, 7}, {32, 6}, {34, 5}, {36, 4}, {41, 3}, {49, 2},
|
||||
{0, 0}, {294, 2}, {265, 3}, {251, 4}, {242, 5}, {237, 6}, {233, 7}, {231, 8}, {229, 9}, {228, 10},
|
||||
{227, 11}, {226, 11}, {226, 12}, {225, 13}, {225, 13}, {224, 14}, {224, 14}, {224, 15}, {224, 15}, {223, 16},
|
||||
{223, 16}, {223, 17}, {223, 17}, {223, 17}, {222, 18}, {222, 18}, {222, 19}, {222, 19}, {222, 19}, {222, 19},
|
||||
{222, 20}, {222, 20}, {222, 20}, {222, 21}, {222, 21}
|
||||
};
|
||||
|
||||
/* step brightness table: gamma = 2.3 */
|
||||
static const uint8_t gamma_table[MAX_PROGRESS] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
||||
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5,
|
||||
5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
|
||||
10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17,
|
||||
17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 25, 25, 26,
|
||||
26, 27, 28, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 36, 37,
|
||||
38, 39, 40, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
|
||||
68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 86,
|
||||
87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107,
|
||||
108, 110, 111, 112, 114, 115, 117, 118, 120, 121, 123, 124, 126, 128, 129, 131,
|
||||
132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 149, 150, 152, 154, 156, 157,
|
||||
159, 161, 163, 164, 166, 168, 170, 172, 174, 175, 177, 179, 181, 183, 185, 187,
|
||||
189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219,
|
||||
221, 223, 226, 228, 230, 232, 234, 236, 239, 241, 243, 245, 248, 250, 252, 255,
|
||||
};
|
||||
|
||||
BuiltInLED::BuiltInLED() {
|
||||
pin_number = (uint8_t) -1; // no pin number
|
||||
state = false; // LED is off
|
||||
hsv_color.value = 0; // black color
|
||||
}
|
||||
|
||||
BuiltInLED::~BuiltInLED(){
|
||||
end();
|
||||
}
|
||||
|
||||
led_indicator_color_hsv_t BuiltInLED::rgb2hsv(led_indicator_color_rgb_t rgb) {
|
||||
led_indicator_color_hsv_t hsv;
|
||||
uint8_t minRGB, maxRGB;
|
||||
uint8_t delta;
|
||||
|
||||
minRGB = rgb.r < rgb.g ? (rgb.r < rgb.b ? rgb.r : rgb.b) : (rgb.g < rgb.b ? rgb.g : rgb.b);
|
||||
maxRGB = rgb.r > rgb.g ? (rgb.r > rgb.b ? rgb.r : rgb.b) : (rgb.g > rgb.b ? rgb.g : rgb.b);
|
||||
hsv.value = 0;
|
||||
hsv.v = maxRGB;
|
||||
delta = maxRGB - minRGB;
|
||||
|
||||
if (delta == 0) {
|
||||
hsv.h = 0;
|
||||
hsv.s = 0;
|
||||
} else {
|
||||
hsv.s = delta * 255 / maxRGB;
|
||||
|
||||
if (rgb.r == maxRGB) {
|
||||
hsv.h = (60 * (rgb.g - rgb.b) / delta + 360) % 360;
|
||||
} else if (rgb.g == maxRGB) {
|
||||
hsv.h = (60 * (rgb.b - rgb.r) / delta + 120);
|
||||
} else {
|
||||
hsv.h = (60 * (rgb.r - rgb.g) / delta + 240);
|
||||
}
|
||||
}
|
||||
return hsv;
|
||||
}
|
||||
|
||||
led_indicator_color_rgb_t BuiltInLED::hsv2rgb(led_indicator_color_hsv_t hsv) {
|
||||
led_indicator_color_rgb_t rgb;
|
||||
uint8_t rgb_max = hsv.v;
|
||||
uint8_t rgb_min = rgb_max * (255 - hsv.s) / 255.0f;
|
||||
|
||||
uint8_t i = hsv.h / 60;
|
||||
uint8_t diff = hsv.h % 60;
|
||||
|
||||
// RGB adjustment amount by hue
|
||||
uint8_t rgb_adj = (rgb_max - rgb_min) * diff / 60;
|
||||
rgb.value = 0;
|
||||
switch (i) {
|
||||
case 0:
|
||||
rgb.r = rgb_max;
|
||||
rgb.g = rgb_min + rgb_adj;
|
||||
rgb.b = rgb_min;
|
||||
break;
|
||||
case 1:
|
||||
rgb.r = rgb_max - rgb_adj;
|
||||
rgb.g = rgb_max;
|
||||
rgb.b = rgb_min;
|
||||
break;
|
||||
case 2:
|
||||
rgb.r = rgb_min;
|
||||
rgb.g = rgb_max;
|
||||
rgb.b = rgb_min + rgb_adj;
|
||||
break;
|
||||
case 3:
|
||||
rgb.r = rgb_min;
|
||||
rgb.g = rgb_max - rgb_adj;
|
||||
rgb.b = rgb_max;
|
||||
break;
|
||||
case 4:
|
||||
rgb.r = rgb_min + rgb_adj;
|
||||
rgb.g = rgb_min;
|
||||
rgb.b = rgb_max;
|
||||
break;
|
||||
default:
|
||||
rgb.r = rgb_max;
|
||||
rgb.g = rgb_min;
|
||||
rgb.b = rgb_max - rgb_adj;
|
||||
break;
|
||||
}
|
||||
|
||||
// gamma correction
|
||||
rgb.r = gamma_table[rgb.r];
|
||||
rgb.g = gamma_table[rgb.g];
|
||||
rgb.b = gamma_table[rgb.b];
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void BuiltInLED::begin(uint8_t pin){
|
||||
if (pin < NUM_DIGITAL_PINS) {
|
||||
pin_number = pin;
|
||||
log_i("Initializing pin %d", pin);
|
||||
} else {
|
||||
log_e("Invalid pin (%d) number", pin);
|
||||
}
|
||||
}
|
||||
void BuiltInLED::end(){
|
||||
state = false;
|
||||
write(); // turn off the LED
|
||||
if (pin_number < NUM_DIGITAL_PINS) {
|
||||
if (!rmtDeinit(pin_number)) {
|
||||
log_e("Failed to deinitialize RMT");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BuiltInLED::on(){
|
||||
state = true;
|
||||
}
|
||||
|
||||
void BuiltInLED::off(){
|
||||
state = false;
|
||||
}
|
||||
|
||||
void BuiltInLED::toggle(){
|
||||
state = !state;
|
||||
}
|
||||
|
||||
bool BuiltInLED::getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
bool BuiltInLED::write(){
|
||||
led_indicator_color_rgb_t rgb_color = getRGB();
|
||||
log_d("Writing to pin %d with state = %s", pin_number, state ? "ON" : "OFF");
|
||||
log_d("HSV: %d, %d, %d", hsv_color.h, hsv_color.s, hsv_color.v);
|
||||
log_d("RGB: %d, %d, %d", rgb_color.r, rgb_color.g, rgb_color.b);
|
||||
if(pin_number < NUM_DIGITAL_PINS){
|
||||
if (state) {
|
||||
rgbLedWrite(pin_number, rgb_color.r, rgb_color.g, rgb_color.b);
|
||||
} else {
|
||||
rgbLedWrite(pin_number, 0, 0, 0);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
log_e("Invalid pin (%d) number", pin_number);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void BuiltInLED::setBrightness(uint8_t brightness){
|
||||
hsv_color.v = brightness;
|
||||
}
|
||||
|
||||
uint8_t BuiltInLED::getBrightness(){
|
||||
return hsv_color.v;
|
||||
}
|
||||
|
||||
void BuiltInLED::setHSV(led_indicator_color_hsv_t hsv){
|
||||
if (hsv.h > MAX_HUE) {
|
||||
hsv.h = MAX_HUE;
|
||||
}
|
||||
hsv_color.value = hsv.value;
|
||||
}
|
||||
|
||||
led_indicator_color_hsv_t BuiltInLED::getHSV(){
|
||||
return hsv_color;
|
||||
}
|
||||
|
||||
void BuiltInLED::setRGB(led_indicator_color_rgb_t rgb_color){
|
||||
hsv_color = rgb2hsv(rgb_color);
|
||||
}
|
||||
|
||||
led_indicator_color_rgb_t BuiltInLED::getRGB(){
|
||||
return hsv2rgb(hsv_color);
|
||||
}
|
||||
|
||||
void BuiltInLED::setTemperature(uint32_t temperature){
|
||||
uint16_t hue;
|
||||
uint8_t saturation;
|
||||
|
||||
log_d("Requested Temperature: %ld", temperature);
|
||||
//hsv_color.v = gamma_table[((temperature >> 25) & 0x7F)];
|
||||
temperature &= 0xFFFFFF;
|
||||
if (temperature < 600) {
|
||||
hue = 0;
|
||||
saturation = 100;
|
||||
} else {
|
||||
if (temperature > 10000) {
|
||||
hue = 222;
|
||||
saturation = 21 + (temperature - 10000) * 41 / 990000;
|
||||
} else {
|
||||
temperature -= 600;
|
||||
temperature /= 100;
|
||||
hue = temperatureTable[temperature].hue;
|
||||
saturation = temperatureTable[temperature].saturation;
|
||||
}
|
||||
}
|
||||
saturation = (saturation * 255) / 100;
|
||||
// brightness is not changed
|
||||
hsv_color.h = hue;
|
||||
hsv_color.s = saturation;
|
||||
log_d("Calculated Temperature: %ld, Hue: %d, Saturation: %d, Brightness: %d", temperature, hue, saturation, hsv_color.v);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
This will implement the onboard WS2812b LED as a LED indicator
|
||||
It can be used to indicate some state or status of the device
|
||||
The LED can be controlled using RGB, HSV or color temperature, brightness
|
||||
|
||||
In this example, the BuiltInLED class is used as the Matter light accessory
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define MAX_HUE 360
|
||||
#define MAX_SATURATION 255
|
||||
#define MAX_BRIGHTNESS 255
|
||||
#define MAX_PROGRESS 256
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t v: 8; /*!< Brightness/Value of the LED. 0-255 */
|
||||
uint32_t s: 8; /*!< Saturation of the LED. 0-255 */
|
||||
uint32_t h: 9; /*!< Hue of the LED. 0-360 */
|
||||
};
|
||||
uint32_t value; /*!< IHSV value of the LED. */
|
||||
};
|
||||
} led_indicator_color_hsv_t;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t r: 8; /*!< Red component of the LED color. Range: 0-255. */
|
||||
uint32_t g: 8; /*!< Green component of the LED color. Range: 0-255. */
|
||||
uint32_t b: 8; /*!< Blue component of the LED color. Range: 0-255. */
|
||||
};
|
||||
uint32_t value; /*!< Combined RGB value of the LED color. */
|
||||
};
|
||||
} led_indicator_color_rgb_t;
|
||||
|
||||
class BuiltInLED {
|
||||
private:
|
||||
uint8_t pin_number;
|
||||
bool state;
|
||||
led_indicator_color_hsv_t hsv_color;
|
||||
|
||||
public:
|
||||
BuiltInLED();
|
||||
~BuiltInLED();
|
||||
|
||||
static led_indicator_color_hsv_t rgb2hsv(led_indicator_color_rgb_t rgb_value);
|
||||
static led_indicator_color_rgb_t hsv2rgb(led_indicator_color_hsv_t hsv);
|
||||
|
||||
void begin(uint8_t pin);
|
||||
void end();
|
||||
|
||||
void on();
|
||||
void off();
|
||||
void toggle();
|
||||
bool getState();
|
||||
|
||||
bool write();
|
||||
|
||||
void setBrightness(uint8_t brightness);
|
||||
uint8_t getBrightness();
|
||||
void setHSV(led_indicator_color_hsv_t hsv);
|
||||
led_indicator_color_hsv_t getHSV();
|
||||
void setRGB(led_indicator_color_rgb_t color);
|
||||
led_indicator_color_rgb_t getRGB();
|
||||
void setTemperature(uint32_t temperature);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
espressif/esp_matter:
|
||||
version: "^1.3.0"
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_matter_attribute_utils.h>
|
||||
#include "builtinLED.h"
|
||||
#include "matter_accessory_driver.h"
|
||||
|
||||
/* Do any conversions/remapping for the actual value here */
|
||||
esp_err_t light_accessory_set_power(void *led, uint8_t val)
|
||||
{
|
||||
BuiltInLED *builtinLED = (BuiltInLED *) led;
|
||||
esp_err_t err = ESP_OK;
|
||||
if (val) {
|
||||
builtinLED->on();
|
||||
} else {
|
||||
builtinLED->off();
|
||||
}
|
||||
if (!builtinLED->write()) {
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
log_i("LED set power: %d", val);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t light_accessory_set_brightness(void *led, uint8_t val)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
BuiltInLED *builtinLED = (BuiltInLED *) led;
|
||||
int value = REMAP_TO_RANGE(val, MATTER_BRIGHTNESS, STANDARD_BRIGHTNESS);
|
||||
|
||||
builtinLED->setBrightness(value);
|
||||
if (!builtinLED->write()) {
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
log_i("LED set brightness: %d", value);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t light_accessory_set_hue(void *led, uint8_t val)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
BuiltInLED *builtinLED = (BuiltInLED *) led;
|
||||
int value = REMAP_TO_RANGE(val, MATTER_HUE, STANDARD_HUE);
|
||||
led_indicator_color_hsv_t hsv = builtinLED->getHSV();
|
||||
hsv.h = value;
|
||||
builtinLED->setHSV(hsv);
|
||||
if (!builtinLED->write()) {
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
log_i("LED set hue: %d", value);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t light_accessory_set_saturation(void *led, uint8_t val)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
BuiltInLED *builtinLED = (BuiltInLED *) led;
|
||||
int value = REMAP_TO_RANGE(val, MATTER_SATURATION, STANDARD_SATURATION);
|
||||
led_indicator_color_hsv_t hsv = builtinLED->getHSV();
|
||||
hsv.s = value;
|
||||
builtinLED->setHSV(hsv);
|
||||
if (!builtinLED->write()) {
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
log_i("LED set saturation: %d", value);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t light_accessory_set_temperature(void *led, uint16_t val)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
BuiltInLED *builtinLED = (BuiltInLED *) led;
|
||||
uint32_t value = REMAP_TO_RANGE_INVERSE(val, STANDARD_TEMPERATURE_FACTOR);
|
||||
builtinLED->setTemperature(value);
|
||||
if (!builtinLED->write()) {
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
log_i("LED set temperature: %ld", value);
|
||||
return err;
|
||||
}
|
||||
|
||||
app_driver_handle_t light_accessory_init()
|
||||
{
|
||||
/* Initialize led */
|
||||
static BuiltInLED builtinLED;
|
||||
|
||||
const uint8_t pin = WS2812_PIN; // set your board WS2812b pin here
|
||||
builtinLED.begin(pin);
|
||||
return (app_driver_handle_t) &builtinLED;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <esp_err.h>
|
||||
#include <sdkconfig.h>
|
||||
|
||||
// set your board WS2812b pin here (e.g. 48 is the default pin for the ESP32-S3 devkit)
|
||||
#ifndef CONFIG_WS2812_PIN
|
||||
#define WS2812_PIN 48 // ESP32-S3 DevKitC built-in LED
|
||||
#else
|
||||
#define WS2812_PIN CONFIG_WS2812_PIN // From sdkconfig.defaults.<soc>
|
||||
#endif
|
||||
|
||||
#ifndef RGB_BUILTIN
|
||||
#define RGB_BUILTIN WS2812_PIN
|
||||
#endif
|
||||
|
||||
// Set your board button pin here (e.g. 0 is the default pin for the ESP32-S3 devkit)
|
||||
#ifndef CONFIG_BUTTON_PIN
|
||||
#define BUTTON_PIN 0 // ESP32-S3 DevKitC built-in button
|
||||
#else
|
||||
#define BUTTON_PIN CONFIG_BUTTON_PIN // From sdkconfig.defaults.<soc>
|
||||
#endif
|
||||
|
||||
/** Standard max values (used for remapping attributes) */
|
||||
#define STANDARD_BRIGHTNESS 255
|
||||
#define STANDARD_HUE 360
|
||||
#define STANDARD_SATURATION 255
|
||||
#define STANDARD_TEMPERATURE_FACTOR 1000000
|
||||
|
||||
/** Matter max values (used for remapping attributes) */
|
||||
#define MATTER_BRIGHTNESS 254
|
||||
#define MATTER_HUE 254
|
||||
#define MATTER_SATURATION 254
|
||||
#define MATTER_TEMPERATURE_FACTOR 1000000
|
||||
|
||||
/** Default attribute values used during initialization */
|
||||
#define DEFAULT_POWER true
|
||||
#define DEFAULT_BRIGHTNESS 64
|
||||
#define DEFAULT_HUE 128
|
||||
#define DEFAULT_SATURATION 254
|
||||
|
||||
typedef void *app_driver_handle_t;
|
||||
|
||||
esp_err_t light_accessory_set_power(void *led, uint8_t val);
|
||||
esp_err_t light_accessory_set_brightness(void *led, uint8_t val);
|
||||
esp_err_t light_accessory_set_hue(void *led, uint8_t val);
|
||||
esp_err_t light_accessory_set_saturation(void *led, uint8_t val);
|
||||
esp_err_t light_accessory_set_temperature(void *led, uint16_t val);
|
||||
app_driver_handle_t light_accessory_init();
|
||||
@@ -0,0 +1,421 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include "matter_accessory_driver.h"
|
||||
|
||||
#include <esp_err.h>
|
||||
|
||||
#include <esp_matter.h>
|
||||
#include <esp_matter_console.h>
|
||||
#include <esp_matter_ota.h>
|
||||
|
||||
#include <app/server/CommissioningWindowManager.h>
|
||||
#include <app/server/Server.h>
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
#include <platform/ESP32/OpenthreadLauncher.h>
|
||||
#include "esp_openthread_types.h"
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_NATIVE, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
|
||||
{ \
|
||||
.storage_partition_name = "nvs", .netif_queue_size = 10, .task_queue_size = 10, \
|
||||
}
|
||||
#endif
|
||||
|
||||
// set your board button pin here
|
||||
const uint8_t button_gpio = BUTTON_PIN; // GPIO BOOT Button
|
||||
|
||||
uint16_t light_endpoint_id = 0;
|
||||
|
||||
using namespace esp_matter;
|
||||
using namespace esp_matter::attribute;
|
||||
using namespace esp_matter::endpoint;
|
||||
using namespace chip::app::Clusters;
|
||||
|
||||
constexpr auto k_timeout_seconds = 300;
|
||||
|
||||
#if CONFIG_ENABLE_ENCRYPTED_OTA
|
||||
extern const char decryption_key_start[] asm("_binary_esp_image_encryption_key_pem_start");
|
||||
extern const char decryption_key_end[] asm("_binary_esp_image_encryption_key_pem_end");
|
||||
|
||||
static const char *s_decryption_key = decryption_key_start;
|
||||
static const uint16_t s_decryption_key_len = decryption_key_end - decryption_key_start;
|
||||
#endif // CONFIG_ENABLE_ENCRYPTED_OTA
|
||||
|
||||
bool isAccessoryCommissioned() {
|
||||
return chip::Server::GetInstance().GetFabricTable().FabricCount() > 0;
|
||||
}
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
|
||||
bool isWifiConnected() {
|
||||
return chip::DeviceLayer::ConnectivityMgr().IsWiFiStationConnected();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
bool isThreadConnected() {
|
||||
return chip::DeviceLayer::ConnectivityMgr().IsThreadAttached();
|
||||
}
|
||||
#endif
|
||||
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
switch (event->Type) {
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
log_i("Interface %s Address changed",
|
||||
event->InterfaceIpAddressChanged.Type == chip::DeviceLayer::InterfaceIpChangeType::kIpV4_Assigned ?
|
||||
"IPv4" : "IPV6" );
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
log_i("Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
log_i("Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
log_i("Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
log_i("Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
log_i("Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
log_i("Commissioning window closed");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFabricRemoved:
|
||||
{
|
||||
log_i("Fabric removed successfully");
|
||||
if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0)
|
||||
{
|
||||
chip::CommissioningWindowManager & commissionMgr = chip::Server::GetInstance().GetCommissioningWindowManager();
|
||||
constexpr auto kTimeoutSeconds = chip::System::Clock::Seconds16(k_timeout_seconds);
|
||||
if (!commissionMgr.IsCommissioningWindowOpen())
|
||||
{
|
||||
/* After removing last fabric, this example does not remove the Wi-Fi credentials
|
||||
* and still has IP connectivity so, only advertising on DNS-SD.
|
||||
*/
|
||||
CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds,
|
||||
chip::CommissioningWindowAdvertisement::kDnssdOnly);
|
||||
if (err != CHIP_NO_ERROR)
|
||||
{
|
||||
log_e("Failed to open commissioning window, err:%" CHIP_ERROR_FORMAT, err.Format());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFabricWillBeRemoved:
|
||||
log_i("Fabric will be removed");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFabricUpdated:
|
||||
log_i("Fabric is updated");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFabricCommitted:
|
||||
log_i("Fabric is committed");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kBLEDeinitialized:
|
||||
log_i("BLE deinitialized and memory reclaimed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t matter_light_attribute_update(app_driver_handle_t driver_handle, uint16_t endpoint_id, uint32_t cluster_id,
|
||||
uint32_t attribute_id, esp_matter_attr_val_t *val)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
if (endpoint_id == light_endpoint_id) {
|
||||
void *led = (void *)driver_handle;
|
||||
if (cluster_id == OnOff::Id) {
|
||||
if (attribute_id == OnOff::Attributes::OnOff::Id) {
|
||||
err = light_accessory_set_power(led, val->val.b);
|
||||
}
|
||||
} else if (cluster_id == LevelControl::Id) {
|
||||
if (attribute_id == LevelControl::Attributes::CurrentLevel::Id) {
|
||||
err = light_accessory_set_brightness(led, val->val.u8);
|
||||
}
|
||||
} else if (cluster_id == ColorControl::Id) {
|
||||
if (attribute_id == ColorControl::Attributes::CurrentHue::Id) {
|
||||
err = light_accessory_set_hue(led, val->val.u8);
|
||||
} else if (attribute_id == ColorControl::Attributes::CurrentSaturation::Id) {
|
||||
err = light_accessory_set_saturation(led, val->val.u8);
|
||||
} else if (attribute_id == ColorControl::Attributes::ColorTemperatureMireds::Id) {
|
||||
err = light_accessory_set_temperature(led, val->val.u16);
|
||||
}
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t matter_light_set_defaults(uint16_t endpoint_id)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
void *led = endpoint::get_priv_data(endpoint_id);
|
||||
node_t *node = node::get();
|
||||
endpoint_t *endpoint = endpoint::get(node, endpoint_id);
|
||||
cluster_t *cluster = NULL;
|
||||
attribute_t *attribute = NULL;
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
|
||||
/* Setting brightness */
|
||||
cluster = cluster::get(endpoint, LevelControl::Id);
|
||||
attribute = attribute::get(cluster, LevelControl::Attributes::CurrentLevel::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
err |= light_accessory_set_brightness(led, val.val.u8);
|
||||
|
||||
/* Setting color */
|
||||
cluster = cluster::get(endpoint, ColorControl::Id);
|
||||
attribute = attribute::get(cluster, ColorControl::Attributes::ColorMode::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kCurrentHueAndCurrentSaturation) {
|
||||
/* Setting hue */
|
||||
attribute = attribute::get(cluster, ColorControl::Attributes::CurrentHue::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
err |= light_accessory_set_hue(led, val.val.u8);
|
||||
/* Setting saturation */
|
||||
attribute = attribute::get(cluster, ColorControl::Attributes::CurrentSaturation::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
err |= light_accessory_set_saturation(led, val.val.u8);
|
||||
} else if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kColorTemperature) {
|
||||
/* Setting temperature */
|
||||
attribute = attribute::get(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
err |= light_accessory_set_temperature(led, val.val.u16);
|
||||
} else {
|
||||
log_e("Color mode not supported");
|
||||
}
|
||||
|
||||
/* Setting power */
|
||||
cluster = cluster::get(endpoint, OnOff::Id);
|
||||
attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
err |= light_accessory_set_power(led, val.val.b);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void button_driver_init()
|
||||
{
|
||||
/* Initialize button */
|
||||
pinMode(button_gpio, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
// This callback is called for every attribute update. The callback implementation shall
|
||||
// handle the desired attributes and return an appropriate error code. If the attribute
|
||||
// is not of your interest, please do not return an error code and strictly return ESP_OK.
|
||||
static esp_err_t app_attribute_update_cb(attribute::callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
|
||||
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
if (type == PRE_UPDATE) {
|
||||
/* Driver update */
|
||||
app_driver_handle_t driver_handle = (app_driver_handle_t)priv_data;
|
||||
err = matter_light_attribute_update(driver_handle, endpoint_id, cluster_id, attribute_id, val);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
// This callback is invoked when clients interact with the Identify Cluster.
|
||||
// In the callback implementation, an endpoint can identify itself. (e.g., by flashing an LED or light).
|
||||
static esp_err_t app_identification_cb(identification::callback_type_t type, uint16_t endpoint_id, uint8_t effect_id,
|
||||
uint8_t effect_variant, void *priv_data)
|
||||
{
|
||||
log_i("Identification callback: type: %u, effect: %u, variant: %u", type, effect_id, effect_variant);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
/* Initialize driver */
|
||||
app_driver_handle_t light_handle = light_accessory_init();
|
||||
button_driver_init();
|
||||
|
||||
/* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
|
||||
node::config_t node_config;
|
||||
|
||||
// node handle can be used to add/modify other endpoints.
|
||||
node_t *node = node::create(&node_config, app_attribute_update_cb, app_identification_cb);
|
||||
if (node == nullptr) {
|
||||
log_e("Failed to create Matter node");
|
||||
abort();
|
||||
}
|
||||
|
||||
extended_color_light::config_t light_config;
|
||||
light_config.on_off.on_off = DEFAULT_POWER;
|
||||
light_config.on_off.lighting.start_up_on_off = nullptr;
|
||||
light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
|
||||
light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS;
|
||||
light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
|
||||
light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
|
||||
light_config.color_control.color_temperature.startup_color_temperature_mireds = nullptr;
|
||||
|
||||
// endpoint handles can be used to add/modify clusters.
|
||||
endpoint_t *endpoint = extended_color_light::create(node, &light_config, ENDPOINT_FLAG_NONE, light_handle);
|
||||
if (endpoint == nullptr) {
|
||||
log_e("Failed to create extended color light endpoint");
|
||||
abort();
|
||||
}
|
||||
|
||||
light_endpoint_id = endpoint::get_id(endpoint);
|
||||
log_i("Light created with endpoint_id %d", light_endpoint_id);
|
||||
|
||||
/* Mark deferred persistence for some attributes that might be changed rapidly */
|
||||
cluster_t *level_control_cluster = cluster::get(endpoint, LevelControl::Id);
|
||||
attribute_t *current_level_attribute = attribute::get(level_control_cluster, LevelControl::Attributes::CurrentLevel::Id);
|
||||
attribute::set_deferred_persistence(current_level_attribute);
|
||||
|
||||
cluster_t *color_control_cluster = cluster::get(endpoint, ColorControl::Id);
|
||||
attribute_t *current_x_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentX::Id);
|
||||
attribute::set_deferred_persistence(current_x_attribute);
|
||||
attribute_t *current_y_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentY::Id);
|
||||
attribute::set_deferred_persistence(current_y_attribute);
|
||||
attribute_t *color_temp_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::ColorTemperatureMireds::Id);
|
||||
attribute::set_deferred_persistence(color_temp_attribute);
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
/* Set OpenThread platform config */
|
||||
esp_openthread_platform_config_t config = {
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
|
||||
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
|
||||
};
|
||||
set_openthread_platform_config(&config);
|
||||
#endif
|
||||
|
||||
/* Matter start */
|
||||
err = esp_matter::start(app_event_cb);
|
||||
if (err != ESP_OK) {
|
||||
log_e("Failed to start Matter, err:%d", err);
|
||||
abort();
|
||||
}
|
||||
|
||||
#if CONFIG_ENABLE_ENCRYPTED_OTA
|
||||
err = esp_matter_ota_requestor_encrypted_init(s_decryption_key, s_decryption_key_len);
|
||||
if (err != ESP_OK) {
|
||||
log_e("Failed to initialized the encrypted OTA, err: %d", err);
|
||||
abort();
|
||||
}
|
||||
#endif // CONFIG_ENABLE_ENCRYPTED_OTA
|
||||
|
||||
#if CONFIG_ENABLE_CHIP_SHELL
|
||||
esp_matter::console::diagnostics_register_commands();
|
||||
esp_matter::console::wifi_register_commands();
|
||||
#if CONFIG_OPENTHREAD_CLI
|
||||
esp_matter::console::otcli_register_commands();
|
||||
#endif
|
||||
esp_matter::console::init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
static uint32_t button_time_stamp = 0;
|
||||
static bool button_state = false;
|
||||
static bool started = false;
|
||||
|
||||
if(!isAccessoryCommissioned()) {
|
||||
log_w("Accessory not commissioned yet. Waiting for commissioning.");
|
||||
#ifdef RGB_BUILTIN
|
||||
rgbLedWrite(RGB_BUILTIN, 48, 0, 20); // Purple indicates accessory not commissioned
|
||||
#endif
|
||||
delay(5000);
|
||||
return;
|
||||
}
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
|
||||
if (!isWifiConnected()) {
|
||||
log_w("Wi-Fi not connected yet. Waiting for connection.");
|
||||
#ifdef RGB_BUILTIN
|
||||
rgbLedWrite(RGB_BUILTIN, 48, 20, 0); // Orange indicates accessory not connected to Wi-Fi
|
||||
#endif
|
||||
delay(5000);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
if (!isThreadConnected()) {
|
||||
log_w("Thread not connected yet. Waiting for connection.");
|
||||
#ifdef RGB_BUILTIN
|
||||
rgbLedWrite(RGB_BUILTIN, 0, 20, 48); // Blue indicates accessory not connected to Trhead
|
||||
#endif
|
||||
delay(5000);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Once all network connections are established, the accessory is ready for use
|
||||
// Run it only once
|
||||
if (!started) {
|
||||
log_i("Accessory is commissioned and connected to Wi-Fi. Ready for use.");
|
||||
started = true;
|
||||
// Starting driver with default values
|
||||
matter_light_set_defaults(light_endpoint_id);
|
||||
}
|
||||
|
||||
// Check if the button is pressed and toggle the light right away
|
||||
if (digitalRead(button_gpio) == LOW && !button_state) {
|
||||
// deals with button debounce
|
||||
button_time_stamp = millis(); // record the time while the button is pressed.
|
||||
button_state = true; // pressed.
|
||||
|
||||
// Toggle button is pressed - toggle the light
|
||||
log_i("Toggle button pressed");
|
||||
|
||||
endpoint_t *endpoint = endpoint::get(node::get(), light_endpoint_id);
|
||||
cluster_t *cluster = cluster::get(endpoint, OnOff::Id);
|
||||
attribute_t *attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id);
|
||||
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
attribute::get_val(attribute, &val);
|
||||
val.val.b = !val.val.b;
|
||||
attribute::update(light_endpoint_id, OnOff::Id, OnOff::Attributes::OnOff::Id, &val);
|
||||
}
|
||||
|
||||
// Check if the button is released and handle the factory reset
|
||||
uint32_t time_diff = millis() - button_time_stamp;
|
||||
if (button_state && time_diff > 100 && digitalRead(button_gpio) == HIGH) {
|
||||
button_state = false; // released. It can be pressed again after 100ms debounce.
|
||||
|
||||
// Factory reset is triggered if the button is pressed for more than 10 seconds
|
||||
if (time_diff > 10000) {
|
||||
log_i("Factory reset triggered. Light will retored to factory settings.");
|
||||
esp_matter::factory_reset();
|
||||
}
|
||||
}
|
||||
|
||||
delay(50); // WDT is happier with a delay
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table
|
||||
esp_secure_cert, 0x3F, ,0xd000, 0x2000, encrypted
|
||||
nvs, data, nvs, 0x10000, 0xC000,
|
||||
nvs_keys, data, nvs_keys,, 0x1000, encrypted
|
||||
otadata, data, ota, , 0x2000
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, 0x20000, 0x1E0000,
|
||||
ota_1, app, ota_1, 0x200000, 0x1E0000,
|
||||
fctry, data, nvs, 0x3E0000, 0x6000
|
||||
|
@@ -0,0 +1,28 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
[platformio]
|
||||
src_dir = main
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
board_build.partitions = partitions.csv
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:esp32s3]
|
||||
board = esp32-s3-devkitc-1
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
@@ -0,0 +1,66 @@
|
||||
# Arduino Settings
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
|
||||
# Log Levels
|
||||
# Boot Messages - Log level
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
# Arduino Log Level
|
||||
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE=y
|
||||
# IDF Log Level
|
||||
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
|
||||
|
||||
#enable BT
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
|
||||
#disable BT connection reattempt
|
||||
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
|
||||
|
||||
#enable lwip ipv6 autoconfig
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
|
||||
# Use a custom partition table
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0xC000
|
||||
|
||||
# Disable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
|
||||
#enable lwIP route hooks
|
||||
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
|
||||
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
|
||||
|
||||
# Button
|
||||
CONFIG_BUTTON_PERIOD_TIME_MS=20
|
||||
CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000
|
||||
|
||||
# disable softap by default
|
||||
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
|
||||
|
||||
# Disable DS Peripheral
|
||||
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
|
||||
|
||||
# Use compact attribute storage mode
|
||||
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
|
||||
|
||||
# Enable HKDF in mbedtls
|
||||
CONFIG_MBEDTLS_HKDF_C=y
|
||||
|
||||
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
|
||||
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
|
||||
|
||||
|
||||
# ESP32-S3-DevKitC-1 Settings
|
||||
# Buttons
|
||||
CONFIG_BSP_BUTTONS_NUM=1
|
||||
CONFIG_BSP_BUTTON_1_TYPE_GPIO=y
|
||||
CONFIG_BSP_BUTTON_1_GPIO=0
|
||||
CONFIG_BSP_BUTTON_1_LEVEL=0
|
||||
# LEDs
|
||||
CONFIG_BSP_LEDS_NUM=1
|
||||
CONFIG_BSP_LED_TYPE_RGB=y
|
||||
CONFIG_BSP_LED_RGB_GPIO=48
|
||||
CONFIG_BSP_LED_RGB_BACKEND_RMT=y
|
||||
@@ -0,0 +1,80 @@
|
||||
CONFIG_IDF_TARGET="esp32c6"
|
||||
|
||||
# Arduino Settings
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
|
||||
# Log Levels
|
||||
# Boot Messages - Log level
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
# Arduino Log Level
|
||||
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# IDF Log Level
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
|
||||
# libsodium
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
|
||||
# NIMBLE
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=n
|
||||
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
|
||||
CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n
|
||||
|
||||
# FreeRTOS should use legacy API
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
|
||||
# Enable OpenThread
|
||||
CONFIG_OPENTHREAD_ENABLED=y
|
||||
CONFIG_OPENTHREAD_SRP_CLIENT=y
|
||||
CONFIG_OPENTHREAD_DNS_CLIENT=y
|
||||
CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n
|
||||
CONFIG_OPENTHREAD_LOG_LEVEL_NOTE=y
|
||||
CONFIG_OPENTHREAD_CLI=n
|
||||
|
||||
# Disable lwip ipv6 autoconfig
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=n
|
||||
|
||||
# Use a custom partition table
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
|
||||
# LwIP config for OpenThread
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=8
|
||||
CONFIG_LWIP_MULTICAST_PING=y
|
||||
|
||||
# MDNS platform
|
||||
CONFIG_USE_MINIMAL_MDNS=n
|
||||
CONFIG_ENABLE_EXTENDED_DISCOVERY=y
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=n
|
||||
|
||||
# Disable STA and AP for ESP32C6
|
||||
CONFIG_ENABLE_WIFI_STATION=n
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Enable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
|
||||
# Disable persist subscriptions
|
||||
CONFIG_ENABLE_PERSIST_SUBSCRIPTIONS=n
|
||||
|
||||
# MRP configs
|
||||
CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL_FOR_THREAD=5000
|
||||
CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL_FOR_THREAD=5000
|
||||
CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST_FOR_THREAD=5000
|
||||
CONFIG_MRP_MAX_RETRANS=3
|
||||
|
||||
# Enable HKDF in mbedtls
|
||||
CONFIG_MBEDTLS_HKDF_C=y
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
CONFIG_IDF_TARGET="esp32c3"
|
||||
|
||||
# Arduino Settings
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
|
||||
# Log Levels
|
||||
# Boot Messages - Log level
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
# Arduino Log Level
|
||||
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# IDF Log Level
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
|
||||
#enable BT
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
|
||||
#disable BT connection reattempt
|
||||
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
|
||||
|
||||
#enable lwip ipv6 autoconfig
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
|
||||
# Use a custom partition table
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0xC000
|
||||
|
||||
# Disable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=n
|
||||
|
||||
#enable lwIP route hooks
|
||||
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
|
||||
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
|
||||
|
||||
# disable softap by default
|
||||
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
|
||||
CONFIG_ENABLE_WIFI_STATION=y
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Disable DS Peripheral
|
||||
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
|
||||
|
||||
# Use compact attribute storage mode
|
||||
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
|
||||
|
||||
# Enable HKDF in mbedtls
|
||||
CONFIG_MBEDTLS_HKDF_C=y
|
||||
|
||||
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
|
||||
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
|
||||
@@ -0,0 +1,79 @@
|
||||
CONFIG_IDF_TARGET="esp32c6"
|
||||
|
||||
# Arduino Settings
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
|
||||
# Log Levels
|
||||
# Boot Messages - Log level
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
# Arduino Log Level
|
||||
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# IDF Log Level
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
|
||||
#enable BT
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
|
||||
#disable BT connection reattempt
|
||||
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
|
||||
|
||||
#enable lwip ipv6 autoconfig
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
|
||||
# Use a custom partition table
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0xC000
|
||||
|
||||
# Disable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=n
|
||||
|
||||
#enable lwIP route hooks
|
||||
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
|
||||
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
|
||||
|
||||
# disable softap by default
|
||||
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
|
||||
CONFIG_ENABLE_WIFI_STATION=y
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Disable DS Peripheral
|
||||
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
|
||||
|
||||
# Use compact attribute storage mode
|
||||
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
|
||||
|
||||
# Enable HKDF in mbedtls
|
||||
CONFIG_MBEDTLS_HKDF_C=y
|
||||
|
||||
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
|
||||
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
|
||||
|
||||
# libsodium
|
||||
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
|
||||
|
||||
# NIMBLE
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=n
|
||||
CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70
|
||||
CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=y
|
||||
|
||||
# FreeRTOS should use legacy API
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
|
||||
# Use minimal mDNS
|
||||
CONFIG_USE_MINIMAL_MDNS=y
|
||||
CONFIG_ENABLE_EXTENDED_DISCOVERY=y
|
||||
@@ -0,0 +1,64 @@
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
|
||||
# Arduino Settings
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
|
||||
# Log Levels
|
||||
# Boot Messages - Log level
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
# Arduino Log Level
|
||||
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
|
||||
# IDF Log Level
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
|
||||
|
||||
# Default to 921600 baud when flashing and monitoring device
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
|
||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
|
||||
#enable BT
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
|
||||
#disable BT connection reattempt
|
||||
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
|
||||
|
||||
#enable lwip ipv6 autoconfig
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
|
||||
# Use a custom partition table
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0xC000
|
||||
|
||||
# Disable chip shell
|
||||
CONFIG_ENABLE_CHIP_SHELL=n
|
||||
|
||||
# Enable OTA Requestor
|
||||
CONFIG_ENABLE_OTA_REQUESTOR=n
|
||||
|
||||
#enable lwIP route hooks
|
||||
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
|
||||
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
|
||||
|
||||
# disable softap by default
|
||||
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
|
||||
CONFIG_ENABLE_WIFI_STATION=y
|
||||
CONFIG_ENABLE_WIFI_AP=n
|
||||
|
||||
# Disable DS Peripheral
|
||||
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
|
||||
|
||||
# Use compact attribute storage mode
|
||||
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
|
||||
|
||||
# Enable HKDF in mbedtls
|
||||
CONFIG_MBEDTLS_HKDF_C=y
|
||||
|
||||
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
|
||||
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
|
||||
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
@@ -23,6 +23,11 @@ from platformio.public import PlatformBase, to_unix_path
|
||||
|
||||
|
||||
IS_WINDOWS = sys.platform.startswith("win")
|
||||
# Set Platformio env var to use windows_amd64 for all windows architectures
|
||||
# only windows_amd64 native espressif toolchains are available
|
||||
# needs platformio core >= 6.1.16b2 or pioarduino core 6.1.16+test
|
||||
if IS_WINDOWS:
|
||||
os.environ["PLATFORMIO_SYSTEM_TYPE"] = "windows_amd64"
|
||||
|
||||
|
||||
class Espressif32Platform(PlatformBase):
|
||||
|
||||
Reference in New Issue
Block a user