From ead1e9350ef6f964a898a7ab0e26da7160439410 Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Wed, 10 Dec 2025 15:35:33 +0530 Subject: [PATCH 1/4] esp_rainmaker: Make Assisted Claiming and Challenge-Response as defaults - Assisted claiming is now the default so that the same firmware can work with global as well as China RainMaker deployment. - Challenge-Response based user-node mapping is now the default because it is recommended workflow as it is faster and prevents sending Wi-Fi credentials to invalid devices --- CHANGES.md | 14 ++++++++++++++ components/esp_rainmaker/CHANGELOG.md | 10 ++++++++++ components/esp_rainmaker/Kconfig.projbuild | 4 ++-- components/esp_rainmaker/idf_component.yml | 3 +-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4da94ee..7b2a6a6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,19 @@ # Changes +## Default Claiming Type and User-Node Mapping Changes (Behavioral Changes) + +**IMPORTANT BEHAVIORAL CHANGES**: Two significant default behavior changes have been made in ESP RainMaker: + +1. **Assisted Claiming is now the default for all supported platforms**: Assisted claiming (via phone apps) is now enabled by default for all platforms that support it (requires Bluetooth enabled and not ESP32S2). Previously, it was only the default for ESP32, with self claiming being the default for other platforms. This change provides a more consistent user experience across platforms and enables admin role support. + + **To revert to self claiming**: Set `CONFIG_ESP_RMAKER_SELF_CLAIM=y` in menuconfig (`idf.py menuconfig -> ESP RainMaker Config -> Claiming Type -> Use Self Claiming`). + +2. **Challenge Response based user-node mapping is now enabled by default**: Challenge response mechanism during provisioning is now enabled by default for improved security and reliability. This replaces the traditional user-node mapping flow and ensures that node mapping happens before Wi-Fi credentials are sent. Traditional user-node mapping provisioning is automatically disabled when this is enabled. + + **To disable challenge response**: Set `CONFIG_ESP_RMAKER_ENABLE_CHALLENGE_RESPONSE=n` in menuconfig (`idf.py menuconfig -> ESP RainMaker Config -> Enable Challenge Response during provisioning`). Note that challenge response requires the node to be claimed before it can be used. + + For more details, check the esp_rainmaker component's [CHANGELOG](components/esp_rainmaker/CHANGELOG.md). + ## 24-Jun-2024: OTA Reliability Improvements - Check details in esp_rainmaker component's [CHANGELOG](components/esp_rainmaker/CHANGELOG.md). diff --git a/components/esp_rainmaker/CHANGELOG.md b/components/esp_rainmaker/CHANGELOG.md index b75bca5..833e3a5 100644 --- a/components/esp_rainmaker/CHANGELOG.md +++ b/components/esp_rainmaker/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 1.8.5 + +### Changes + +- Assisted claiming is now the default for all supported platforms (requires Bluetooth enabled and not ESP32S2). + Previously, it was only the default for ESP32. To revert to self claiming, set `CONFIG_ESP_RMAKER_SELF_CLAIM=y` in menuconfig. +- Challenge response based user-node mapping is now enabled by default. This replaces the traditional user-node mapping flow. + To disable it, set `CONFIG_ESP_RMAKER_ENABLE_CHALLENGE_RESPONSE=n` in menuconfig. + Note that challenge response requires the node to be claimed before it can be used. + ## 1.8.4 ### New Feature diff --git a/components/esp_rainmaker/Kconfig.projbuild b/components/esp_rainmaker/Kconfig.projbuild index 62a6b3d..62ab2d5 100644 --- a/components/esp_rainmaker/Kconfig.projbuild +++ b/components/esp_rainmaker/Kconfig.projbuild @@ -2,8 +2,8 @@ menu "ESP RainMaker Config" choice ESP_RMAKER_CLAIM_TYPE bool "Claiming Type" + default ESP_RMAKER_ASSISTED_CLAIM if BT_ENABLED && !IDF_TARGET_ESP32S2 default ESP_RMAKER_SELF_CLAIM - default ESP_RMAKER_ASSISTED_CLAIM if IDF_TARGET_ESP32 help Claiming type to be used. @@ -200,7 +200,7 @@ menu "ESP RainMaker Config" config ESP_RMAKER_ENABLE_CHALLENGE_RESPONSE bool "Enable Challenge Response during provisioning" select ESP_RMAKER_FACTORY_RESET_REPORTING - default n + default y help Enable challenge response mechanism during provisioning to verify node authenticity. The node will receive a challenge from the client during provisioning, which it will diff --git a/components/esp_rainmaker/idf_component.yml b/components/esp_rainmaker/idf_component.yml index 7432a57..005e377 100644 --- a/components/esp_rainmaker/idf_component.yml +++ b/components/esp_rainmaker/idf_component.yml @@ -1,5 +1,4 @@ -## IDF Component Manager Manifest File -version: "1.8.4" +version: "1.8.5" description: ESP RainMaker firmware agent url: https://github.com/espressif/esp-rainmaker/tree/master/components/esp_rainmaker repository: https://github.com/espressif/esp-rainmaker.git From 407f2e502dd2eefa235515dcec3f1e5bec96d8be Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Fri, 19 Dec 2025 20:27:35 +0530 Subject: [PATCH 2/4] console: Add a command to clear claim data This can help developers to - Test claiming repeatedly - Move between China and Global deployments during development and testing --- .../src/console/esp_rmaker_commands.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/components/esp_rainmaker/src/console/esp_rmaker_commands.c b/components/esp_rainmaker/src/console/esp_rmaker_commands.c index f72aee1..30b4ddd 100644 --- a/components/esp_rainmaker/src/console/esp_rmaker_commands.c +++ b/components/esp_rainmaker/src/console/esp_rmaker_commands.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include /* Include internal header to access device structure */ #include "esp_rmaker_internal.h" @@ -538,6 +540,45 @@ static void register_param_commands() #endif /* CONFIG_ESP_RMAKER_CONSOLE_PARAM_CMDS_ENABLE */ +static int clear_claim_data_handler(int argc, char** argv) +{ + const char *partition_name = "fctry"; +#ifdef CONFIG_ESP_RMAKER_FACTORY_PARTITION_NAME + partition_name = CONFIG_ESP_RMAKER_FACTORY_PARTITION_NAME; +#endif + + printf("%s: Erasing fctry partition (%s)...\n", TAG, partition_name); + + const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, + ESP_PARTITION_SUBTYPE_DATA_NVS, + partition_name); + if (!partition) { + printf("%s: Failed to find partition '%s'\n", TAG, partition_name); + return ESP_FAIL; + } + + esp_err_t err = esp_partition_erase_range(partition, 0, partition->size); + if (err != ESP_OK) { + printf("%s: Failed to erase partition '%s'. Error: %d\n", TAG, partition_name, err); + return err; + } + + printf("%s: Successfully erased fctry partition (%s). Rebooting...\n", TAG, partition_name); + esp_rmaker_reboot(2); + return ESP_OK; +} + +static void register_clear_claim_data() +{ + const esp_console_cmd_t cmd = { + .command = "clear-claim-data", + .help = "Erase the fctry NVS partition (clears claim data)", + .func = &clear_claim_data_handler, + }; + ESP_LOGI(TAG, "Registering command: %s", cmd.command); + esp_console_cmd_register(&cmd); +} + void esp_rmaker_register_commands() { register_user_node_mapping(); @@ -547,6 +588,7 @@ void esp_rmaker_register_commands() register_cmd_resp_command(); #endif register_sign_data_command(); + register_clear_claim_data(); #ifdef CONFIG_ESP_RMAKER_CONSOLE_PARAM_CMDS_ENABLE register_param_commands(); #endif From 23123e3a2df53428168f5d0952963730b4bf6916 Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Fri, 19 Dec 2025 20:44:42 +0530 Subject: [PATCH 3/4] esp32c5: Added default config for binary size optimisation And also make esp32c5 part of standard esp-idf release/v5.5 CI builds --- .gitlab-ci.yml | 27 +------------------ examples/fan/sdkconfig.defaults.esp32c5 | 1 + examples/gpio/sdkconfig.defaults.esp32c5 | 1 + examples/led_light/sdkconfig.defaults.esp32c5 | 1 + .../multi_device/sdkconfig.defaults.esp32c5 | 1 + examples/switch/sdkconfig.defaults.esp32c5 | 1 + .../sdkconfig.defaults.esp32c5 | 1 + 7 files changed, 7 insertions(+), 26 deletions(-) create mode 100644 examples/fan/sdkconfig.defaults.esp32c5 create mode 100644 examples/gpio/sdkconfig.defaults.esp32c5 create mode 100644 examples/led_light/sdkconfig.defaults.esp32c5 create mode 100644 examples/multi_device/sdkconfig.defaults.esp32c5 create mode 100644 examples/switch/sdkconfig.defaults.esp32c5 create mode 100644 examples/temperature_sensor/sdkconfig.defaults.esp32c5 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8d3e2a..f901a1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -161,7 +161,7 @@ build_idf_v5.5: extends: .build_template image: espressif/idf:release-v5.5 variables: - EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3 esp32s3 esp32c6 esp32c2 esp32h2" + EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3 esp32s3 esp32c6 esp32c2 esp32h2 esp32c5" build_standalone_camera: extends: .build_template @@ -294,28 +294,3 @@ push_master_to_github: - git remote remove github &>/dev/null || true - git remote add github git@github.com:espressif/esp-rainmaker.git - git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}" - -build_esp32c5_preview: - extends: .build_template - image: espressif/idf:release-v5.5 - variables: - EXAMPLE_TARGETS: "esp32c5" - EXAMPLES: "switch led_light fan temperature_sensor multi_device gpio" - script: - - pip install --upgrade idf-component-manager - - for EXAMPLE in $EXAMPLES; do - - cd $CI_PROJECT_DIR/examples/$EXAMPLE - - echo Building $EXAMPLE - - for TARGET in $EXAMPLE_TARGETS; do - - echo Building for $TARGET - - idf.py --preview set-target $TARGET - - idf.py build - - mkdir -p $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/$EXAMPLE/$TARGET/ - - cp $CI_PROJECT_DIR/examples/$EXAMPLE/build/*.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/$EXAMPLE/$TARGET/ - - done - - echo Build Complete for $EXAMPLE - - done - # Generating zip file for binaries generated - - cd $CI_PROJECT_DIR - - echo Generating zip file for binaries generated - - tar -zcvf esp-rainmaker-bins-${CI_JOB_ID}.zip esp-rainmaker-bins-${CI_JOB_ID}/ diff --git a/examples/fan/sdkconfig.defaults.esp32c5 b/examples/fan/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/fan/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/gpio/sdkconfig.defaults.esp32c5 b/examples/gpio/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/gpio/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/led_light/sdkconfig.defaults.esp32c5 b/examples/led_light/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/led_light/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/multi_device/sdkconfig.defaults.esp32c5 b/examples/multi_device/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/multi_device/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/switch/sdkconfig.defaults.esp32c5 b/examples/switch/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/switch/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y diff --git a/examples/temperature_sensor/sdkconfig.defaults.esp32c5 b/examples/temperature_sensor/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000..4983b4d --- /dev/null +++ b/examples/temperature_sensor/sdkconfig.defaults.esp32c5 @@ -0,0 +1 @@ +CONFIG_COMPILER_OPTIMIZATION_SIZE=y From 61c860b68e5391fe9810fb0a602eee11a2b37e59 Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Mon, 22 Dec 2025 15:37:06 +0530 Subject: [PATCH 4/4] gitlab-ci: Add a separate job for HomeKit examples --- .gitlab-ci.yml | 54 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f901a1e..6242b07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,22 +62,11 @@ before_script: - for EXAMPLE in $EXAMPLES; do - cd $CI_PROJECT_DIR/examples/$EXAMPLE - echo Building $EXAMPLE - - if [[ "$EXAMPLE" == "homekit_switch" ]]; then - - cd components - - echo Cloning esp-homekit-sdk - - git clone --recursive --branch master --depth 1 https://github.com/espressif/esp-homekit-sdk.git - - cd .. - - export HOMEKIT_PATH=$PWD/components/esp-homekit-sdk - - fi - if [[ "$EXAMPLE" == "thread_br" ]]; then - - sed -i "/CONFIG_LWIP_IPV6_NUM_ADDRESSES=8/c\\CONFIG_LWIP_IPV6_NUM_ADDRESSES=12" sdkconfig.defaults + - sed -i "/CONFIG_LWIP_IPV6_NUM_ADDRESSES=8/c\\CONFIG_LWIP_IPV6_NUM_ADDRESSES=12" sdkconfig.defaults - fi - for TARGET in $EXAMPLE_TARGETS; do - echo Building for $TARGET - - if [[ "$EXAMPLE" == "homekit_switch" && "$TARGET" == "esp32h2" ]]; then - - echo "Skipping homekit_switch build for esp32h2" - - continue - - fi - rm -rf managed_components dependencies.lock build sdkconfig sdkconfig.old - idf.py set-target $TARGET - idf.py build @@ -85,10 +74,10 @@ before_script: - cp $CI_PROJECT_DIR/examples/$EXAMPLE/build/*.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/$EXAMPLE/$TARGET/ - done - echo Build Complete for $EXAMPLE - - done - if [[ "$EXAMPLE" == "thread_br" ]]; then - - sed -i "/CONFIG_LWIP_IPV6_NUM_ADDRESSES=12/c\\CONFIG_LWIP_IPV6_NUM_ADDRESSES=8" sdkconfig.defaults + - sed -i "/CONFIG_LWIP_IPV6_NUM_ADDRESSES=12/c\\CONFIG_LWIP_IPV6_NUM_ADDRESSES=8" sdkconfig.defaults - fi + - done # Generating zip file for binaries generated - cd $CI_PROJECT_DIR - echo Generating zip file for binaries generated @@ -119,6 +108,33 @@ before_script: - echo Generating zip file for binaries generated - tar -zcvf esp-rainmaker-bins-${CI_JOB_ID}.zip esp-rainmaker-bins-${CI_JOB_ID}/ +.build_homekit_examples: &build_homekit_examples + - pip install --upgrade idf-component-manager + # Clone esp-homekit-sdk + - cd $CI_PROJECT_DIR/examples/homekit_switch + - cd components + - echo Cloning esp-homekit-sdk + - git clone --recursive --branch master --depth 1 https://github.com/espressif/esp-homekit-sdk.git + - cd .. + - export HOMEKIT_PATH=$PWD/components/esp-homekit-sdk + # start building homekit_switch example + - cd $CI_PROJECT_DIR/examples/homekit_switch + - echo Building homekit_switch + # build for the targets + - for TARGET in $EXAMPLE_TARGETS; do + - echo Building for $TARGET + - rm -rf managed_components dependencies.lock build sdkconfig sdkconfig.old + - idf.py set-target $TARGET + - idf.py build + - mkdir -p $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/homekit_switch/$TARGET/ + - cp $CI_PROJECT_DIR/examples/homekit_switch/build/*.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/homekit_switch/$TARGET/ + - done + - echo Build Complete for homekit_switch + # Generating zip file for binaries generated + - cd $CI_PROJECT_DIR + - echo Generating zip file for binaries generated + - tar -zcvf esp-rainmaker-bins-${CI_JOB_ID}.zip esp-rainmaker-bins-${CI_JOB_ID}/ + .build_template: stage: build image: espressif/idf:latest @@ -129,7 +145,7 @@ before_script: EXTRA_CFLAGS: "${PEDANTIC_FLAGS}" EXTRA_CXXFLAGS: "${PEDANTIC_FLAGS}" EXAMPLE_TARGETS: "esp32" - EXAMPLES: "switch led_light fan temperature_sensor multi_device gpio homekit_switch" + EXAMPLES: "switch led_light fan temperature_sensor multi_device gpio" script: - *build_all_examples @@ -183,6 +199,14 @@ build_split_camera: script: - *build_camera_examples +build_homekit: + extends: .build_template + image: espressif/idf:release-v5.5 + variables: + EXAMPLE_TARGETS: "esp32 esp32s2 esp32c3 esp32s3 esp32c6 esp32c2" + script: + - *build_homekit_examples + build_thread_br: extends: .build_template image: espressif/idf:release-v5.3