diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1f5b04789..97894d396 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,8 @@ +# 27-December-2024 + +Added ``matter esp factoryreset`` command to factory reset a Matter device. +This command erases the esp-matter and connectedhomeip SDK's non-volatile storage. + # 15-Oct-2024 API Change diff --git a/components/esp_matter_console/CMakeLists.txt b/components/esp_matter_console/CMakeLists.txt index bbfad816e..159f822df 100644 --- a/components/esp_matter_console/CMakeLists.txt +++ b/components/esp_matter_console/CMakeLists.txt @@ -3,7 +3,7 @@ if (CONFIG_ENABLE_CHIP_SHELL) list(APPEND src_dirs ".") endif() -set(priv_req chip mbedtls esp_timer bt openthread) +set(priv_req chip mbedtls esp_timer bt openthread esp_matter) if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") list(APPEND priv_req esp_rcp_update) endif() diff --git a/components/esp_matter_console/esp_matter_console.h b/components/esp_matter_console/esp_matter_console.h index cf9454937..b513cc9cc 100644 --- a/components/esp_matter_console/esp_matter_console.h +++ b/components/esp_matter_console/esp_matter_console.h @@ -155,5 +155,14 @@ esp_err_t otcli_register_commands(); */ esp_err_t udc_register_commands(); +/** Add Factory Reset Commands + * + * Adds the default factory reset commands. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t factoryreset_register_commands(); + } // namespace console } // namespace esp_matter diff --git a/components/esp_matter_console/esp_matter_console_factory_reset.cpp b/components/esp_matter_console/esp_matter_console_factory_reset.cpp new file mode 100644 index 000000000..1156ba2a2 --- /dev/null +++ b/components/esp_matter_console/esp_matter_console_factory_reset.cpp @@ -0,0 +1,40 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +namespace esp_matter { +namespace console { + +static engine factoryreset; + +static esp_err_t factoryreset_dispatch(int argc, char *argv[]) +{ + return factory_reset(); +} + +esp_err_t factoryreset_register_commands() +{ + static const command_t command = { + .name = "factoryreset", + .description = "factoryreset the device. Usage: matter esp factoryreset.", + .handler = factoryreset_dispatch, + }; + return add_commands(&command, 1); +} +} // namespace console +} // namespace esp_matter diff --git a/docs/en/developing.rst b/docs/en/developing.rst index d0e9bbb6a..d62a24409 100644 --- a/docs/en/developing.rst +++ b/docs/en/developing.rst @@ -521,7 +521,7 @@ The console on the device can be used to run commands for testing. It is configu :: - matter device factoryreset + matter esp factoryreset - On-boarding codes: Dump the on-boarding pairing code payloads: diff --git a/examples/all_device_types_app/README.md b/examples/all_device_types_app/README.md index 09e64dc57..640bb46ab 100644 --- a/examples/all_device_types_app/README.md +++ b/examples/all_device_types_app/README.md @@ -24,7 +24,7 @@ On boot-up esp-idf console starts. In order to create a device user have to use - 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 device factoryreset`. +- To delete existing device perform `matter esp factoryreset`. - To add new device, say fan or any other device type use `create --device_type=fan`. Setup OTBR for a device diff --git a/examples/all_device_types_app/main/app_main.cpp b/examples/all_device_types_app/main/app_main.cpp index add9c41dd..480a8fc27 100644 --- a/examples/all_device_types_app/main/app_main.cpp +++ b/examples/all_device_types_app/main/app_main.cpp @@ -216,6 +216,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #ifdef CONFIG_OPENTHREAD_CLI esp_matter::console::otcli_register_commands(); diff --git a/examples/bridge_apps/blemesh_bridge/main/app_main.cpp b/examples/bridge_apps/blemesh_bridge/main/app_main.cpp index e9f2dedf7..6a66096c1 100644 --- a/examples/bridge_apps/blemesh_bridge/main/app_main.cpp +++ b/examples/bridge_apps/blemesh_bridge/main/app_main.cpp @@ -145,6 +145,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/bridge_apps/bridge_cli/main/app_main.cpp b/examples/bridge_apps/bridge_cli/main/app_main.cpp index 77f55c578..9c31ee3f5 100644 --- a/examples/bridge_apps/bridge_cli/main/app_main.cpp +++ b/examples/bridge_apps/bridge_cli/main/app_main.cpp @@ -97,6 +97,7 @@ extern "C" void app_main() esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); esp_matter::console::bridge_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp b/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp index 3d078ad6f..073a92aa3 100644 --- a/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp +++ b/examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp @@ -193,6 +193,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/bridge_apps/zigbee_bridge/main/app_main.cpp b/examples/bridge_apps/zigbee_bridge/main/app_main.cpp index 658af3ddb..2889cb003 100644 --- a/examples/bridge_apps/zigbee_bridge/main/app_main.cpp +++ b/examples/bridge_apps/zigbee_bridge/main/app_main.cpp @@ -145,6 +145,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif launch_app_zboss(); diff --git a/examples/controller/main/app_main.cpp b/examples/controller/main/app_main.cpp index a074ecc90..d180ed46f 100644 --- a/examples/controller/main/app_main.cpp +++ b/examples/controller/main/app_main.cpp @@ -71,6 +71,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #if CONFIG_ESP_MATTER_CONTROLLER_ENABLE esp_matter::console::controller_register_commands(); diff --git a/examples/demo/badge/main/app_main.cpp b/examples/demo/badge/main/app_main.cpp index f83cf15bf..5a2da974e 100644 --- a/examples/demo/badge/main/app_main.cpp +++ b/examples/demo/badge/main/app_main.cpp @@ -361,6 +361,7 @@ extern "C" void app_main() esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/door_lock/main/app_main.cpp b/examples/door_lock/main/app_main.cpp index ee130b29d..f830f0728 100644 --- a/examples/door_lock/main/app_main.cpp +++ b/examples/door_lock/main/app_main.cpp @@ -212,6 +212,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); #if CONFIG_OPENTHREAD_CLI esp_matter::console::otcli_register_commands(); #endif diff --git a/examples/generic_switch/main/app_main.cpp b/examples/generic_switch/main/app_main.cpp index c2ef5d4e5..01fb39225 100644 --- a/examples/generic_switch/main/app_main.cpp +++ b/examples/generic_switch/main/app_main.cpp @@ -245,6 +245,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 3d572e76d..95ac16c37 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -225,6 +225,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); #if CONFIG_OPENTHREAD_CLI esp_matter::console::otcli_register_commands(); #endif diff --git a/examples/light_switch/main/app_main.cpp b/examples/light_switch/main/app_main.cpp index 39324d317..f8d519409 100644 --- a/examples/light_switch/main/app_main.cpp +++ b/examples/light_switch/main/app_main.cpp @@ -159,6 +159,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/light_wifi_prov/main/app_main.cpp b/examples/light_wifi_prov/main/app_main.cpp index 130bf6891..6aa7167fe 100644 --- a/examples/light_wifi_prov/main/app_main.cpp +++ b/examples/light_wifi_prov/main/app_main.cpp @@ -317,6 +317,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/multiple_on_off_plugin_units/main/app_main.cpp b/examples/multiple_on_off_plugin_units/main/app_main.cpp index 9bc398cd8..2037d9c6e 100644 --- a/examples/multiple_on_off_plugin_units/main/app_main.cpp +++ b/examples/multiple_on_off_plugin_units/main/app_main.cpp @@ -237,6 +237,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); #if CONFIG_OPENTHREAD_CLI esp_matter::console::otcli_register_commands(); #endif diff --git a/examples/ota_provider/main/app_main.cpp b/examples/ota_provider/main/app_main.cpp index 913f4407e..c1163aadf 100644 --- a/examples/ota_provider/main/app_main.cpp +++ b/examples/ota_provider/main/app_main.cpp @@ -68,6 +68,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif // CONFIG_ENABLE_CHIP_SHELL } diff --git a/examples/refrigerator/main/app_main.cpp b/examples/refrigerator/main/app_main.cpp index 47bf3f172..3d8c7e8c7 100644 --- a/examples/refrigerator/main/app_main.cpp +++ b/examples/refrigerator/main/app_main.cpp @@ -113,10 +113,10 @@ extern "C" void app_main() temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config; endpoint_t *endpoint1 = temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); ABORT_APP_ON_FAILURE(endpoint1 != nullptr, ESP_LOGE(TAG, "Failed to create temperature controlled cabinet endpoint")); - + esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpoint1, chip::app::Clusters::TemperatureControl::Id); - // Atlest one of temperature_number and temperature_level feature is mandatory. + // Atlest one of temperature_number and temperature_level feature is mandatory. cluster::temperature_control::feature::temperature_number::config_t temperature_number_config; cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); @@ -148,6 +148,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/room_air_conditioner/main/app_main.cpp b/examples/room_air_conditioner/main/app_main.cpp index b5376af94..5e121ecb6 100644 --- a/examples/room_air_conditioner/main/app_main.cpp +++ b/examples/room_air_conditioner/main/app_main.cpp @@ -175,6 +175,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif } diff --git a/examples/thread_border_router/main/app_main.cpp b/examples/thread_border_router/main/app_main.cpp index bf7a1756c..9cd256373 100644 --- a/examples/thread_border_router/main/app_main.cpp +++ b/examples/thread_border_router/main/app_main.cpp @@ -114,6 +114,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif // CONFIG_ENABLE_CHIP_SHELL } diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index 45eb56e4a..39808313b 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -116,6 +116,7 @@ extern "C" void app_main() #if CONFIG_ENABLE_CHIP_SHELL esp_matter::console::diagnostics_register_commands(); esp_matter::console::wifi_register_commands(); + esp_matter::console::factoryreset_register_commands(); esp_matter::console::init(); #endif }