更新UI。增加时间和IP显示
This commit is contained in:
@@ -1,34 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
WIFI_CONNECT_STATUS_IDLE = 0,
|
||||
WIFI_CONNECT_STATUS_PROVISIONING,
|
||||
WIFI_CONNECT_STATUS_CONNECTING,
|
||||
WIFI_CONNECT_STATUS_CONNECTED,
|
||||
WIFI_CONNECT_STATUS_FAILED,
|
||||
WIFI_CONNECT_STATUS_TIMEOUT,
|
||||
} wifi_connect_status_t;
|
||||
|
||||
typedef struct {
|
||||
bool has_config;
|
||||
char ssid[33];
|
||||
char password[65];
|
||||
} wifi_connect_config_t;
|
||||
|
||||
esp_err_t wifi_connect_init(void);
|
||||
esp_err_t wifi_connect_start(void);
|
||||
esp_err_t wifi_connect_stop(void);
|
||||
wifi_connect_status_t wifi_connect_get_status(void);
|
||||
esp_err_t wifi_connect_get_config(wifi_connect_config_t *config);
|
||||
esp_err_t wifi_connect_clear_config(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
WIFI_CONNECT_STATUS_IDLE = 0,
|
||||
WIFI_CONNECT_STATUS_PROVISIONING,
|
||||
WIFI_CONNECT_STATUS_CONNECTING,
|
||||
WIFI_CONNECT_STATUS_CONNECTED,
|
||||
WIFI_CONNECT_STATUS_FAILED,
|
||||
WIFI_CONNECT_STATUS_TIMEOUT,
|
||||
} wifi_connect_status_t;
|
||||
|
||||
typedef struct {
|
||||
bool has_config;
|
||||
char ssid[33];
|
||||
char password[65];
|
||||
} wifi_connect_config_t;
|
||||
|
||||
esp_err_t wifi_connect_init(void);
|
||||
esp_err_t wifi_connect_start(void);
|
||||
esp_err_t wifi_connect_stop(void);
|
||||
wifi_connect_status_t wifi_connect_get_status(void);
|
||||
esp_err_t wifi_connect_get_config(wifi_connect_config_t *config);
|
||||
esp_err_t wifi_connect_clear_config(void);
|
||||
const char* wifi_connect_get_ip(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -323,6 +323,18 @@ wifi_connect_status_t wifi_connect_get_status(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
const char *wifi_connect_get_ip(void)
|
||||
{
|
||||
if (!s_ctx.initialized || s_ctx.lock == NULL)
|
||||
return "0.0.0.0";
|
||||
|
||||
static char ip_buf[16];
|
||||
xSemaphoreTake(s_ctx.lock, portMAX_DELAY);
|
||||
strncpy(ip_buf, s_ctx.sta_ip, sizeof(ip_buf));
|
||||
xSemaphoreGive(s_ctx.lock);
|
||||
return ip_buf;
|
||||
}
|
||||
|
||||
static esp_err_t wifi_connect_send_json(httpd_req_t *req, const char *json)
|
||||
{
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
|
||||
Reference in New Issue
Block a user