aboutsummaryrefslogtreecommitdiffstats
path: root/src/wifi.c
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2025-09-04 22:25:39 +0200
committerFilip Wandzio <contact@philw.dev>2025-09-04 22:25:39 +0200
commit1ba21da6cbc63c0c549fb92731e25bedc482eb51 (patch)
treeddf6fc2259a2495f8de336a07873cc3c6796785e /src/wifi.c
parente00f3a9ede1b8e46b480bd68daf48da0bb08acae (diff)
downloade1-1ba21da6cbc63c0c549fb92731e25bedc482eb51.tar.gz
e1-1ba21da6cbc63c0c549fb92731e25bedc482eb51.zip
Unify the directory, add new analysis methods, unify the code style
Signed-off-by: Filip Wandzio <contact@philw.dev>
Diffstat (limited to 'src/wifi.c')
-rw-r--r--src/wifi.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/wifi.c b/src/wifi.c
deleted file mode 100644
index 8d6b29d..0000000
--- a/src/wifi.c
+++ /dev/null
@@ -1,49 +0,0 @@
1#include "wifi.h"
2#include "config.h"
3#include "esp_event.h"
4#include "esp_netif.h"
5#include "esp_wifi.h"
6#include "freertos/FreeRTOS.h"
7#include "freertos/task.h"
8#include <string.h>
9
10#define WIFI_SCAN_DELAY_MS 3000
11
12/**
13 * @brief Initialize WiFi in station mode.
14 *
15 * This function performs the following steps:
16 * - Creates the default WiFi station network interface.
17 * - Initializes the WiFi driver with default configuration.
18 * - Sets WiFi mode to station.
19 * - Starts WiFi.
20 * - Starts scanning for available WiFi networks.
21 * - Waits for a predefined delay to allow scanning to complete.
22 * - Configures the WiFi station with SSID and password.
23 * - Connects to the configured WiFi network.
24 *
25 * The SSID and password are defined in the configuration headers.
26 */
27void wifi_init_sta(void) {
28 esp_netif_create_default_wifi_sta();
29
30 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
31 if (esp_wifi_init(&cfg) != ESP_OK) {
32 return;
33 }
34
35 esp_wifi_set_mode(WIFI_MODE_STA);
36 esp_wifi_start();
37
38 wifi_scan_start();
39 vTaskDelay(pdMS_TO_TICKS(WIFI_SCAN_DELAY_MS));
40
41 wifi_config_t wifi_config = {0};
42 strncpy((char *)wifi_config.sta.ssid, WIFI_SSID,
43 sizeof(wifi_config.sta.ssid) - 1);
44 strncpy((char *)wifi_config.sta.password, WIFI_PASS,
45 sizeof(wifi_config.sta.password) - 1);
46
47 esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
48 esp_wifi_connect();
49}