aboutsummaryrefslogtreecommitdiff
path: root/main/station.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2021-11-29 17:38:06 -0700
committerJosh Rahm <joshuarahm@gmail.com>2021-11-29 17:38:06 -0700
commitc6a0cf2ff3403e9726ea6429af50bedcfd4f9a01 (patch)
tree428d4348bbf9ea44fa279368002d2c58b9f388c9 /main/station.c
parent1888bc20144559265b0719e5a0f83a5150a867c6 (diff)
downloadesp32-ws2812b-c6a0cf2ff3403e9726ea6429af50bedcfd4f9a01.tar.gz
esp32-ws2812b-c6a0cf2ff3403e9726ea6429af50bedcfd4f9a01.tar.bz2
esp32-ws2812b-c6a0cf2ff3403e9726ea6429af50bedcfd4f9a01.zip
Added simple routine to use a server socket.
Diffstat (limited to 'main/station.c')
-rw-r--r--main/station.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/main/station.c b/main/station.c
index fa1dd0d..8f69f49 100644
--- a/main/station.c
+++ b/main/station.c
@@ -40,7 +40,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
}
}
-void wifi_init_station()
+void wifi_init_station(const char* ssid, const char* psk)
{
/** Initialize the flash. Not exactly sure why this is required, but it is,
* otherwise there will be a fault. */
@@ -76,12 +76,12 @@ void wifi_init_station()
wifi_config_t wifi_config = {
.sta = {
- .ssid = "Wort",
- .password = "psk",
+ // .ssid = ssid,
+ // .password = psk,
/* Setting a password implies station will connect to all security modes including WEP/WPA.
* However these modes are deprecated and not advisable to be used. Incase your Access point
* doesn't support WPA2, these mode can be enabled by commenting below line */
- .threshold.authmode = WIFI_AUTH_WPA2_PSK,
+ .threshold.authmode = WIFI_AUTH_WPA2_PSK,
.pmf_cfg = {
.capable = true,
@@ -89,6 +89,10 @@ void wifi_init_station()
},
},
};
+
+ memcpy(wifi_config.sta.ssid, ssid, strlen(ssid));
+ memcpy(wifi_config.sta.password, psk, strlen(psk));
+
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
ESP_ERROR_CHECK(esp_wifi_start() );
@@ -106,10 +110,10 @@ void wifi_init_station()
* happened. */
if (bits & WIFI_CONNECTED_BIT) {
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
- "Wort", "psk");
+ ssid, psk);
} else if (bits & WIFI_FAIL_BIT) {
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
- "Wort", "psk");
+ ssid, psk);
} else {
ESP_LOGE(TAG, "UNEXPECTED EVENT");
}