Skip to content

Commit badac88

Browse files
committed
Merge branch 'factory-reset' into 'main'
components/esp_matter_console: add the "matter esp factoryreset" See merge request app-frameworks/esp-matter!984
2 parents cfb11d5 + 9575c13 commit badac88

File tree

24 files changed

+77
-5
lines changed

24 files changed

+77
-5
lines changed

RELEASE_NOTES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 27-December-2024
2+
3+
Added ``matter esp factoryreset`` command to factory reset a Matter device.
4+
This command erases the esp-matter and connectedhomeip SDK's non-volatile storage.
5+
16
# 15-Oct-2024
27

38
API Change

components/esp_matter_console/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (CONFIG_ENABLE_CHIP_SHELL)
33
list(APPEND src_dirs ".")
44
endif()
55

6-
set(priv_req chip mbedtls esp_timer bt openthread)
6+
set(priv_req chip mbedtls esp_timer bt openthread esp_matter)
77
if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
88
list(APPEND priv_req esp_rcp_update)
99
endif()

components/esp_matter_console/esp_matter_console.h

+9
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,14 @@ esp_err_t otcli_register_commands();
155155
*/
156156
esp_err_t udc_register_commands();
157157

158+
/** Add Factory Reset Commands
159+
*
160+
* Adds the default factory reset commands.
161+
*
162+
* @return ESP_OK on success.
163+
* @return error in case of failure.
164+
*/
165+
esp_err_t factoryreset_register_commands();
166+
158167
} // namespace console
159168
} // namespace esp_matter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <esp_check.h>
16+
#include <esp_log.h>
17+
#include <esp_matter_console.h>
18+
#include <esp_matter_core.h>
19+
20+
namespace esp_matter {
21+
namespace console {
22+
23+
static engine factoryreset;
24+
25+
static esp_err_t factoryreset_dispatch(int argc, char *argv[])
26+
{
27+
return factory_reset();
28+
}
29+
30+
esp_err_t factoryreset_register_commands()
31+
{
32+
static const command_t command = {
33+
.name = "factoryreset",
34+
.description = "factoryreset the device. Usage: matter esp factoryreset.",
35+
.handler = factoryreset_dispatch,
36+
};
37+
return add_commands(&command, 1);
38+
}
39+
} // namespace console
40+
} // namespace esp_matter

docs/en/developing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ The console on the device can be used to run commands for testing. It is configu
521521

522522
::
523523

524-
matter device factoryreset
524+
matter esp factoryreset
525525

526526
- On-boarding codes: Dump the on-boarding pairing code payloads:
527527

examples/all_device_types_app/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ On boot-up esp-idf console starts. In order to create a device user have to use
2424

2525
- Use `create --device_type` to list all supported device types.
2626
- Use `create --device_type=on_off_light` to create light device.
27-
- To delete existing device perform `matter device factoryreset`.
27+
- To delete existing device perform `matter esp factoryreset`.
2828
- To add new device, say fan or any other device type use `create --device_type=fan`.
2929

3030
Setup OTBR for a device

examples/all_device_types_app/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ extern "C" void app_main()
216216
#if CONFIG_ENABLE_CHIP_SHELL
217217
esp_matter::console::diagnostics_register_commands();
218218
esp_matter::console::wifi_register_commands();
219+
esp_matter::console::factoryreset_register_commands();
219220
esp_matter::console::init();
220221
#ifdef CONFIG_OPENTHREAD_CLI
221222
esp_matter::console::otcli_register_commands();

examples/bridge_apps/blemesh_bridge/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ extern "C" void app_main()
145145

146146
#if CONFIG_ENABLE_CHIP_SHELL
147147
esp_matter::console::diagnostics_register_commands();
148+
esp_matter::console::factoryreset_register_commands();
148149
esp_matter::console::init();
149150
#endif
150151
}

examples/bridge_apps/bridge_cli/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ extern "C" void app_main()
9797
esp_matter::console::diagnostics_register_commands();
9898
esp_matter::console::wifi_register_commands();
9999
esp_matter::console::bridge_register_commands();
100+
esp_matter::console::factoryreset_register_commands();
100101
esp_matter::console::init();
101102
#endif
102103
}

examples/bridge_apps/esp-now_bridge_light/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ extern "C" void app_main()
193193
#if CONFIG_ENABLE_CHIP_SHELL
194194
esp_matter::console::diagnostics_register_commands();
195195
esp_matter::console::wifi_register_commands();
196+
esp_matter::console::factoryreset_register_commands();
196197
esp_matter::console::init();
197198
#endif
198199
}

examples/bridge_apps/zigbee_bridge/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ extern "C" void app_main()
145145
#if CONFIG_ENABLE_CHIP_SHELL
146146
esp_matter::console::diagnostics_register_commands();
147147
esp_matter::console::wifi_register_commands();
148+
esp_matter::console::factoryreset_register_commands();
148149
esp_matter::console::init();
149150
#endif
150151
launch_app_zboss();

examples/controller/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extern "C" void app_main()
7171
#if CONFIG_ENABLE_CHIP_SHELL
7272
esp_matter::console::diagnostics_register_commands();
7373
esp_matter::console::wifi_register_commands();
74+
esp_matter::console::factoryreset_register_commands();
7475
esp_matter::console::init();
7576
#if CONFIG_ESP_MATTER_CONTROLLER_ENABLE
7677
esp_matter::console::controller_register_commands();

examples/demo/badge/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ extern "C" void app_main()
361361

362362
esp_matter::console::diagnostics_register_commands();
363363
esp_matter::console::wifi_register_commands();
364+
esp_matter::console::factoryreset_register_commands();
364365
esp_matter::console::init();
365366
#endif
366367
}

examples/door_lock/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ extern "C" void app_main()
212212
#if CONFIG_ENABLE_CHIP_SHELL
213213
esp_matter::console::diagnostics_register_commands();
214214
esp_matter::console::wifi_register_commands();
215+
esp_matter::console::factoryreset_register_commands();
215216
#if CONFIG_OPENTHREAD_CLI
216217
esp_matter::console::otcli_register_commands();
217218
#endif

examples/generic_switch/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ extern "C" void app_main()
245245
#if CONFIG_ENABLE_CHIP_SHELL
246246
esp_matter::console::diagnostics_register_commands();
247247
esp_matter::console::wifi_register_commands();
248+
esp_matter::console::factoryreset_register_commands();
248249
esp_matter::console::init();
249250
#endif
250251

examples/light/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ extern "C" void app_main()
225225
#if CONFIG_ENABLE_CHIP_SHELL
226226
esp_matter::console::diagnostics_register_commands();
227227
esp_matter::console::wifi_register_commands();
228+
esp_matter::console::factoryreset_register_commands();
228229
#if CONFIG_OPENTHREAD_CLI
229230
esp_matter::console::otcli_register_commands();
230231
#endif

examples/light_switch/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ extern "C" void app_main()
159159
#if CONFIG_ENABLE_CHIP_SHELL
160160
esp_matter::console::diagnostics_register_commands();
161161
esp_matter::console::wifi_register_commands();
162+
esp_matter::console::factoryreset_register_commands();
162163
esp_matter::console::init();
163164
#endif
164165
}

examples/light_wifi_prov/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ extern "C" void app_main()
317317
#if CONFIG_ENABLE_CHIP_SHELL
318318
esp_matter::console::diagnostics_register_commands();
319319
esp_matter::console::wifi_register_commands();
320+
esp_matter::console::factoryreset_register_commands();
320321
esp_matter::console::init();
321322
#endif
322323
}

examples/multiple_on_off_plugin_units/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ extern "C" void app_main()
237237
#if CONFIG_ENABLE_CHIP_SHELL
238238
esp_matter::console::diagnostics_register_commands();
239239
esp_matter::console::wifi_register_commands();
240+
esp_matter::console::factoryreset_register_commands();
240241
#if CONFIG_OPENTHREAD_CLI
241242
esp_matter::console::otcli_register_commands();
242243
#endif

examples/ota_provider/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extern "C" void app_main()
6868
#if CONFIG_ENABLE_CHIP_SHELL
6969
esp_matter::console::diagnostics_register_commands();
7070
esp_matter::console::wifi_register_commands();
71+
esp_matter::console::factoryreset_register_commands();
7172
esp_matter::console::init();
7273
#endif // CONFIG_ENABLE_CHIP_SHELL
7374
}

examples/refrigerator/main/app_main.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ extern "C" void app_main()
113113
temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config;
114114
endpoint_t *endpoint1 = temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL);
115115
ABORT_APP_ON_FAILURE(endpoint1 != nullptr, ESP_LOGE(TAG, "Failed to create temperature controlled cabinet endpoint"));
116-
116+
117117
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpoint1, chip::app::Clusters::TemperatureControl::Id);
118118

119-
// Atlest one of temperature_number and temperature_level feature is mandatory.
119+
// Atlest one of temperature_number and temperature_level feature is mandatory.
120120
cluster::temperature_control::feature::temperature_number::config_t temperature_number_config;
121121
cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config);
122122

@@ -148,6 +148,7 @@ extern "C" void app_main()
148148
#if CONFIG_ENABLE_CHIP_SHELL
149149
esp_matter::console::diagnostics_register_commands();
150150
esp_matter::console::wifi_register_commands();
151+
esp_matter::console::factoryreset_register_commands();
151152
esp_matter::console::init();
152153
#endif
153154
}

examples/room_air_conditioner/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ extern "C" void app_main()
175175
#if CONFIG_ENABLE_CHIP_SHELL
176176
esp_matter::console::diagnostics_register_commands();
177177
esp_matter::console::wifi_register_commands();
178+
esp_matter::console::factoryreset_register_commands();
178179
esp_matter::console::init();
179180
#endif
180181
}

examples/thread_border_router/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ extern "C" void app_main()
114114
#if CONFIG_ENABLE_CHIP_SHELL
115115
esp_matter::console::diagnostics_register_commands();
116116
esp_matter::console::wifi_register_commands();
117+
esp_matter::console::factoryreset_register_commands();
117118
esp_matter::console::init();
118119
#endif // CONFIG_ENABLE_CHIP_SHELL
119120
}

examples/zap_light/main/app_main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ extern "C" void app_main()
116116
#if CONFIG_ENABLE_CHIP_SHELL
117117
esp_matter::console::diagnostics_register_commands();
118118
esp_matter::console::wifi_register_commands();
119+
esp_matter::console::factoryreset_register_commands();
119120
esp_matter::console::init();
120121
#endif
121122
}

0 commit comments

Comments
 (0)