1313#include "base_components/led.h"
1414#include "base_components/network_indicator.h"
1515#include "config_nv.h"
16+ #include "device_config/reset.h"
1617#include "hal/system.h"
1718#include "hal/zigbee.h"
1819#include "hal/zigbee_ota.h"
@@ -52,12 +53,11 @@ uint8_t relay_clusters_cnt = 0;
5253hal_zigbee_cluster clusters [32 ];
5354hal_zigbee_endpoint endpoints [10 ];
5455
55- void reset_to_default_config ();
5656uint32_t parse_int (const char * s );
5757char * seek_until (char * cursor , char needle );
5858char * extract_next_entry (char * * cursor );
5959
60- void onResetClicked (void * _ ) { hal_zigbee_leave_network (); }
60+ void on_reset_clicked (void * _ ) { reset_all (); }
6161
6262void parse_config () {
6363 device_config_read_from_nv ();
@@ -68,7 +68,7 @@ void parse_config() {
6868 basic_cluster .manuName [0 ] = strlen (zb_manufacturer );
6969 if (basic_cluster .manuName [0 ] > 31 ) {
7070 printf ("Manufacturer too big\r\n" );
71- reset_to_default_config ();
71+ reset_all ();
7272 }
7373 memcpy (basic_cluster .manuName + 1 , zb_manufacturer ,
7474 basic_cluster .manuName [0 ]);
@@ -77,7 +77,7 @@ void parse_config() {
7777 basic_cluster .modelId [0 ] = strlen (zb_model );
7878 if (basic_cluster .modelId [0 ] > 31 ) {
7979 printf ("Model too big\r\n" );
80- reset_to_default_config ();
80+ reset_all ();
8181 }
8282 memcpy (basic_cluster .modelId + 1 , zb_model , basic_cluster .modelId [0 ]);
8383
@@ -93,7 +93,7 @@ void parse_config() {
9393 buttons [buttons_cnt ].pin = pin ;
9494 buttons [buttons_cnt ].long_press_duration_ms = 2000 ;
9595 buttons [buttons_cnt ].multi_press_duration_ms = 800 ;
96- buttons [buttons_cnt ].on_long_press = onResetClicked ;
96+ buttons [buttons_cnt ].on_long_press = on_reset_clicked ;
9797 buttons_cnt ++ ;
9898 } else if (entry [0 ] == 'L' ) {
9999 hal_gpio_pin_t pin = hal_gpio_parse_pin (entry + 1 );
@@ -277,12 +277,6 @@ void init_reporting() {
277277
278278// Helper functions
279279
280- __attribute__((noreturn )) void reset_to_default_config () {
281- printf ("RESET reset_to_default_config\r\n" );
282- device_config_remove_from_nv ();
283- hal_system_reset ();
284- }
285-
286280char * seek_until (char * cursor , char needle ) {
287281 while (* cursor != needle && * cursor != '\0' ) {
288282 cursor ++ ;
0 commit comments