### Build and Flash Network Adapter Example for ESP32-C6 Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/standalone/README.md Builds and flashes the network adapter example on an ESP32-C6, which is required when using a P4+C6 setup. This requires an ESP-Prog board or JTAG for flashing. ```bash cd ${KVS_SDK_PATH}/esp_port/examples/network_adapter idf.py set-target esp32c6 idf.py build idf.py -p [ESP32-C6-PORT] flash monitor ``` -------------------------------- ### Build and Flash Example Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/README.md Build and flash the Matter + Rainmaker example after setting up the environment and generating necessary files. Monitor the device using 'idf.py monitor'. ```bash cd idf.py set-target esp32c3 idf.py build idf.py flash monitor ``` -------------------------------- ### Setup ESP-IDF Environment Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/split_mode/rmaker_split_camera/README.md Installs essential tools and sets up the ESP-IDF environment for development. Ensure you are using the correct IDF version (release/v5.5). ```bash ./install.sh . $IDF_PATH/export.sh ``` -------------------------------- ### Setup ESP-IDF Environment Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/standalone/README.md Installs essential tools and sets up the IDF environment for ESP32-P4 development. Ensure you are using the correct IDF version. ```bash ./install.sh . $IDF_PATH/export.sh ``` -------------------------------- ### Build and Flash Standalone Camera Example Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/standalone/README.md Builds and flashes the standalone camera example to the ESP device. Monitor the output for logs and ensure the correct target and console output are configured in menuconfig. ```bash cd esp-rainmaker/examples/camera/standalone idf.py set-target [esp32p4/esp32s3/esp32] idf.py menuconfig idf.py build idf.py -p [PORT] flash monitor ``` -------------------------------- ### Example Output for getparams Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_light/README.md This is an example of the output received when retrieving pairing codes, showing the manual code, QR code, and window open status. ```json "MatterCWM": { "ManualCode": "35306901693", "QRCode": "MT:U9VJ0CQM00YHG.48200", "WindowOpen": true } ``` -------------------------------- ### Clone Multi-Device Example Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/m5_demos/stickcplus_multi_device/README.md Clone the esp-rainmaker repository and navigate into the specific multi-device example directory for the M5Stack StickC Plus. ```bash git clone https://github.com/espressif/esp-rainmaker.git cd examples/m5_demos/stickcplus_multi_device ``` -------------------------------- ### Apply Demo Patch Source: https://github.com/espressif/esp-rainmaker/wiki/ESP32-C3-LED-Light-Demo Navigate to the example directory and apply the demo-specific patch file before building. ```bash cd esp-rainmaker/examples/led_light patch -p1 < esp32c3-demo.patch ``` -------------------------------- ### Build and Flash Application Source: https://github.com/espressif/esp-rainmaker/wiki/ESP32-C3-LED-Light-Demo Set the target to esp32c3, then build and flash the application, and start the serial monitor. ```bash idf.py set-target esp32c3 idf.py build flash monitor ``` -------------------------------- ### Build and Flash Project Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/m5_demos/stickcplus_multi_device/README.md Build the project and then flash it to the device using a baud rate of 1500000. The monitor command will start automatically after flashing. ```bash idf.py build idf.py flash -b 1500000 monitor ``` -------------------------------- ### Initialize and Start Network Connectivity Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_app_network/README.md Include the 'app_network.h' header to initialize and start network services. The app_network_start function can be called with different population types. ```c #include "app_network.h" // Initialize network app_network_init(); ... ... app_network_start(POP_TYPE_RANDOM) ``` -------------------------------- ### Build and Flash ESP32-P4 Streaming-Only Example Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/split_mode/rmaker_split_camera/README.md Builds and flashes the 'streaming_only' example from the KVS SDK onto the ESP32-P4. This firmware handles the media streaming part of the split-mode camera. ```bash cd ${KVS_SDK_PATH}/esp_port/examples/streaming_only idf.py set-target esp32p4 idf.py menuconfig idf.py build idf.py -p [PORT] flash monitor ``` -------------------------------- ### Matter Controller Setup Service Interface Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_matter_controller/SPEC.md The Matter Controller Setup Service provides an interface for managing the Matter Controller device. It requires authorization via the `esp.service.rmaker-user-auth` service. The service exposes parameters for group ID, command execution, and status reporting. ```APIDOC ## Service | Type | Name | |-------------------------------------|--------------------| | esp.service.matter-controller-setup | **MatterCTLSetup** | **Note**: `esp.service.matter-controller-setup` service requires `esp.service.rmaker-user-auth` service to authorize. ## Parameters | Type | Name | Value Type | Default | Flag | |-----------------------------|---------------|------------|---------|-------| | esp.param.rmaker-group-id | RMakerGroupID | string | | R W P | | esp.param.matter-ctl-cmd | MTCtlCMD | int | -1 | W | | esp.param.matter-ctl-status | MTCtlStatus | int | 0 | R P | **Note**: If `esp.param.rmaker-group-id` is available, Phone APP should not prompt the user to select a group again. ### RMakerGroupID Parameter This parameter stores the Rainmaker Group Id which is bound to the Matter Fabric Id. In RainMaker Matter Fabric, each RainMaker group corresponds to a Matter Fabric. If this parameter already has a non-empty value, it should not be updated in any case. ### MTCtlCMD Parameter This parameter corresponds to the command that the cloud sends to the Matter Controller. Here defines two command enumerations. | Command Code Value | Command Name | |--------------------|------------------| | 1 | UpdateNOC | | 2 | UpdateDeviceList | #### UpdateNOC command The UpdateNOC command allows the controller to fetch the Rainmaker Controller NOC. When receiving this command, the controller will generate a new CSR and send it to the cloud. After receiving the response, it will install the new NOC. #### UpdateDeviceList command This UpdateDeviceList command allows the controller to fetch the Matter devices in its RainMaker Group(Matter Fabric). **Note**: This command SHALL be executed when a Matter device is added/removed. ### MTCtlStatus Parameter This parameter is a bitmap value which corresponds to the status of Matter Controller | Bit | Name | Summary | |-----|----------------------|-------------------------------------------------------------------------------| | 0 | BaseURLSet | Whether the BaseURL is received from `esp.service.rmaker-user-auth` service | | 1 | UserTokenSet | Whether the UserToken is received from `esp.service.rmaker-user-auth` service | | 2 | RmakerGroupIDSet | Whether the RMakerGroupID parameter is set | | 3 | ControllerSetup | Whether the controller has been successfully set up before | | 4 | MatterCASEPermission | Whether the Phone APP should establish a CASE with the device | **Note**: The MatterCASEPermission bit takes effect only after the ControllerSetup bit is set to true. Before that, since the controller is not yet set up, there is no restriction on the Phone APP establishing a CASE with the device. ## Matter Controller Initialization Steps for Matter controller initialization: 1. Matter controller get network credentials with wifi-provisioning or other methods (e.g., Matter commissioning). 2. Phone APP authorizes the device with `esp.service.rmaker-user-auth` service. 3. Phone APP sends `setparams` command with the `--data` payload `{"MatterCTLSetup":{"RMakerGroupID": }}`. * If the device was added via Matter commissioning, `` must match the group selected during commissioning. * If the device is not added via Matter commissioning, `` should be the selected group. 4. Phone APP receives report of `MTCtlStatus` with 0-3 bits set to `true` before timeout. 5. Phone APP sends `setparams` command with the `--data` payload `{"MatterCTLSetup":{"MTCtlCMD": 2}}` to make the controller obtain the device list in the Matter Fabric. The same command should also be sent whenever a Matter device is added or removed. ``` -------------------------------- ### Zigbee Gateway Log Output Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/zigbee_gateway/README.md This log output shows the process of connecting to Wi-Fi, initializing MQTT, and receiving parameters for adding a Zigbee device via install code. It includes parsed install code and MAC address. ```log I (81687) app_wifi: Connected with IP Address:192.168.1.106 I (81687) esp_netif_handlers: sta ip: 192.168.1.106, mask: 255.255.255.0, gw: 192.168.1.1 I (81687) wifi_prov_mgr: STA Got IP I (81697) app_wifi: Provisioning successful I (81697) main_task: Returned from app_main() I (81727) esp_mqtt_glue: AWS PPI: ?Platform=APN3|A0|RM|EX00|RMDev|1x0|240AC41C91F8 I (81727) esp_mqtt_glue: Initialising MQTT I (81727) esp_rmaker_mqtt_budget: MQTT Budgeting initialised. Default: 100, Max: 1024, Revive count: 1, Revive period: 5 I (81737) esp_rmaker_local: Couldn't find POP in NVS. Generating a new one. I (81747) esp_rmaker_local: Waiting for Wi-Fi provisioning to finish. I (81747) esp_mqtt_glue: Connecting to a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com I (81757) esp_rmaker_core: Waiting for MQTT connection I (81817) wifi:idx:1 (ifx:0, 24:69:8e:07:04:25), tid:0, ssn:1, winSize:64 I (82927) esp-x509-crt-bundle: Certificate validated I (84767) esp_mqtt_glue: MQTT Connected I (84767) esp_rmaker_node_config: Reporting Node Configuration of length 1342 bytes. I (84777) esp_rmaker_core: Waiting for User Node Association. I (84777) esp_rmaker_ota_using_topics: Subscribing to: node/XZTfzxp4YfXqLmDwPvNTUi/otaurl I (84787) esp_rmaker_user_mapping: MQTT Publish: {"node_id":"XZTfzxp4YfXqLmDwPvNTUi","user_id":"0e155512-8946-4be4-a0e7-1e0e74b901c3","secret_key":"180A1405-894A-44F1-A84D-452B42F4FB35","reset":true} I (85577) esp_rmaker_user_mapping: User Node association message published successfully. I (85587) esp_rmaker_param: Params MQTT Init done. I (85597) esp_rmaker_param: Reporting params (init): {"Zigbee_Gateway":{"Add_zigbee_device":""},"Time":{"TZ":"","TZ-POSIX":""},"Schedule":{"Schedules":[]},"Scenes":{"Scenes":[]},"Local Control":{"POP":"e3fe1a33","Type":1}} I (85607) esp_rmaker_cmd_resp: Enabling Command-Response Module. I (86347) NimBLE: GAP procedure initiated: stop advertising. I (86357) NimBLE: GAP procedure initiated: stop advertising. I (86357) NimBLE: GAP procedure initiated: terminate connection; conn_handle=0 hci_reason=19 E (86397) protocomm_nimble: Error setting advertisement data; rc = 30 I (86407) wifi_prov_mgr: Provisioning stopped I (86407) wifi_prov_scheme_ble: BTDM memory released I (86407) esp_rmaker_local: Event 6 I (86407) esp_rmaker_local: Starting ESP Local control with HTTP Transport and security version: 1 I (86437) esp_https_server: Starting server I (86437) esp_https_server: Server listening on port 8080 I (86437) esp_rmaker_local: esp_local_ctrl service started with name : XZTfzxp4YfXqLmDwPvNTUi I (89067) esp_rmaker_param: Received params: {"Time":{"TZ":"Asia/Shanghai"}} I (89067) esp_rmaker_time_service: Received value = Asia/Shanghai for Time - TZ I (89077) esp_rmaker_time: Time not synchronised yet. I (89077) esp_rmaker_time: The current time is: Thu Jan 1 08:01:28 1970 +0800[CST], DST: No. I (89097) esp_rmaker_param: Reporting params: {"Time":{"TZ-POSIX":"CST-8"}} I (89097) esp_rmaker_param: Reporting params: {"Time":{"TZ":"Asia/Shanghai"}} I (89787) esp_rmaker_ota_using_topics: Fetching OTA details, if any. I (100537) esp_rmaker_param: Received params: {"Zigbee_Gateway":{"Add_zigbee_device":"{\"install_code\":\"83FED3407A939723A5C639B26916D505C3B5\",\"MAC_address\":\"74fa0801a003f784\"}"}} I (100537) app_main: Received write request via : Cloud I (100547) app_main: Received device name = Zigbee_Gateway,parameter name = Add_zigbee_device I (100557) app_main: prase zigbee ic success I (100557) app_main: prase install code:83fed3407a939723a5c639b26916d505 CRC:c3b5 I (100567) app_main: prase MAC address::74fa0801a003f784 I (100577) esp_rmaker_param: Reporting params: {"Zigbee_Gateway":{"Add_zigbee_device":"{\"install_code\":\"83FED3407A939723A5C639B26916D505C3B5\",\"MAC_address\":\"74fa0801a003f784\"}"}} ``` -------------------------------- ### Enable Zigbee Install Code Feature Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/zigbee_gateway/README.md Navigate to menuconfig to enable the Zigbee install code feature for your ESP RainMaker Zigbee Gateway example. ```shell idf.py menuconfig --> ESP Rainmaker Zigbee Gateway Example --> Enable zigbee install code ``` -------------------------------- ### Build Controller with OTBR Feature Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_controller/README.md Build and flash the controller example with the OTBR feature enabled using the provided sdkconfig defaults. Ensure the correct target is set. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.otbr" set-target esp32s3 build idf.py -p erase-flash flash monitor ``` -------------------------------- ### Clone esp-homekit-sdk Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/homekit_switch/README.md Clone the esp-homekit-sdk repository to compile this example. Ensure to use the --recursive flag to include submodules. ```bash git clone --recursive https://github.com/espressif/esp-homekit-sdk.git ``` -------------------------------- ### Start Thread Network with Random Dataset Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/thread_br/README.md After provisioning, use the RainMaker CLI to generate a random Thread dataset, set it as the active dataset, and start the Thread network. Replace '3485187E7F68' with your node ID. ```bash $ esp-rainmaker-cli setparams --data '{"TBRService":{"ThreadCmd": 1}}' 3485187E7F68 ``` -------------------------------- ### Creating a Lightbulb Device with Default Names Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Example of creating a lightbulb device using default parameter names (Name, Power). ```c light_device = esp_rmaker_lightbulb_device_create("Light", NULL, DEFAULT_POWER); ``` -------------------------------- ### Creating a Lightbulb Device with Custom Names Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Example of creating a lightbulb device and explicitly setting parameter names to 'name' and 'power'. ```c light_device = esp_rmaker_device_create("Light", ESP_RMAKER_DEVICE_LIGHTBULB, NULL); esp_rmaker_device_add_param(light_device, esp_rmaker_name_param_create("name", "Light")); power_param = esp_rmaker_power_param_create("power", DEFAULT_POWER); esp_rmaker_device_add_param(light_device, power_param); esp_rmaker_device_assign_primary_param(light_device, power_param); ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/README.md Set up the necessary environment variables for ESP-IDF, ESP-Matter, and ESP Rainmaker SDKs. Ensure you are in the correct directories before exporting. ```bash cd /path/to/esp-idf . ./export.sh cd /path/to/esp-matter . ./export.sh export RMAKER_PATH=/path/to/esp-rainmaker ``` -------------------------------- ### Build and Flash ESP RainMaker Controller Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/rainmaker_controller/README.md Commands to set the target, build, flash, and monitor the ESP RainMaker controller example. ```bash idf.py set-target # e.g. esp32, esp32s3 idf.py build idf.py -p flash monitor ``` -------------------------------- ### Build and Flash media_adapter (ESP32-P4) Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/split_mode/README.md Build and flash the media_adapter firmware for the ESP32-P4, which is based on the 'streaming_only' example from the KVS SDK. Ensure the correct console output is selected in menuconfig for the ESP32-P4 Function EV Board version. ```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 ``` -------------------------------- ### Example Output of getparams Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_controller_with_touchscreen/README.md This JSON output shows the detailed parameters and structure of a Matter Controller and its associated devices. ```json { "Matter Controller": { "Name": "Controller", "Power": true }, "Matter-Controller": { "Matter-Controller-Data-Version": "1.0.1", "Matter-Devices": { "d81b1178e484c26d": { "enabled": true, "endpoints": { "0x1": { "clusters": { "servers": { "0x3": { "attributes": { "0x0": 0, "0x1": 0 } }, "0x300": { "attributes": { "0x10": 0, "0x2": 0, "0x3": 24939, "0x4": 24701, "0x4001": 2, "0x400a": 24, "0x400b": 0, "0x400c": 65279, "0x400d": 0, "0x4010": "Unhandled", "0x7": 250, "0x8": 2, "0xf": 0 } }, "0x4": { "attributes": { "0x0": 128 } }, "0x6": { "attributes": { "0x0": true, "0x4000": true, "0x4001": 0, "0x4002": 0, "0x4003": "Unhandled" } }, "0x62": { "attributes": { "0x1": 16, "0x2": "Unhandled" } }, "0x8": { "attributes": { "0x0": 64, "0x1": 0, "0x11": "Unhandled", "0x2": 1, "0x3": 254, "0x4000": 64, "0xf": 0 } } } }, "device_type": "0x10d" }, "0x2": { "clusters": { "servers": { "0x3": { "attributes": { "0x0": 0, "0x1": 0 } }, "0x3b": { "attributes": { "0x0": 2, "0x1": 0 }, "events": { "0x0": false, "0x1": false, "0x2": false, "0x3": false, "0x4": false, "0x5": false, "0x6": false } } } }, "device_type": "0xf" }, "0x3": { "clusters": { "clients": ["0x3", "0x6", "0x4"], "servers": { "0x1e": { "attributes": { "0x0": "Unhandled" } }, "0x3": { "attributes": { "0x0": 0, "0x1": 0 } }, "0x4": { "attributes": { "0x0": 128 } } } }, "device_type": "0x103" } }, "reachable": true } } }, "Scenes": { "Scenes": [] }, "Schedule": { "Schedules": [] }, "Time": { "TZ": "", "TZ-POSIX": "" } } ``` -------------------------------- ### Build and Flash with OpenThread Border Router Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_controller_with_touchscreen/README.md Steps to build and flash the Matter controller example with OpenThread Border Router defaults enabled. Requires an ESP32-H2 board flashed with ot_rcp. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.otbr" set-target esp32s3 idf.py bmgr -l idf.py bmgr -b idf.py build idf.py flash monitor ``` -------------------------------- ### Start Thread Network with Specific Active Dataset Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/thread_br/README.md Use the RainMaker CLI to set a specific active dataset and start the Thread network. Replace '3485187E7F68' with your node ID. ```bash $ esp-rainmaker-cli setparams --data '{"TBRService":{"ActiveDataset": "0E080000000000010000000300001235060004001FFFE00208DE45772E58CAC8CE0708FD01321F6B80688105101CBF6F4E68CBC611B52ED9A39EFD80A9030F4F70656E5468726561642D616534370102AE470410AB7CDEB095B2C453E6CE7E7DB2BC52980C0402A0F7F8"}}' 3485187E7F68 ``` -------------------------------- ### Clone Repository with Submodules Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Use this command for new clones to ensure all submodules are included from the start. ```bash git clone --recursive https://github.com/espressif/esp-rainmaker.git ``` -------------------------------- ### Build and Flash without OpenThread Border Router Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_controller_with_touchscreen/README.md Steps to set the target, list boards, build, and flash the Matter controller example when not using an OpenThread Border Router. ```bash idf.py set-target esp32s3 idf.py bmgr -l idf.py bmgr -b idf.py build idf.py flash monitor ``` -------------------------------- ### Export HomeKit SDK Path Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/homekit_switch/README.md Set the HOMEKIT_PATH environment variable to the location where you cloned the esp-homekit-sdk. This is required for building the example. ```bash export HOMEKIT_PATH=/path/to/esp-homekit-sdk/ ``` -------------------------------- ### Set Target and Build for ESP32-C6 Thread Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_light/THREAD_INSTRUCTIONS.md Configures the build target to esp32c6 and applies Thread-specific SDK configurations. Ensure the SDKCONFIG_DEFAULTS path is correct for your setup. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.esp32c6.thread" set-target esp32c6 build ``` -------------------------------- ### Example Log Output Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/fan/README.md This log message indicates that the 'Fan - power' parameter received a 'true' value, likely from the phone app. ```log I (16073) app_main: Received value = true for Fan - power ``` -------------------------------- ### Example CLI Commands for ESP RainMaker Controller Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/rainmaker_controller/README.md Demonstrates the usage of various CLI commands to manage RainMaker nodes via the UART console. Use single quotes for JSON payloads. ```text rainmaker_controller_cli> getnodes 1. 2. rainmaker_controller_cli> getnodestatus Node is online ``` -------------------------------- ### Basic App Reset Initialization Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_app_reset/README.md Initialize the app_reset component by creating a button handle and registering Wi-Fi and factory reset timeouts. This example uses default button creation. ```c #include #include #include #define BUTTON_GPIO 0 #define BUTTON_ACTIVE_LEVEL 0 void app_driver_init() { /* Create button using app_reset helper */ button_handle_t btn_handle = app_reset_button_create(BUTTON_GPIO, BUTTON_ACTIVE_LEVEL); if (btn_handle) { /* Register Wi-Fi reset (3 seconds) and Factory reset (10 seconds) */ app_reset_button_register(btn_handle, 3, 10); } } ``` -------------------------------- ### Configure Camera Component Sources and Dependencies Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/components/rmaker_camera/CMakeLists.txt Defines the source files, include directories, and required components for the camera component. This setup is essential for building the camera functionality within an ESP-IDF project. ```cmake set( srcs "src/credentials_provider.c" "src/rmaker_camera.c" "src/sleep_command.c" ) idf_component_register( SRCS ${srcs} INCLUDE_DIRS "include" REQUIRES "nvs_flash" "esp_wifi" "esp_timer" "esp_netif" "esp_event" "mbedtls" "lwip" ) ``` -------------------------------- ### Generate Factory NVS Binary with esp-matter-mfg-tool Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/README.md Generate the factory NVS binary required for Matter and embed RainMaker MQTT host information. This tool is available via pip install esp-matter-mfg-tool. ```bash esp-matter-mfg-tool --vendor-id 0x131B --product-id 0x2 \ --vendor-name "Espressif" --product-name "RainMaker-Matter-Light" \ --hw-ver-str "DevKitM1" \ -cd $RMAKER_PATH/examples/matter/mfg/cd_131B_0002.der \ --csv $RMAKER_PATH/examples/matter/mfg/keys.csv \ --mcsv $RMAKER_PATH/examples/matter/mfg/master.csv ``` -------------------------------- ### Build Matter App with Fabric Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_light/README.md Use this command to build the Matter application with default fabric configuration. ```bash idf.py build ``` -------------------------------- ### Create Camera Device and Initialize WebRTC Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/components/rmaker_camera/README.md Demonstrates the creation of a camera device and initialization of the WebRTC stack using the rmaker_camera component. Ensure necessary interfaces for peer connection, video, and audio capture are provided. ```c #include "rmaker_camera.h" /* Create camera device */ esp_rmaker_device_t *device = esp_rmaker_camera_device_create("ESP32 Camera", NULL); /* Initialize WebRTC */ rmaker_webrtc_camera_config_t config = { .peer_connection_if = kvs_peer_connection_if_get(), .video_capture = media_stream_get_video_capture_if(), .audio_capture = media_stream_get_audio_capture_if(), .init_callback = NULL, .init_callback_user_data = NULL, }; rmaker_webrtc_camera_init(&config); ``` -------------------------------- ### Configure Source and Include Directories Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/zigbee_gateway/main/CMakeLists.txt Sets the source and include directories for the project. Additional directories are appended if the M5Stack Zigbee Gateway board configuration is enabled. ```cmake set(SRC_DIRS_LIST ".") set(INCLUDE_DIRS_LIST ".") if (CONFIG_M5STACK_ZIGBEE_GATEWAY_BOARD) list(APPEND SRC_DIRS_LIST "./m5stack_display" "./m5stack_display/icon") list(APPEND INCLUDE_DIRS_LIST "./m5stack_display") endif() idf_component_register(SRC_DIRS ${SRC_DIRS_LIST} INCLUDE_DIRS ${INCLUDE_DIRS_LIST}) ``` -------------------------------- ### Helper API: Get Groups Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_user_api/README.md Retrieves a list of groups associated with the user. ```APIDOC ## Helper API: Get Groups ### Description Retrieves a list of groups. If a group name is provided, it fetches details for that specific group; otherwise, it fetches all groups. ### Function Signature ```c esp_err_t app_rmaker_user_helper_api_get_groups(const char *group_name, char **groups); ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **group_name** (const char *) - Optional - The name of the specific group to retrieve. If NULL, all groups are fetched. - **groups** (char **) - Output - Pointer to a char pointer where a JSON string representing the group(s) will be stored. The caller is responsible for freeing this memory. ### Request Example ```c #include "app_rmaker_user_helper_api.h" char *groups = NULL; // To get all groups: esp_err_t ret_all = app_rmaker_user_helper_api_get_groups(NULL, &groups); if (ret_all == ESP_OK && groups) { // Use groups (JSON string for all groups) // Remember to free the memory: free(groups); } free(groups); // Free memory if allocated // To get a specific group (e.g., "MyLivingRoom"): char *specific_group = NULL; esp_err_t ret_specific = app_rmaker_user_helper_api_get_groups("MyLivingRoom", &specific_group); if (ret_specific == ESP_OK && specific_group) { // Use specific_group (JSON string for the specific group) // Remember to free the memory: free(specific_group); } free(specific_group); // Free memory if allocated ``` ### Response #### Success Response (ESP_OK) - **ret** (esp_err_t) - ESP_OK on successful retrieval. - **groups** (char *) - A JSON string containing the group information. Caller must free this memory. #### Error Response - **ret** (esp_err_t) - Error code indicating failure. ``` -------------------------------- ### Helper API: Get Nodes List Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_user_api/README.md Retrieves a list of all registered nodes associated with the user. ```APIDOC ## Helper API: Get Nodes List ### Description Retrieves a list of all nodes registered under the current user's account, along with their count. ### Function Signature ```c esp_err_t app_rmaker_user_helper_api_get_nodes_list(char **nodes_list, uint16_t *nodes_count); ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **nodes_list** (char **) - Output - Pointer to a char pointer where a JSON string representing the list of nodes will be stored. The caller is responsible for freeing this memory. - **nodes_count** (uint16_t *) - Output - Pointer to a uint16_t where the total number of nodes will be stored. ### Request Example ```c #include "app_rmaker_user_helper_api.h" char *nodes_list = NULL; uint16_t nodes_count = 0; esp_err_t ret = app_rmaker_user_helper_api_get_nodes_list(&nodes_list, &nodes_count); if (ret == ESP_OK && nodes_list) { // Use nodes_list (JSON string) and nodes_count // Remember to free the memory: free(nodes_list); } free(nodes_list); // Free memory if nodes_list was allocated ``` ### Response #### Success Response (ESP_OK) - **ret** (esp_err_t) - ESP_OK on successful retrieval. - **nodes_list** (char *) - A JSON string containing the list of nodes. Caller must free this memory. - **nodes_count** (uint16_t) - The total number of nodes. #### Error Response - **ret** (esp_err_t) - Error code indicating failure. ``` -------------------------------- ### Helper API: Get User ID Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_user_api/README.md Retrieves the current user's ID using the helper API. ```APIDOC ## Helper API: Get User ID ### Description Retrieves the unique identifier for the currently logged-in user. ### Function Signature ```c esp_err_t app_rmaker_user_helper_api_get_user_id(char **user_id); ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **user_id** (char **) - Output - Pointer to a char pointer where the user ID string will be stored. The caller is responsible for freeing this memory. ### Request Example ```c #include "app_rmaker_user_helper_api.h" char *user_id = NULL; esp_err_t ret = app_rmaker_user_helper_api_get_user_id(&user_id); if (ret == ESP_OK && user_id) { // Use user_id // Remember to free the memory: free(user_id); } free(user_id); // Free memory if user_id was allocated ``` ### Response #### Success Response (ESP_OK) - **ret** (esp_err_t) - ESP_OK on successful retrieval. - **user_id** (char *) - A string containing the user ID. Caller must free this memory. #### Error Response - **ret** (esp_err_t) - Error code indicating failure. ``` -------------------------------- ### ESP RainMaker Device Creation (Old) Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Shows the previous method for creating a device and defining its callback function. ```c typedef esp_err_t (*esp_rmaker_param_callback_t)(const char *name, const char *dev_name, esp_rmaker_param_val_t val, void *priv_data); esp_err_t esp_rmaker_create_device(const char *dev_name, const char *type, esp_rmaker_param_callback_t cb, void *priv_data); ``` -------------------------------- ### ESP RainMaker Device Creation (New) Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Illustrates the new approach to creating a device, returning a device handle and allowing separate read/write callbacks. ```c typedef esp_err_t (*esp_rmaker_device_write_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, const esp_rmaker_param_val_t val, void *priv_data, esp_rmaker_write_ctx_t *ctx); typedef esp_err_t (*esp_rmaker_device_read_cb_t)(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param, void *priv_data, esp_rmaker_read_ctx_t *ctx); esp_rmaker_device_t *esp_rmaker_device_create(const char *dev_name, const char *type, void *priv_data); esp_err_t esp_rmaker_device_add_cb(const esp_rmaker_device_t *device, esp_rmaker_device_write_cb_t write_cb, esp_rmaker_device_read_cb_t read_cb); esp_err_t esp_rmaker_node_add_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device); esp_err_t esp_rmaker_node_remove_device(const esp_rmaker_node_t *node, const esp_rmaker_device_t *device); ``` -------------------------------- ### ESP RainMaker Initialization (New) Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Illustrates the updated ESP RainMaker configuration and initialization, returning a node handle. ```c typedef struct { bool enable_time_sync; } esp_rmaker_config_t; esp_rmaker_node_t *esp_rmaker_node_init(const esp_rmaker_config_t *config, const char *name, const char *type); ``` -------------------------------- ### Clone ESP-IDF v5.1.4 Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/m5_demos/stickcplus_multi_device/README.md Clone the ESP-IDF repository, ensuring you use the specific v5.1.4 version for compatibility. This is a one-time setup for your development environment. ```bash git clone -b v5.1.4 --recursive https://github.com/espressif/esp-idf.git ``` -------------------------------- ### Build M5Stack CoreS3 + Module Gateway H2 Firmware Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/thread_br/README.md Use this command to build the firmware for the M5Stack CoreS3 + Module Gateway H2. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.m5stack" set-target esp32s3 build ``` -------------------------------- ### Get Command Request Status via RainMaker CLI Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/led_light/README.md Retrieves the status of a previously sent command request using the RainMaker CLI. ```bash $ ./rainmaker.py get_cmd_requests BK00t2QNe7oT12dBdh9f8X Requests: [{'node_id': '6055F97E2008', 'request_id': 'BK00t2QNe7oT12dBdh9f8X', 'request_timestamp': 1685382006, 'status': 'in_progress', 'expiration_timestamp': 1685382066}] Total: 1 ``` -------------------------------- ### ESP RainMaker Initialization (Old) Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Shows the previous structure for ESP RainMaker configuration and initialization. ```c typedef struct { char *name; char *type; char *fw_version; char *model; } esp_rmaker_node_info_t; typedef struct { esp_rmaker_node_info_t info; bool enable_time_sync; } esp_rmaker_config_t; esp_err_t esp_rmaker_init(esp_rmaker_config_t *config); ``` -------------------------------- ### Send Custom Command via RainMaker CLI Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/led_light/README.md Demonstrates sending a custom command to a node using the RainMaker CLI. This example sends a brightness command. ```bash $ ./rainmaker.py create_cmd_request --timeout 60 6055F97E2008 4096 '{"brightness":50}' Request Id: BK00t2QNe7oT12dBdh9f8X Status: success ``` -------------------------------- ### Build and Flash Media Adapter Firmware Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/split_mode/media_adapter/README.md Build and flash the media adapter firmware for the ESP32-P4. Ensure the rmarker_camera firmware is flashed first. Configure console output in menuconfig if necessary. ```bash cd ${KVS_SDK_PATH}/esp_port/examples/streaming_only idf.py set-target esp32p4 # Configure console output (required for different board versions) 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 ``` -------------------------------- ### Build Matter App without Fabric (Static QR) Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_light/README.md Build the Matter application without fabric support, using a static QR code configuration for ESP32-C3 or ESP32-H2. Manual adaptation may be needed for other modules. ```bash idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.esp32c3.no_fabric" set-target esp32c3 build ``` -------------------------------- ### Clone KVS WebRTC SDK Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/README.md Clone the KVS WebRTC SDK from the specified branch and set the KVS_SDK_PATH environment variable. This is a prerequisite for using the camera examples. ```bash git clone -b beta-reference-esp-port git@github.com:awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git export KVS_SDK_PATH=/path/to/amazon-kinesis-video-streams-webrtc-sdk-c ``` -------------------------------- ### Get RainMaker Node Groups Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/client_only_matter_controller/README.md Retrieve a list of RainMaker node groups, specifically filtering for those that are Matter-enabled. This is necessary to identify the correct Matter Fabric ID. ```bash curl -X 'GET' \ '/v1/user/node_group?node_list=false&sub_groups=false&node_details=true&is_matter=true&fabric_details=false&num_records=25' \ -H 'accept: application/json' \ -H 'Authorization: ' {"groups":[{"group_id":"","group_name":"","fabric_id":"","is_matter":true,"primary":true,"total":0}, ...],"total":} ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Execute this command to update and initialize submodules for the project. This is necessary after the generic modules were moved out. ```bash git submodule update --init --recursive ``` -------------------------------- ### Build and Flash ESP32-C6 Firmware Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/camera/split_mode/rmaker_split_camera/README.md Configures the ESP-IDF target to esp32c6, builds the firmware, and flashes it to the device. Note that ESP32-C6 requires an external programmer like ESP-Prog for flashing. ```bash cd esp-rainmaker/examples/camera/split_mode/rmaker_camera idf.py set-target esp32c6 idf.py build idf.py -p [PORT] flash monitor ``` -------------------------------- ### Get Command Request Response via RainMaker CLI Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/led_light/README.md Retrieves the final response of a command request, including response data and status, using the RainMaker CLI. ```bash $ ./rainmaker.py get_cmd_requests BK00t2QNe7oT12dBdh9f8X Requests: [{'node_id': '6055F97E2008', 'request_id': 'BK00t2QNe7oT12dBdh9f8X', 'request_timestamp': 1685382006, 'response_timestamp': 1685382039, 'response_data': {'status': 'success'}, 'status': 'success', 'device_status': 0, 'expiration_timestamp': 1685382066}] ``` -------------------------------- ### Build and Flash ESP RainMaker Ethernet Switch Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/ethernet_switch/README.md Standard command to build the project, flash it to the ESP32 device, and monitor its output via serial connection. Ensure your device is connected and configured. ```bash idf.py build flash monitor ``` -------------------------------- ### Export Script Execution Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/m5_demos/stickcplus_multi_device/README.md Make the export script executable and run it to fetch necessary components for FastLED, m5_lvgl, and m5_relay. This prepares the project dependencies. ```bash chmod +x export.sh ./export.sh ``` -------------------------------- ### Build ESP Thread Border Router Board Firmware Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/thread_br/README.md Use this command to build the firmware for the ESP Thread Border Router Board. ```bash idf.py set-target esp32s3 build ``` -------------------------------- ### Flash Prebuilt Demo Image Source: https://github.com/espressif/esp-rainmaker/wiki/ESP32-C3-LED-Light-Demo Use these commands to erase the flash and write the prebuilt demo image to your ESP32-C3 board. ```bash export ESPPORT=/dev/tty.SLAB_USBtoUART #Replace with your board's serial port esptool.py -p $ESPPORT erase_flash esptool.py -p $ESPPORT write_flash 0x0 esp32c3_rainmaker_led_light_demo.bin ``` -------------------------------- ### ESP RainMaker Parameter Handling (New) Source: https://github.com/espressif/esp-rainmaker/blob/master/CHANGES.md Illustrates the new API for creating parameters with type and properties, and updating/reporting their values. ```c esp_rmaker_param_t *esp_rmaker_param_create(const char *param_name, const char *type, esp_rmaker_param_val_t val, uint8_t properties); esp_err_t esp_rmaker_device_add_param(const esp_rmaker_device_t *device, const esp_rmaker_param_t *param); esp_err_t esp_rmaker_param_update_and_report(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val); ``` -------------------------------- ### Use Helper API for Common Operations Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/common/rmaker_user_api/README.md Utilizes the optional helper API layer for simplified access to common RainMaker operations like getting user ID, node lists, and group information. Requires `CONFIG_ENABLE_RM_USER_HELPER_API` to be enabled. The caller is responsible for freeing the returned string pointers. ```c #include "app_rmaker_user_helper_api.h" char *user_id = NULL; app_rmaker_user_helper_api_get_user_id(&user_id); char *nodes_list = NULL; uint16_t nodes_count = 0; app_rmaker_user_helper_api_get_nodes_list(&nodes_list, &nodes_count); char *groups = NULL; app_rmaker_user_helper_api_get_groups(NULL, &groups); // NULL = all groups // ... use results; caller must free(...) free(user_id); free(nodes_list); free(groups); ``` -------------------------------- ### Component Registration and Configuration Source: https://github.com/espressif/esp-rainmaker/blob/master/examples/matter/matter_light/main/CMakeLists.txt Registers the component with its source files, include directories, and private requirements. Sets the C++ standard to 17 and adds a compile-time option. ```cmake set(PRIV_REQUIRES_LIST device app_matter) set(SRCS ./app_main.cpp ./app_matter_light.cpp ./app_driver.cpp) set(PRIV_INCLUDE_DIRS ./ ) if (NOT CONFIG_EXAMPLE_USE_RAINMAKER_FABRIC) list(APPEND SRCS "network_prov_scheme/protocomm_matter_ble.cpp" "network_prov_scheme/network_prov_scheme_matter_ble.cpp" "network_prov_scheme/app_network.cpp" "matter_cwm/matter_commissioning_window_management_std.cpp" "matter_cwm/matter_commissioning_window_management.cpp") list(APPEND PRIV_INCLUDE_DIRS "network_prov_scheme/" "matter_cwm/") list(APPEND PRIV_REQUIRES_LIST network_provisioning) endif() list(APPEND PRIV_INCLUDE_DIRS "$ENV{ESP_MATTER_PATH}/examples/common") if (CONFIG_CUSTOM_COMMISSIONABLE_DATA_PROVIDER) list(APPEND SRCS "matter_cwm/dynamic_commissionable_data_provider.cpp") endif() idf_component_register(SRCS ${SRCS} PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS} PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H") ```