Skip to content

Commit

Permalink
Merge branch 'fix/web_netconfig_error_by_wechat_applet' into 'master'
Browse files Browse the repository at this point in the history
fix(ESPAT-2025): Fixed the issue where at web netconfig failed by wechat applet

See merge request application/esp-at!1570
  • Loading branch information
xcguang committed Jun 18, 2024
2 parents 70ff588 + a4e0bf4 commit 6666188
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions components/at/src/at_web_server_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static char *s_at_web_redirect_url = NULL;
} \
} while (0)

#define ESP_AT_WEB_VERSION "1.0"
#define ESP_AT_WEB_FILE_PATH_MAX (ESP_VFS_PATH_MAX + 128)
#define ESP_AT_WEB_SCRATCH_BUFSIZE 320
#define ESP_AT_WEB_WIFI_MAX_RECONNECT_TIMEOUT 60 // 60sec
Expand Down Expand Up @@ -1324,6 +1325,18 @@ static esp_err_t config_wifi_get_handler(httpd_req_t *req)
return ESP_OK;
}

static esp_err_t at_web_version_get_handler(httpd_req_t *req)
{
httpd_resp_set_type(req, "application/json");
char *temp_json_str = ((web_server_context_t*)(req->user_ctx))->scratch;
sprintf(temp_json_str, "{\"version\":\"%s\"}", ESP_AT_WEB_VERSION);
ESP_LOGD(TAG, "ready to send version: %s\n", temp_json_str);

httpd_resp_send(req, temp_json_str, (temp_json_str == NULL) ? 0 : strlen(temp_json_str));

return ESP_OK;
}

static esp_err_t accept_wifi_result_post_handler(httpd_req_t *req)
{
char *buf = ((web_server_context_t*)(req->user_ctx))->scratch;
Expand Down Expand Up @@ -1750,6 +1763,7 @@ static esp_err_t start_web_server(const char *base_path, uint16_t server_port)
ESP_AT_WEB_SERVER_CHECK(httpd_start(&s_server, &config) == ESP_OK, "Start server failed", err_start);

httpd_uri_t httpd_uri_array[] = {
{"/getversion", HTTP_GET, at_web_version_get_handler, s_web_context},
{"/getstainfo", HTTP_GET, config_wifi_get_handler, s_web_context},
{"/setstainfo", HTTP_POST, config_wifi_post_handler, s_web_context},
{"/getresult", HTTP_POST, accept_wifi_result_post_handler, s_web_context},
Expand Down

0 comments on commit 6666188

Please sign in to comment.