From 1ba21da6cbc63c0c549fb92731e25bedc482eb51 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Thu, 4 Sep 2025 22:25:39 +0200 Subject: Unify the directory, add new analysis methods, unify the code style Signed-off-by: Filip Wandzio --- src/wifi_scan.c | 61 --------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/wifi_scan.c (limited to 'src/wifi_scan.c') diff --git a/src/wifi_scan.c b/src/wifi_scan.c deleted file mode 100644 index e588cfc..0000000 --- a/src/wifi_scan.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "esp_log.h" -#include "esp_wifi.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#define WIFI_SCAN_TASK_STACK_SIZE 4096 -#define WIFI_SCAN_TASK_PRIORITY 5 -#define WIFI_SCAN_MAX_APS 20 -#define WIFI_SCAN_POLL_INTERVAL_MS 500 -#define WIFI_SCAN_DEFAULT_CHANNEL 0 -#define WIFI_SCAN_SHOW_HIDDEN true -#define WIFI_SCAN_TASK_NAME "wifi_scan_task" - -/** - * @brief Task to perform WiFi scanning asynchronously. - * - * Starts a WiFi scan, polls for scan completion, - * retrieves and logs the found access points, then deletes itself. - * - * @param pvParameter Task parameter (unused). - */ -static void wifi_scan_task(void *pvParameter) { - uint16_t ap_count = WIFI_SCAN_MAX_APS; - static wifi_ap_record_t ap_info[WIFI_SCAN_MAX_APS]; - wifi_scan_config_t scan_config = { - .ssid = NULL, - .bssid = NULL, - .channel = WIFI_SCAN_DEFAULT_CHANNEL, - .show_hidden = WIFI_SCAN_SHOW_HIDDEN, - }; - - ESP_LOGI("wifi_scan", "Starting Wi-Fi scan..."); - ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, false)); - - while (true) { - uint16_t finished_ap_count = 0; - ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&finished_ap_count)); - if (finished_ap_count > 0) - break; - vTaskDelay(pdMS_TO_TICKS(WIFI_SCAN_POLL_INTERVAL_MS)); - } - - ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&ap_count, ap_info)); - ESP_LOGI("wifi_scan", "Found %d access points:", ap_count); - for (uint16_t ap_index = 0; ap_index < ap_count; ++ap_index) { - ESP_LOGI("wifi_scan", "%d: SSID: %s, RSSI: %d", ap_index + 1, - ap_info[ap_index].ssid, ap_info[ap_index].rssi); - } - - vTaskDelete(NULL); -} - -/** - * @brief Starts the WiFi scan task. - * - * Creates a FreeRTOS task that runs the WiFi scan asynchronously. - */ -void wifi_scan_start(void) { - xTaskCreate(wifi_scan_task, WIFI_SCAN_TASK_NAME, WIFI_SCAN_TASK_STACK_SIZE, - NULL, WIFI_SCAN_TASK_PRIORITY, NULL); -} -- cgit v1.2.3