wifi web interface scan implemented
This commit is contained in:
parent
111839f329
commit
82a2328571
|
|
@ -50,6 +50,8 @@ QueueHandle_t MQTT1MessagesQueueHandle;
|
|||
QueueHandle_t MQTT2MessagesQueueHandle;
|
||||
EventGroupHandle_t transport_event_group;
|
||||
|
||||
wifi_ap_record_t* GetWiFiAPRecord(uint8_t n);
|
||||
|
||||
void StartTimeGet(void);
|
||||
|
||||
void WiFiAPStart(void);
|
||||
|
|
|
|||
|
|
@ -216,6 +216,14 @@ static HTTP_IO_RESULT HTTPPostAdaptersSettings(httpd_req_t *req, char *PostData)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (httpd_query_key_value(PostData, "wifisc", tmp, 4) == ESP_OK)
|
||||
{
|
||||
if (!strcmp(tmp, (const char*) "prs"))
|
||||
{
|
||||
WiFiScan();
|
||||
}
|
||||
}
|
||||
|
||||
if (httpd_query_key_value(PostData, "save", tmp, 5) == ESP_OK ||
|
||||
httpd_query_key_value(PostData, "apply", tmp, 5) == ESP_OK)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ static void HTTPPrint_updstat(char *VarData, void *arg)
|
|||
snprintf(VarData, MAX_DYNVAR_LENGTH, "%s", GetUpdateStatus());
|
||||
}
|
||||
|
||||
|
||||
static void HTTPPrint_idfver(char *VarData, void *arg)
|
||||
{
|
||||
esp_app_desc_t cur_app_info;
|
||||
|
|
@ -347,6 +346,15 @@ static void HTTPPrint_apmacadr(char *VarData, void *arg)
|
|||
{
|
||||
PrintMACFromInterface(VarData, arg, GetAPNetifAdapter());
|
||||
}
|
||||
static void HTTPPrint_wifisc(char *VarData, void *arg)
|
||||
{
|
||||
wifi_ap_record_t *R = GetWiFiAPRecord(*(uint8_t*) (arg));
|
||||
if (!R)
|
||||
return;
|
||||
snprintf(VarData, MAX_DYNVAR_LENGTH, "{\"ssid\":\"%s\",\"rssi\":%i,\"ch\":%d}", R->ssid, R->rssi,
|
||||
R->primary);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_WEBGUIAPP_ETHERNET_ENABLE
|
||||
|
|
@ -481,7 +489,6 @@ void HTTPPrint_gsmmac(char *VarData, void *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_WEBGUIAPP_LORAWAN_ENABLE
|
||||
/*LORAWAN settings*/
|
||||
void HTTPPrint_lren(char *VarData, void *arg)
|
||||
|
|
@ -695,7 +702,6 @@ dyn_var_handler_t HANDLERS_ARRAY[] = {
|
|||
{ "fverav", sizeof("fverav") - 1, &HTTPPrint_fverav },
|
||||
{ "updstat", sizeof("updstat") - 1, &HTTPPrint_updstat },
|
||||
|
||||
|
||||
{ "idfver", sizeof("idfver") - 1, &HTTPPrint_idfver },
|
||||
{ "builddate", sizeof("builddate") - 1, &HTTPPrint_builddate },
|
||||
{ "serial", sizeof("serial") - 1, &HTTPPrint_serial },
|
||||
|
|
@ -730,6 +736,7 @@ dyn_var_handler_t HANDLERS_ARRAY[] = {
|
|||
{ "dns3", sizeof("dns3") - 1, &HTTPPrint_dns3 },
|
||||
{ "macadr", sizeof("macadr") - 1, &HTTPPrint_macadr },
|
||||
{ "apmacadr", sizeof("apmacadr") - 1, &HTTPPrint_apmacadr },
|
||||
{ "wifisc", sizeof("wifisc") - 1, &HTTPPrint_wifisc },
|
||||
#endif
|
||||
|
||||
#if CONFIG_WEBGUIAPP_ETHERNET_ENABLE
|
||||
|
|
@ -746,8 +753,6 @@ dyn_var_handler_t HANDLERS_ARRAY[] = {
|
|||
{ "emacadr", sizeof("emacadr") - 1, &HTTPPrint_emacadr },
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if CONFIG_WEBGUIAPP_GPRS_ENABLE
|
||||
/*GSM modem*/
|
||||
{ "gsmen", sizeof("gsmen") - 1, &HTTPPrint_gsmen },
|
||||
|
|
|
|||
|
|
@ -48,6 +48,19 @@ static EventGroupHandle_t s_wifi_event_group;
|
|||
static int s_retry_num = 0;
|
||||
static bool isWiFiGotIp = false;
|
||||
|
||||
#define DEFAULT_SCAN_LIST_SIZE 20
|
||||
static wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
|
||||
static bool isScanReady = false;
|
||||
|
||||
wifi_ap_record_t* GetWiFiAPRecord(uint8_t n)
|
||||
{
|
||||
if (n < DEFAULT_SCAN_LIST_SIZE)
|
||||
{
|
||||
return &ap_info[n];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
esp_netif_t* GetSTANetifAdapter(void)
|
||||
{
|
||||
return sta_netif;
|
||||
|
|
@ -484,23 +497,21 @@ void WiFiSTAStart(void)
|
|||
xTaskCreate(wifi_init_sta, "InitStationTask", 1024 * 4, (void*) 0, 3, NULL);
|
||||
}
|
||||
|
||||
#define DEFAULT_SCAN_LIST_SIZE 20
|
||||
|
||||
void WiFiScan(void)
|
||||
static void wifi_scan(void *arg)
|
||||
{
|
||||
uint16_t number = DEFAULT_SCAN_LIST_SIZE;
|
||||
wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
|
||||
uint16_t ap_count = 0;
|
||||
memset(ap_info, 0, sizeof(ap_info));
|
||||
|
||||
esp_wifi_scan_start(NULL, true);
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
|
||||
ESP_LOGI(TAG, "Total APs scanned = %u", ap_count);
|
||||
for (int i = 0; (i < DEFAULT_SCAN_LIST_SIZE) && (i < ap_count); i++)
|
||||
{
|
||||
ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid);
|
||||
ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi);
|
||||
ESP_LOGI(TAG, "Channel \t\t%d\n", ap_info[i].primary);
|
||||
}
|
||||
isScanReady = true;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void WiFiScan(void)
|
||||
{
|
||||
isScanReady = false;
|
||||
xTaskCreate(wifi_scan, "ScanWiFiTask", 1024 * 4, (void*) 0, 3, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user