wifi_prov_manager: Change the name of an internal timer handle to better reflect the purpose

Signed-off-by: Piyush Shah <piyush@espressif.com>
This commit is contained in:
Piyush Shah 2020-01-03 19:58:59 +05:30 committed by bot
parent 71b4768df8
commit c4fb524d03
2 changed files with 23 additions and 14 deletions

View File

@ -7,4 +7,12 @@ menu "Wi-Fi Provisioning Manager"
help
This sets the maximum number of entries of Wi-Fi scan results that will be kept by the provisioning manager
config WIFI_PROV_AUTOSTOP_TIMEOUT
int "Provisioning auto-stop timeout"
default 30
range 5 600
help
Time (in seconds) after which the Wi-Fi provisioning manager will auto-stop after connecting to
a Wi-Fi network successfully.
endmenu

View File

@ -99,8 +99,8 @@ struct wifi_prov_mgr_ctx {
/* Pointer to proof of possession */
protocomm_security_pop_t pop;
/* Handle to timer */
esp_timer_handle_t timer;
/* Handle for Provisioning Auto Stop timer */
esp_timer_handle_t autostop_timer;
/* State of Wi-Fi Station */
wifi_prov_sta_state_t wifi_state;
@ -567,10 +567,10 @@ static bool wifi_prov_mgr_stop_service(bool blocking)
}
/* Timer not needed anymore */
if (prov_ctx->timer) {
esp_timer_stop(prov_ctx->timer);
esp_timer_delete(prov_ctx->timer);
prov_ctx->timer = NULL;
if (prov_ctx->autostop_timer) {
esp_timer_stop(prov_ctx->autostop_timer);
esp_timer_delete(prov_ctx->autostop_timer);
prov_ctx->autostop_timer = NULL;
}
ESP_LOGD(TAG, "Stopping provisioning");
@ -836,10 +836,11 @@ static void wifi_prov_mgr_event_handler_internal(
prov_ctx->prov_state = WIFI_PROV_STATE_SUCCESS;
/* If auto stop is enabled (default), schedule timer to
* stop provisioning app after 30 seconds. */
* stop provisioning after configured timeout. */
if (!prov_ctx->mgr_info.capabilities.no_auto_stop) {
ESP_LOGD(TAG, "Starting 30s timer for stop_prov_timer_cb()");
esp_timer_start_once(prov_ctx->timer, 30000 * 1000U);
ESP_LOGD(TAG, "Starting %d sec timer for stop_prov_timer_cb()",
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT);
esp_timer_start_once(prov_ctx->autostop_timer, CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT * 1000000U);
}
/* Execute user registered callback handler */
@ -1457,15 +1458,15 @@ esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const
/* If auto stop on completion is enabled (default) create the stopping timer */
if (!prov_ctx->mgr_info.capabilities.no_auto_stop) {
/* Create timer object as a member of app data */
esp_timer_create_args_t timer_conf = {
esp_timer_create_args_t autostop_timer_conf = {
.callback = stop_prov_timer_cb,
.arg = NULL,
.dispatch_method = ESP_TIMER_TASK,
.name = "wifi_prov_mgr_tm"
.name = "wifi_prov_autostop_tm"
};
ret = esp_timer_create(&timer_conf, &prov_ctx->timer);
ret = esp_timer_create(&autostop_timer_conf, &prov_ctx->autostop_timer);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to create timer");
ESP_LOGE(TAG, "Failed to create auto-stop timer");
free((void *)prov_ctx->pop.data);
goto err;
}
@ -1480,7 +1481,7 @@ esp_err_t wifi_prov_mgr_start_provisioning(wifi_prov_security_t security, const
/* Start provisioning service */
ret = wifi_prov_mgr_start_service(service_name, service_key);
if (ret != ESP_OK) {
esp_timer_delete(prov_ctx->timer);
esp_timer_delete(prov_ctx->autostop_timer);
free((void *)prov_ctx->pop.data);
}
ACQUIRE_LOCK(prov_ctx_lock);