### Example: Build Light Example on ESP32_custom Platform Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst This sequence of shell commands demonstrates how to set up and build the 'light' example using an external platform named 'ESP32_custom'. It involves copying platform files and modifying configuration. ```bash mkdir $ESP_MATTER_PATH/../platform cp -r $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/src/platform/ESP32 $ESP_MATTER_PATH/../platform/ESP32_custom cp $ESP_MATTER_PATH/examples/common/external_platform/BUILD.gn $ESP_MATTER_PATH/../platform/ESP32_custom cd $ESP_MATTER_PATH/examples/light cp sdkconfig.defaults.ext_plat sdkconfig.defaults idf.py build ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/espressif/esp-matter/blob/main/docs/README.md Installs the necessary Python dependencies for building the documentation. Ensure you have Python and pip installed. ```bash pip install -r requirements.txt ``` -------------------------------- ### Build and Flash Example App Source: https://github.com/espressif/esp-matter/blob/main/tools/test_optional_attributes/README.md Builds and flashes the example application with all clusters enabled. This application is required for testing optional attributes. ```bash cd examples/test_apps/test_optional_attributes idf.py build idf.py flash monitor ``` -------------------------------- ### Install esp-matter-mfg-tool Source: https://github.com/espressif/esp-matter/blob/main/tools/mfg_tool/README.md Install the `esp-matter-mfg-tool` package using pip. ```bash python3 -m pip install esp-matter-mfg-tool ``` -------------------------------- ### Install pre-commit Source: https://github.com/espressif/esp-matter/blob/main/DEVELOPER_GUIDE.md Installs the pre-commit tool using pip. Ensure you have Python 3 and pip available. ```bash python3 -m pip install pre-commit ``` -------------------------------- ### Build and Flash OTBR Example Source: https://github.com/espressif/esp-matter/blob/main/examples/all_device_types_app/README.md Build and flash the example with the 'sdkconfig.defaults.otbr' file to enable OTBR features. Use the specified idf.py commands and replace with the appropriate serial port. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.otbr" set-target esp32s3 build idf.py -p erase-flash flash monitor ``` -------------------------------- ### External Platform Build Configuration Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst This BUILD.gn file example shows how to configure an external platform for Matter, including adding it to the include path and exporting build configurations. ```gn # Example BUILD.gn for ESP32_custom platform import("//build/config/build_args.gni") # Configuration for ESP32_custom platform config("ESP32_custom_include") { include_dirs = [ "../..", # Adjust path as necessary "../../../../connectedhomeip/connectedhomeip/src", "../../../../connectedhomeip/connectedhomeip/src/platform/ESP32", # Include original ESP32 platform headers "..", # Include current platform headers ] } # Export build configurations buildconfig_header("buildconfig") { output = "chip_build_config.h" # Define necessary build configurations here # Example: # defines = [ # "CHIP_DEVICE_CONFIG_ENABLE_WIFI", # ] } # Example target for the platform # This would typically compile the platform-specific code # Example: # source_set("esp32_custom_platform") { # sources = [ # "main.cpp", # # Add other platform-specific source files # ] # include_dirs = [ # ".", # ] # configs = [ ":ESP32_custom_include", "//connectedhomeip/connectedhomeip/src/platform:common_platform_config" ] # public_configs = [ ":buildconfig" ] # } ``` -------------------------------- ### Configure Mode Select Cluster in Light Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Integrates the Mode Select cluster into the light example by adding source and include paths and initializing the StaticSupportedModesManager. ```cpp #include static ModeSelect::StaticSupportedModesManager sStaticSupportedModesManager; { cluster::mode_select::config_t ms_config; cluster_t *ms_cluster = cluster::mode_select::create(endpoint, &ms_config, CLUSTER_FLAG_SERVER); sStaticSupportedModesManager.InitEndpointArray(get_count(node)); ModeSelect::setSupportedModesManager(&sStaticSupportedModesManager); } ``` -------------------------------- ### Install ESP-Matter Python Dependencies Source: https://github.com/espressif/esp-matter/blob/main/docs/en/faq.rst Install required Python dependencies for ESP-Matter examples. Ensure the ESP-IDF environment is sourced before running the installation script. ```bash cd esp-idf source ./export.sh cd esp-matter python3 -m pip install -r requirements.txt # Now examples will build without any error cd examples/... idf.py build ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/espressif/esp-matter/blob/main/DEVELOPER_GUIDE.md Installs the pre-commit hooks into the local repository. This command should be run from the repository root after navigating to the ESP-MATTER_PATH. ```bash cd $ESP_MATTER_PATH pre-commit install ``` -------------------------------- ### Build and Monitor Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Builds the project and starts a serial monitor to observe device output. ```bash idf.py flash monitor ``` -------------------------------- ### Install QEMU via ESP-IDF Tools Source: https://github.com/espressif/esp-matter/blob/main/examples/unit_test_app/README.md Install the QEMU binary for RISC-V (esp32c3) using ESP-IDF tools. Ensure the QEMU binary is available in your PATH by re-sourcing the export script. ```bash $IDF_PATH/tools/idf_tools.py install qemu-riscv32 source $IDF_PATH/export.sh ``` -------------------------------- ### Example of Changing Badge Name and Company Source: https://github.com/espressif/esp-matter/blob/main/examples/demo/badge/README.md An example demonstrating the usage of the `change_name` console command with specific values for name, company, email, contact, and event name. ```sh matter esp change_name "John Doe/Company Name/john.doe@espressif.com/123456789/Special Events" ``` -------------------------------- ### Pairing with Matter Setup Payload Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Use this command to pair a device using a Matter setup payload. The controller discovers the end-device on the IP network. ```bash matter esp controller pairing code ``` -------------------------------- ### Start Matter Stack Source: https://context7.com/espressif/esp-matter/llms.txt Initializes and starts the Matter stack, enabling device advertising for commissioning. Includes an event callback for stack events. ```cpp #include using namespace esp_matter; // Event callback for Matter stack events static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { switch (event->Type) { case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: ESP_LOGI("app", "Commissioning complete - device is now part of Matter fabric"); break; case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened: ESP_LOGI("app", "Commissioning window opened - ready for pairing"); break; case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed: ESP_LOGI("app", "Commissioning window closed"); break; case chip::DeviceLayer::DeviceEventType::kFabricRemoved: ESP_LOGI("app", "Fabric removed - device unpaired"); break; case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged: ESP_LOGI("app", "IP address changed"); break; default: break; } } void start_matter() { // Start Matter stack with event callback esp_err_t err = esp_matter::start(app_event_cb); if (err != ESP_OK) { ESP_LOGE("app", "Failed to start Matter: %d", err); return; } // Check if Matter is running if (esp_matter::is_started()) { ESP_LOGI("app", "Matter stack is running"); } } ``` -------------------------------- ### Install QEMU for RISC-V Source: https://github.com/espressif/esp-matter/blob/main/examples/unit_test_app/README.md Install the necessary QEMU package for RISC-V emulation, required for running tests without hardware. This command installs the pytest-embedded-qemu plugin. ```bash python3 -m pip install pytest-embedded-qemu ``` -------------------------------- ### Add Group Command Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of how to use the invoke-cmd to add a group. ```APIDOC ## POST /espressif/esp-matter/invoke-cmd (AddGroup Example) ### Description Example of how to use the invoke-cmd to add a group using the Groups cluster. ### Method POST ### Endpoint /espressif/esp-matter/invoke-cmd ### Parameters #### Path Parameters - **node-id** (string) - Required - The ID of the Matter node. - **endpoint-id** (string) - Required - The ID of the endpoint on the node. - **cluster-id** (string) - Required - The ID of the Groups cluster (0x04). - **command-id** (string) - Required - The ID of the AddGroup command (0). #### Request Body - **command-data** (string) - Required - A JSON string representing the AddGroup command payload. Example: `{"groupID": 1, "groupName": "grp1"}`. The actual command data format is `{"0:U16": 1, "1:STR": "grp1"}`. ### Request Example ```json { "command-data": "{\"0:U16\": 1, \"1:STR\": \"grp1\"}" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the command invocation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Build otbr-posix Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Clone the ot-br-posix repository and run the bootstrap and setup scripts to build the otbr-posix on the host machine. ```bash git clone https://github.com/openthread/ot-br-posix cd ot-br-posix ./script/bootstrap ./script/setup ``` -------------------------------- ### Start otbr-agent Manually Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Manually start the otbr-agent service with specified network interfaces and RCP port. Ensure the backbone interface is connected to the same AP as the Wi-Fi product. ```bash sudo systemctl disable otbr-agent.service sudo ./build/otbr/src/agent/otbr-agent -I wpan0 -B eth0 -v spinel+hdlc+uart://{RCP_PORT1} ``` -------------------------------- ### Build and Flash ESP-Matter Optional Attributes Test App Source: https://github.com/espressif/esp-matter/blob/main/examples/test_apps/test_optional_attributes/README.md Navigate to the example directory, set the target, and then build, flash, and monitor the application. Ensure you replace `` with your specific ESP32 target. ```bash cd examples/test_apps/test_optional_attributes idf.py set-target idf.py build flash monitor ``` -------------------------------- ### Install Bluez for Bluetooth Functionality Source: https://github.com/espressif/esp-matter/blob/main/docs/en/using_chip_tool.rst Install the bluez library on your WSL2 instance, which is necessary for managing and scanning Bluetooth devices. ```ini sudo apt install bluez ``` -------------------------------- ### Configure SDK for Production Environment Source: https://github.com/espressif/esp-matter/blob/main/docs/en/production.rst This example demonstrates how to set up SDK configurations for a production environment by creating a defaults file and using it with 'idf.py'. It enables specific ESP32 factory data providers and secure certificate providers. ```bash cat > sdkconfig.defaults.prod < ``` -------------------------------- ### Build ESP-Matter with RAM Optimization Source: https://github.com/espressif/esp-matter/blob/main/examples/controller/README.md Use this command to build the ESP-Matter example with RAM optimization enabled, including SPIRAM and BSS segment placement in external memory. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.ram_optimization" set-target esp32s3 build ``` -------------------------------- ### Install ESP-Matter Mfg Tool Dependencies Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md Installs the necessary Python dependencies for the ESP-Matter manufacturing tool. Ensure your IDF environment is sourced before running. ```bash source $IDF_PATH/export.sh python3 -m pip install -r tools/mfg_tool/requirements.txt ``` -------------------------------- ### Pairing with Wi-Fi and Matter Setup Payload Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Use this command to pair a device over Wi-Fi using its SSID, passphrase, and a Matter setup payload. If BLE controller is enabled, discovery occurs on both IP and BLE networks. ```bash matter esp controller pairing code-wifi ``` -------------------------------- ### Pairing with Wi-Fi, Thread, and Matter Setup Payload Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Use this command to pair a device over Wi-Fi and Thread using its SSID, passphrase, operational dataset, and a Matter setup payload. If BLE controller is enabled, discovery occurs on both IP and BLE networks. ```bash matter esp controller pairing code-wifi-thread ``` -------------------------------- ### Build ESP Matter Unit Test App Source: https://github.com/espressif/esp-matter/blob/main/examples/unit_test_app/README.md Build the unit test application for the ESP Matter component. Navigate to the example directory and execute the build command. ```bash cd examples/unit_test_app idf.py build ``` -------------------------------- ### Write StartUpOnOff Attribute (Integer) Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of writing the StartUpOnOff attribute with an integer value. The value is represented as a JSON object with a uint8 type. ```bash matter esp controller write-attr 6 0x4003 "{\"0:U8\": 2}" ``` -------------------------------- ### Pairing with Thread and Matter Setup Payload Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Use this command to pair a device over Thread using its operational dataset and a Matter setup payload. If BLE controller is enabled, discovery occurs on both IP and BLE networks. ```bash matter esp controller pairing code-thread ``` -------------------------------- ### Build Python Test Environment Source: https://github.com/espressif/esp-matter/blob/main/tools/test_optional_attributes/README.md Installs the Matter Python controller and test framework into a virtual environment. This script must be run before executing the tests. ```bash ./install.sh --build-python ``` -------------------------------- ### Namespace Update Example Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md Illustrates a namespace change from 'wifi' to 'wi_fi' as part of the generated data model implementation. ```c++ - namespace wifi {} → namespace wi_fi {} ``` -------------------------------- ### Write StartUpOnOff Attribute (Null) Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of writing the StartUpOnOff attribute with a null value. The value is represented as a JSON object with a null type. ```bash matter esp controller write-attr 6 0x4003 "{\"0:NULL\": null}" ``` -------------------------------- ### Initialize and Commit Thread Network Dataset Source: https://github.com/espressif/esp-matter/blob/main/examples/controller/README.md Initialize a new Thread network dataset and commit it as the active one. This is a prerequisite for starting the Thread network. ```bash matter esp ot_cli dataset init new matter esp ot_cli dataset commit active ``` -------------------------------- ### Configure Thread Network Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Commands to bring up the network interface and start the Thread stack. ```bash ifconfig up thread start srp client autostart enable ``` -------------------------------- ### Start ESP-Matter with Event Callback and Argument Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md The `esp_matter::start` API now supports passing additional data to the event callback via the `callback_arg` parameter. It defaults to NULL if not specified. ```cpp esp_matter::start(event_callback_t callback, intptr_t callback_arg = static_cast(NULL)) ``` -------------------------------- ### Explicit Namespace Referencing Example Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md Demonstrates how to explicitly reference namespaces like 'window_covering', 'power_source', and 'mode_select' to avoid ambiguity when they exist in both 'cluster' and 'device_type' contexts. ```c - Use endpoint::window_covering::create() to create the endpoint - Use cluster::window_covering::create() to create the cluster ``` -------------------------------- ### Start CHIP Tool Interactive Mode Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Initiates the CHIP Tool in interactive mode for commissioning and controlling Matter devices. ```bash chip-tool interactive start ``` -------------------------------- ### ESP-Matter Build Configuration for Secure Cert Partition Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Example build configuration options for using the esp_secure_cert partition with ESP-Matter. These options enable specific data providers and disable DS Peripheral support. ```text # Disable the DS Peripheral support CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n # Use DAC Provider implementation which reads attestation data from secure cert partition CONFIG_SEC_CERT_DAC_PROVIDER=y # Enable some options which reads CD and other basic info from the factory partition CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER=y CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER=y CONFIG_FACTORY_COMMISSIONABLE_DATA_PROVIDER=y CONFIG_FACTORY_DEVICE_INSTANCE_INFO_PROVIDER=y ``` -------------------------------- ### Interact with ot-ctl Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Connect to the ot-ctl and execute commands to bring up the interface, start the Thread network, and retrieve the active dataset. ```bash sudo ot-ctl > ifconfig up > thread start > dataset active -x ``` -------------------------------- ### Initialize Device Drivers Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Initializes device drivers, including buttons and LEDs, and registers callbacks for button events. This function should be called during the application's setup phase. ```cpp esp_err_t app_driver_init() { ESP_LOGI(TAG, "Initialising driver"); /* Initialize button */ button_config_t button_config = button_driver_get_config(); button_handle_t handle = iot_button_create(&button_config); iot_button_register_cb(handle, BUTTON_PRESS_DOWN, app_driver_button_toggle_cb); app_reset_button_register(handle); /* Initialize led */ led_driver_config_t led_config = led_driver_get_config(); led_driver_init(&led_config); app_driver_attribute_set_defaults(); return ESP_OK; } ``` -------------------------------- ### Initialize and Configure OTA Requestor in ESP-Matter Source: https://context7.com/espressif/esp-matter/llms.txt Enables Over-The-Air (OTA) updates by initializing the OTA requestor and configuring its parameters like periodic query and watchdog timeouts. Starts the OTA requestor after initialization. ```cpp #include void setup_ota() { // Initialize OTA requestor (adds clusters to root endpoint) esp_err_t err = esp_matter_ota_requestor_init(); if (err != ESP_OK) { ESP_LOGE("app", "Failed to initialize OTA requestor"); return; } // Configure OTA parameters esp_matter_ota_config_t ota_config = { .periodic_query_timeout = 86400, // Query every 24 hours .watchdog_timeout = 300, // 5 minute watchdog .impl = nullptr // Use default implementation }; esp_matter_ota_requestor_set_config(ota_config); // Start OTA requestor esp_matter_ota_requestor_start(); ESP_LOGI("app", "OTA requestor started"); } // For encrypted OTA images #if CONFIG_ENABLE_ENCRYPTED_OTA void setup_encrypted_ota(const char *decryption_key, uint16_t key_len) { esp_err_t err = esp_matter_ota_requestor_encrypted_init(decryption_key, key_len); if (err == ESP_OK) { ESP_LOGI("app", "Encrypted OTA initialized"); } } #endif ``` -------------------------------- ### Flash SDK Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Wipes the entire flash memory to ensure a clean start before flashing the SDK. Recommended for first-time SDK installations. ```bash idf.py erase_flash ``` -------------------------------- ### Copy Auth Key to Project Directory Source: https://github.com/espressif/esp-matter/blob/main/docs/en/insights.rst Copy the downloaded authentication key to the specified project directory within your ESP-Matter example. This step is crucial for establishing a connection with the ESP-Insights service. ```bash cp /path/to/auth/key.txt path/to/esp-matter/examples/generic_switch/insights_auth_key.txt ``` -------------------------------- ### Setup WebRTC SDK and Media Adapter (ESP32-P4) Source: https://github.com/espressif/esp-matter/blob/main/examples/camera/README.md Clone and set up the Amazon Kinesis Video Streams WebRTC SDK, then build and flash the media adapter firmware onto the ESP32-P4. Ensure correct console output selection in menuconfig. ```bash git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git git checkout beta-reference-esp-port git submodule update --init --depth 1 export KVS_SDK_PATH=/path/to/amazon-kinesis-video-streams-webrtc-sdk-c ``` ```bash cd ${KVS_SDK_PATH}/esp_port/examples/streaming_only idf.py set-target esp32p4 idf.py menuconfig # Go to Component config -> ESP System Settings -> Channel for console output # (X) USB Serial/JTAG Controller # For ESP32-P4 Function_EV_Board V1.2 OR V1.5 # (X) Default: UART0 # For ESP32-P4 Function_EV_Board V1.4 idf.py build idf.py -p [PORT] flash monitor ``` -------------------------------- ### Verify Bluetooth Module Availability Source: https://github.com/espressif/esp-matter/blob/main/docs/en/using_chip_tool.rst After attaching, list USB devices within WSL2 to confirm the Bluetooth module is recognized. This example shows an Intel Bluetooth device. ```ini $ lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 8087:0029 Intel Corp. AX201 Bluetooth Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub ``` -------------------------------- ### Display Build-Docs Help Source: https://github.com/espressif/esp-matter/blob/main/docs/README.md Displays all available options and arguments for the `build-docs` command. This is useful for understanding customization possibilities. ```bash build-docs --help ``` -------------------------------- ### Install Requirements Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Installs necessary Python packages from the requirements file, typically used to resolve build errors related to virtual environments. ```bash pip install -r $IDF_PATH/requirements.txt ``` -------------------------------- ### Basic Commissioner Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Implements a basic Matter commissioner for commissioning other Matter devices to its fabric. Refer to the GitHub link for the full example. -------------------------------- ### CSV File Format Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/production.rst Example structure for a CSV file used with esp-matter-mfg-tool. It defines serial number, data, and string types. ```text serial-num,data,string rd-id-uid,data,hex2bin discriminator,data,u32 ``` -------------------------------- ### Create and Manage Devices via Console Source: https://github.com/espressif/esp-matter/blob/main/examples/all_device_types_app/README.md Use console commands to create, delete, and manage devices. Use 'create --device_type' to list supported types or create a specific device like 'on_off_light' or 'fan'. Factory reset is performed using 'matter esp factoryreset'. ```bash - Use `create --device_type` to list all supported device types. - Use `create --device_type=on_off_light` to create light device. - To delete existing device perform `matter esp factoryreset`. - To add new device, say fan or any other device type use `create --device_type=fan`. ``` -------------------------------- ### MCSV File Format Example Source: https://github.com/espressif/esp-matter/blob/main/docs/en/production.rst Example structure for an MCSV file used with esp-matter-mfg-tool. It maps serial numbers to rotating device IDs and discriminators. ```text serial-num,rd-id-uid,discriminator esp32c_dev3,c0398f4980b07c9460f71c5421e1a3c5,1234 esp32c_dev4,c0398f4980b07c9460f71c5421e1a3c6,1235 esp32c_dev5,c0398f4980b07c9460f71c5421e1a3c7,1236 esp32c_dev6,c0398f4980b07c9460f71c5421e1a3c8,1237 esp32c_dev7,c0398f4980b07c9460f71c5421e1a3c9,1238 ``` -------------------------------- ### Generate Matter Onboarding Codes with Python Script Source: https://github.com/espressif/esp-matter/blob/main/docs/en/faq.rst Use the generate_setup_payload.py script to create Matter onboarding codes. This script requires parameters such as discriminator, passcode, vendor ID, and product ID. ```bash ./generate_setup_payload.py --discriminator 3131 --passcode 20201111 \ --vendor-id 65521 --product-id 32768 \ --commissioning-flow 0 --discovery-cap-bitmask 2 ``` -------------------------------- ### Get Matter Attribute Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Retrieve the value of a Matter attribute using 'matter esp attribute get'. Requires endpoint, cluster, and attribute IDs in hexadecimal format. ```bash matter esp attribute get ``` ```bash matter esp attribute get 0x1 0x6 0x0 ``` -------------------------------- ### Initialize ESP32ManufacturingDataProvider with Default Precedence Source: https://github.com/espressif/esp-matter/blob/main/examples/common/manufacturing_data_provider/README.md Creates a provider that checks the factory partition first, then the secure cert partition. Must be called before esp_matter::start(). ```cpp #include { // Create provider with default precedence (FactoryFirst) // This checks the data in the factory partition first, and if it's not valid, // it will check the data in the secure cert partition. static chip::DeviceLayer::ESP32ManufacturingDataProvider provider; // Set as the commissionable data provider using esp_matter functions // Must be called before esp_matter::start() set_custom_commissionable_data_provider(&provider); set_custom_device_instance_info_provider(&provider); } ``` -------------------------------- ### Run Zap Tool for Customization Source: https://github.com/espressif/esp-matter/blob/main/examples/zap_light/README.md Execute this command to open the zap-tool for customizing device configurations. An optional existing .zap file can be provided as an argument. If the command fails, try running it again. ```bash cd esp-matter/connectedhomeip/connectedhomeip ./scripts/tools/zap/run_zaptool.sh ``` -------------------------------- ### Build Documentation Source: https://github.com/espressif/esp-matter/blob/main/docs/README.md Builds the documentation for the specified targets and language. Use the `-t` argument to add more targets like `esp32s2`, `esp32c3`, etc. The `-bs` argument specifies the builders (e.g., html, latex). ```bash build-docs -bs html latex -t esp32 -l en ``` -------------------------------- ### Build ESP Matter Unit Test App for QEMU Source: https://github.com/espressif/esp-matter/blob/main/examples/unit_test_app/README.md Build the unit test application specifically for QEMU emulation on the ESP32-C3 target. This command sets the appropriate SDK configuration defaults for QEMU. ```bash cd examples/unit_test_app idf.py -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.qemu" set-target esp32c3 build ``` -------------------------------- ### Set and Get Attribute Values Source: https://github.com/espressif/esp-matter/blob/main/examples/all_device_types_app/README.md Simulate changing an attribute value locally using the 'matter esp attribute set' command, specifying endpoint ID, cluster ID, attribute ID, and the new value. Retrieve attribute values using 'matter esp attribute get' with the respective IDs. ```bash - Command to set attribute value: `matter esp attribute set ` - Command to get attribute value: `matter esp attribute get ` ``` -------------------------------- ### Dump Device Configuration Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Use the 'matter config' command to display the static configuration of the device. ```bash matter config ``` -------------------------------- ### Display Help for Data Model Generator Source: https://github.com/espressif/esp-matter/blob/main/tools/data_model_gen/README.md Run the --help command to view advanced usage options for the data model generation script. ```bash python data_model_gen.py --help ``` -------------------------------- ### Initialize ESP32ManufacturingDataProvider with SecureCertFirst Precedence Source: https://github.com/espressif/esp-matter/blob/main/examples/common/manufacturing_data_provider/README.md Creates a provider that checks the secure cert partition first, then the factory partition. Must be called before esp_matter::start(). ```cpp { using namespace chip::DeviceLayer; static ESP32ManufacturingDataProvider provider(ESP32ManufacturingDataProvider::Precedence::SecureCertFirst); // Set as the commissionable data provider using esp_matter functions // Must be called before esp_matter::start() set_custom_commissionable_data_provider(&provider); set_custom_device_instance_info_provider(&provider); } ``` -------------------------------- ### Display Help for XML Parser Module Source: https://github.com/espressif/esp-matter/blob/main/tools/data_model_gen/README.md View available options for the XML parser module by running its --help command. ```bash python -m xml_processing.xml_parser --help ``` -------------------------------- ### Groups Cluster API Renaming Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md Example of API renaming in the Groups Cluster, changing 'create_group_name_support' to 'create_name_support'. ```c++ create_group_name_support() → create_name_support() ``` -------------------------------- ### Configure and Build Custom WSL2 Kernel Source: https://github.com/espressif/esp-matter/blob/main/docs/en/using_chip_tool.rst After cloning the kernel, navigate to the directory, checkout the specific branch, copy the current kernel configuration, and then use 'make menuconfig' to enable Bluetooth drivers. Finally, build and install the new kernel. ```bash cd WSL2-Linux-Kernel git checkout linux-msft-wsl-6.1.21.2 cp /proc/config.gz config.gz gunzip config.gz mv config .config sudo make menuconfig sudo make -j$(getconf _NPROCESSORS_ONLN) && sudo make modules_install -j$(getconf _NPROCESSORS_ONLN) && sudo make install -j$(getconf _NPROCESSORS_ONLN) ``` -------------------------------- ### Get Bounds API Update Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md The `get_bounds` API has been updated to return an `esp_err_t` status code and includes a `bounds` parameter. ```c esp_err_t get_bounds(attribute_t *attribute, esp_matter_attr_bounds_t *bounds); ``` -------------------------------- ### Build and Run ot-cli Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Clone the OpenThread repository, build the ot-cli for POSIX, and run it with the specified RCP port and baud rate to connect to the Thread network. ```bash git clone --recursive https://github.com/openthread/openthread.git cd openthread/ ./script/bootstrap ./bootstrap ./script/cmake-build posix ./build/posix/src/posix/ot-cli 'spinel+hdlc+uart:///dev/{RCP_PORT2}?uart-baudrate=115200' -v ``` -------------------------------- ### Write Binding Attribute Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of writing the Binding attribute with an array of binding objects. Each object specifies node, endpoint, and cluster. ```bash matter esp controller write-attr 30 0 "{\"0:ARR-OBJ\":[{\"1:U64\":1, \"3:U16\":1, \"4:U32\": 6}]}" ``` -------------------------------- ### Set Project Version in CMakeLists.txt Source: https://github.com/espressif/esp-matter/blob/main/docs/en/faq.rst Define project version variables in CMakeLists.txt when CONFIG_APP_PROJECT_VER_FROM_CONFIG is disabled. This scheme is used by default in most examples. ```cmake set(PROJECT_VER "1.0") set(PROJECT_VER_NUMBER 1) ``` -------------------------------- ### Define Extra Component Directories Source: https://github.com/espressif/esp-matter/blob/main/examples/demo/badge/CMakeLists.txt Specifies additional directories where CMake should look for components, including common ESP-Matter examples and components. ```cmake set(EXTRA_COMPONENT_DIRS "${ESP_MATTER_PATH}/examples/common" "${MATTER_SDK_PATH}/config/esp32/components" "${ESP_MATTER_PATH}/components" ${extra_components_dirs_append}) ``` -------------------------------- ### Connect to Wi-Fi via Matter Device Console Source: https://github.com/espressif/esp-matter/blob/main/docs/en/faq.rst Use this command to connect your Matter device to a Wi-Fi network through the device console. Ensure you have the correct SSID and password. ```bash matter esp wifi connect ``` -------------------------------- ### Descriptor Cluster API Renaming Source: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md Example of API renaming within the Descriptor Cluster to improve consistency and alignment with Matter specifications. ```c++ create_device_list() → create_device_type_list() ``` -------------------------------- ### Generate Matter Onboarding Codes with chip-tool Source: https://github.com/espressif/esp-matter/blob/main/docs/en/faq.rst Generate Matter onboarding codes using the chip-tool. Supports QR code generation and both short (11-digit) and long (21-digit) manual pairing codes. ```bash // Generate the QR Code chip-tool payload generate-qrcode --discriminator 3131 --setup-pin-code 20201111 \ --vendor-id 0xFFF1 --product-id 0x8004 \ --version 0 --commissioning-mode 0 --rendezvous 2 ``` ```bash // Generates the short manual pairing code (11-digit). chip-tool payload generate-manualcode --discriminator 3131 --setup-pin-code 20201111 \ --version 0 --commissioning-mode 0 ``` ```bash // To generate a long manual pairing code (21-digit) that includes both the vendor ID and product ID, // --commissioning-mode parameter must be set to either 1 or 2, indicating a non-standard commissioning flow. chip-tool payload generate-manualcode --discriminator 3131 --setup-pin-code 20201111 \ --vendor-id 0xFFF1 --product-id 0x8004 \ --version 0 --commissioning-mode 1 ``` -------------------------------- ### Set Name Attribute via Console Source: https://github.com/espressif/esp-matter/blob/main/examples/demo/badge/README.md Example command to set the 'Name' attribute (ID: 0x0000) on the badge via the Matter console. ```sh matter esp attribute set 0x0 0x131BFC03 0x0000 "Espressif Systems" ``` -------------------------------- ### Write Multiple Attributes Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of writing multiple attributes (ACL and Binding) in a single command. The attribute values are provided as a JSON array. ```bash matter esp controller write-attr , 31,30 0,0 "[{\"0:ARR-OBJ\":[{\"1:U8\": 5, \"2:U8\": 2, \"3:ARR-U64\": [112233], \"4:NULL\": null}, {\"1:U8\": 4, \"2:U8\": 3, \"3:ARR-U64\": [1], \"4:NULL\": null}]}, {\"0:ARR-OBJ\":[{\"1:U64\":1, \"3:U16\":1, \"4:U32\": 6}]}]" ``` -------------------------------- ### Set Target and Build ESP32-S3 Firmware Source: https://github.com/espressif/esp-matter/blob/main/examples/thread_border_router/README.md Set the target to ESP32-S3 and build the firmware. The default flash size is 8MB. ```bash idf.py set-target esp32s3 idf.py build ``` -------------------------------- ### Write ACL Attribute Source: https://github.com/espressif/esp-matter/blob/main/docs/en/controller.rst Example of writing the ACL attribute with an array of AccessControlList entries. Each entry specifies privilege, authMode, subjects, and targets. ```bash matter esp controller write-attr 31 0 "{\"0:ARR-OBJ\":[{\"1:U8\": 5, \"2:U8\": 2, \"3:ARR-U64\": [112233], \"4:NULL\": null}, {\"1:U8\": 4, \"2:U8\": 3, \"3:ARR-U64\": [1], \"4:NULL\": null}]}" ``` -------------------------------- ### Generate Matter OTA Files Source: https://github.com/espressif/esp-matter/blob/main/docs/en/certification.rst Use the ota_image_tool.py script to create Matter OTA files. The '-vn' parameter specifies the software version number, and '-vs' specifies the software version string. Ensure the firmware version is higher than the currently running version. ```bash cd $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/src/app ./ota_image_tool.py create -v -p -vn 2 -vs 1.1 -da sha256 \ /path/to/original_app_bin /path/to/out_ota_bin ``` -------------------------------- ### Initialize and Manage Thread Network Source: https://github.com/espressif/esp-matter/blob/main/examples/all_device_types_app/README.md After pairing, use console commands to initialize a new Thread network dataset, commit it as active, bring the interface up, and start the Thread network. The operational dataset TLV-encoded string can also be retrieved. ```bash matter esp ot_cli dataset init new matter esp ot_cli dataset commit active matter esp ot_cli ifconfig up matter esp ot_cli thread start # Get the operational dataset TLV-encoded string command matter esp ot_cli dataset active -x ``` -------------------------------- ### Linking Main Library Source: https://github.com/espressif/esp-matter/blob/main/CMakeLists.txt Links the main Matter library to the current component, using start and end group options for symbol resolution. ```cmake idf_component_get_property(main_lib main COMPONENT_LIB) set(chip_libraries $) target_link_libraries(${COMPONENT_LIB} INTERFACE -Wl,--start-group ${chip_libraries} -Wl,--end-group) ``` -------------------------------- ### Add Prebuilt Matter Library Source: https://github.com/espressif/esp-matter/blob/main/examples/zap_light/main/CMakeLists.txt Add a prebuilt Matter library to the project. Link the component library against the prebuilt library. ```cmake add_prebuilt_library(matterlib "${CMAKE_BINARY_DIR}/esp-idf/chip/lib/libCHIP.a" REQUIRES esp_matter main) target_link_libraries(${COMPONENT_LIB} INTERFACE matterlib) ``` -------------------------------- ### BLE Commands Source: https://github.com/espressif/esp-matter/blob/main/docs/en/developing.rst Control BLE advertisement on the device using 'matter ble' commands. Use 'start', 'stop', or 'state' to manage the BLE advertising. ```bash matter ble [start|stop|state] ``` -------------------------------- ### Start Bluetooth Device Scanning Source: https://github.com/espressif/esp-matter/blob/main/docs/en/using_chip_tool.rst Initiate a Bluetooth scan using the bluetoothctl utility to discover nearby Bluetooth devices. The discovery process should then begin. ```ini bluetoothctl scan on ``` -------------------------------- ### List Supported Bridged Device Types Source: https://github.com/espressif/esp-matter/blob/main/examples/bridge_apps/bridge_cli/README.md Use this command to see which bridged device types are supported by the bridge. No setup is required before running this command. ```bash matter esp bridge support ``` -------------------------------- ### Get Operational Dataset TLV Source: https://github.com/espressif/esp-matter/blob/main/examples/controller/README.md Retrieve the operational dataset in TLV-encoded string format. This output, represented by , is required for pairing Thread end-devices. ```bash matter esp ot_cli dataset active -x ``` -------------------------------- ### Set up CHIP Project Configuration File Source: https://github.com/espressif/esp-matter/blob/main/CMakeLists.txt Configures the CHIP project configuration file path. If CONFIG_CHIP_PROJECT_CONFIG is defined, it resolves the real path and formats it. Otherwise, it remains empty. ```cmake if (CONFIG_CHIP_PROJECT_CONFIG) get_filename_component(CHIP_PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} ) set(CHIP_PROJECT_CONFIG "<${CHIP_PROJECT_CONFIG}>") else() set(CHIP_PROJECT_CONFIG "") endif() ``` -------------------------------- ### Project Name and Target-Specific Includes Source: https://github.com/espressif/esp-matter/blob/main/examples/light_switch/CMakeLists.txt Sets the project name and conditionally includes the 'relinker' script for ESP32C2 targets. This is part of the standard ESP-Matter project setup. ```cmake project(light_switch) if(CONFIG_IDF_TARGET_ESP32C2) include(relinker) endif() ```