Skip to content

Commit

Permalink
Fix #278: UI locks when trying to reconnect to a disabled Wi-Fi AP wi…
Browse files Browse the repository at this point in the history
…th a saved password (#279)
  • Loading branch information
TheSomeMan authored Jan 10, 2024
1 parent 3f550d8 commit 7b12c77
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/http_server_handle_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,42 +423,41 @@ http_server_handle_req_post_connect_json(const http_req_body_t http_body)
wifiman_msg_send_cmd_connect_eth();
return http_server_resp_200_json("{}");
}
if (!login_info.is_ssid_null)
if (login_info.is_ssid_null)
{
if (login_info.is_password_null)
/* bad request the authentication header is not complete/not the correct format */
return http_server_resp_400();
}
if (login_info.is_password_null)
{
const wifiman_wifi_ssid_t saved_ssid = wifiman_config_sta_get_ssid();
if (0 == strcmp(saved_ssid.ssid_buf, login_info.ssid.ssid_buf))
{
const wifiman_wifi_ssid_t saved_ssid = wifiman_config_sta_get_ssid();
if (0 == strcmp(saved_ssid.ssid_buf, login_info.ssid.ssid_buf))
{
LOG_INFO("POST /connect.json: SSID:%s, PWD: NULL - reconnect to saved WiFi", login_info.ssid.ssid_buf);
}
else
{
LOG_WARN(
"POST /connect.json: SSID:%s, PWD: NULL - try to connect to WiFi without authentication",
login_info.ssid.ssid_buf);
wifiman_config_sta_set_ssid_and_password(&login_info.ssid, NULL);
}
wifi_manager_lock();
json_network_info_clear();
wifi_manager_unlock();
LOG_DBG("http_server_netconn_serve: wifi_manager_connect_async() call");
wifi_manager_start_timer_reconnect_sta_after_timeout();
return http_server_resp_200_json("{}");
LOG_INFO("POST /connect.json: SSID:%s, PWD: NULL - reconnect to saved WiFi", login_info.ssid.ssid_buf);
}
else
{
LOG_WARN(
"POST /connect.json: SSID:%s, PWD: NULL - try to connect to WiFi without authentication",
login_info.ssid.ssid_buf);
wifiman_config_sta_set_ssid_and_password(&login_info.ssid, NULL);
}
}
else
{
LOG_DBG(
"POST /connect.json: SSID:%s, PWD: %s - connect to WiFi",
login_info.ssid.ssid_buf,
login_info.password.password_buf);
LOG_INFO("POST /connect.json: SSID:%s, PWD: ******** - connect to WiFi", login_info.ssid.ssid_buf);
wifiman_config_sta_set_ssid_and_password(&login_info.ssid, &login_info.password);

LOG_DBG("http_server_netconn_serve: wifi_manager_connect_async() call");
wifi_manager_connect_async();
return http_server_resp_200_json("{}");
}
/* bad request the authentication header is not complete/not the correct format */
return http_server_resp_400();
wifi_manager_lock();
json_network_info_clear();
wifi_manager_unlock();
LOG_DBG("http_server_netconn_serve: wifi_manager_connect_async() call");
wifi_manager_connect_async();
return http_server_resp_200_json("{}");
}

static http_server_resp_t
Expand Down

0 comments on commit 7b12c77

Please sign in to comment.