@@ -2350,6 +2350,13 @@ esp_err_t network_prov_mgr_reset_wifi_sm_state_on_failure(void)
23502350 ACQUIRE_LOCK (prov_ctx_lock );
23512351
23522352 esp_err_t err = ESP_OK ;
2353+ /* If already in STARTED state, reset has already been performed (e.g., by firmware).
2354+ * Return success as the device is effectively already reset and in provisioning mode. */
2355+ if (prov_ctx -> prov_state == NETWORK_PROV_STATE_STARTED ) {
2356+ ESP_LOGD (TAG , "Reset already performed, device already in provisioning mode" );
2357+ goto exit ;
2358+ }
2359+
23532360 if (prov_ctx -> prov_state != NETWORK_PROV_STATE_FAIL ) {
23542361 ESP_LOGE (TAG , "Trying reset when not in failure state. Current state: %d" , prov_ctx -> prov_state );
23552362 err = ESP_ERR_INVALID_STATE ;
@@ -2448,6 +2455,13 @@ esp_err_t network_prov_mgr_reset_thread_sm_state_on_failure(void)
24482455 otInstance * instance = esp_openthread_get_instance ();
24492456
24502457 esp_openthread_lock_acquire (portMAX_DELAY );
2458+ /* If already in STARTED state, reset has already been performed (e.g., by firmware).
2459+ * Return success as the device is effectively already reset and in provisioning mode. */
2460+ if (prov_ctx -> prov_state == NETWORK_PROV_STATE_STARTED ) {
2461+ ESP_LOGD (TAG , "Reset already performed, device already in provisioning mode" );
2462+ goto exit ;
2463+ }
2464+
24512465 if (prov_ctx -> prov_state != NETWORK_PROV_STATE_FAIL ) {
24522466 ESP_LOGE (TAG , "Trying reset when not in failure state. Current state: %d" , prov_ctx -> prov_state );
24532467 err = ESP_ERR_INVALID_STATE ;
0 commit comments