Refine Wi-Fi, mDNS, and terminal lifecycles
- Stage disabled station profile edits without restarting the radio - Make mDNS initialization failure-isolated and reannounce in place - Document deferred admin actions and explicit browser disconnect behavior
This commit is contained in:
+35
-5
@@ -12,6 +12,8 @@
|
||||
|
||||
static SemaphoreHandle_t s_mutex;
|
||||
static mdns_config_t s_config;
|
||||
static bool s_component_initialized;
|
||||
static bool s_initialization_failed;
|
||||
static bool s_announced;
|
||||
static esp_err_t s_last_error;
|
||||
|
||||
@@ -91,10 +93,16 @@ esp_err_t mdns_service_start(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
lock_service();
|
||||
if (s_announced) {
|
||||
if (s_component_initialized) {
|
||||
s_announced = true;
|
||||
unlock_service();
|
||||
return ESP_OK;
|
||||
}
|
||||
if (s_initialization_failed) {
|
||||
esp_err_t error = s_last_error;
|
||||
unlock_service();
|
||||
return error;
|
||||
}
|
||||
mdns_config_t config = s_config;
|
||||
unlock_service();
|
||||
|
||||
@@ -112,6 +120,8 @@ esp_err_t mdns_service_start(void)
|
||||
}
|
||||
|
||||
lock_service();
|
||||
s_component_initialized = error == ESP_OK;
|
||||
s_initialization_failed = error != ESP_OK;
|
||||
s_announced = error == ESP_OK;
|
||||
s_last_error = error;
|
||||
unlock_service();
|
||||
@@ -124,10 +134,30 @@ void mdns_service_stop(void)
|
||||
return;
|
||||
}
|
||||
lock_service();
|
||||
bool announced = s_announced;
|
||||
s_announced = false;
|
||||
unlock_service();
|
||||
if (announced) {
|
||||
mdns_free();
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t mdns_service_reannounce(void)
|
||||
{
|
||||
if (s_mutex == NULL) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
lock_service();
|
||||
if (!s_component_initialized) {
|
||||
esp_err_t error = s_initialization_failed ? s_last_error : ESP_ERR_INVALID_STATE;
|
||||
unlock_service();
|
||||
return error;
|
||||
}
|
||||
mdns_config_t config = s_config;
|
||||
unlock_service();
|
||||
|
||||
char hostname[MDNS_CONFIG_SUFFIX_MAX_LEN + 5U] = {0};
|
||||
make_hostname(&config, hostname, sizeof(hostname));
|
||||
esp_err_t error = mdns_hostname_set(hostname);
|
||||
|
||||
lock_service();
|
||||
s_last_error = error;
|
||||
unlock_service();
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user