Refactor: Apply automated formatting, optimize includes, and consolidate code styles across components.
Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
// Created by shinys on 25. 9. 1.
|
||||
//
|
||||
|
||||
#include "priv_wifi.h"
|
||||
#include <string.h>
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_log.h"
|
||||
#include "nconfig.h"
|
||||
#include "esp_netif.h"
|
||||
#include "wifi.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "lwip/ip4_addr.h"
|
||||
#include "nconfig.h"
|
||||
#include "priv_wifi.h"
|
||||
#include "wifi.h"
|
||||
|
||||
static const char *TAG = "AP";
|
||||
static const char* TAG = "AP";
|
||||
|
||||
#define DEFAULT_AP_SSID "odroid-pm"
|
||||
#define DEFAULT_AP_PASS "powermate"
|
||||
@@ -24,9 +24,10 @@ static const char *TAG = "AP";
|
||||
void wifi_init_ap(void)
|
||||
{
|
||||
// Get the network interface handle for the AP
|
||||
esp_netif_t *p_netif_ap = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
esp_netif_t* p_netif_ap = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
|
||||
if (p_netif_ap) {
|
||||
if (p_netif_ap)
|
||||
{
|
||||
ESP_LOGI(TAG, "Setting AP static IP to 192.168.4.1");
|
||||
esp_netif_dhcps_stop(p_netif_ap); // Stop DHCP server to apply new IP settings
|
||||
|
||||
@@ -41,37 +42,46 @@ void wifi_init_ap(void)
|
||||
|
||||
// Configure Wi-Fi AP settings
|
||||
wifi_config_t wifi_config = {
|
||||
.ap = {
|
||||
.channel = AP_CHANNEL,
|
||||
.max_connection = AP_MAX_CONN,
|
||||
.authmode = WIFI_AUTH_WPA2_PSK,
|
||||
.pmf_cfg = {
|
||||
.required = false,
|
||||
.ap =
|
||||
{
|
||||
.channel = AP_CHANNEL,
|
||||
.max_connection = AP_MAX_CONN,
|
||||
.authmode = WIFI_AUTH_WPA2_PSK,
|
||||
.pmf_cfg =
|
||||
{
|
||||
.required = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Read SSID and password from NVS (nconfig)
|
||||
size_t len;
|
||||
if (nconfig_get_str_len(AP_SSID, &len) == ESP_OK && len > 1) {
|
||||
if (nconfig_get_str_len(AP_SSID, &len) == ESP_OK && len > 1)
|
||||
{
|
||||
nconfig_read(AP_SSID, (char*)wifi_config.ap.ssid, sizeof(wifi_config.ap.ssid));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy((char*)wifi_config.ap.ssid, DEFAULT_AP_SSID);
|
||||
}
|
||||
|
||||
if (nconfig_get_str_len(AP_PASSWORD, &len) == ESP_OK && len > 1) {
|
||||
if (nconfig_get_str_len(AP_PASSWORD, &len) == ESP_OK && len > 1)
|
||||
{
|
||||
nconfig_read(AP_PASSWORD, (char*)wifi_config.ap.password, sizeof(wifi_config.ap.password));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy((char*)wifi_config.ap.password, DEFAULT_AP_PASS);
|
||||
}
|
||||
|
||||
// If password is not set, use open authentication
|
||||
if (strlen((char*)wifi_config.ap.password) == 0) {
|
||||
if (strlen((char*)wifi_config.ap.password) == 0)
|
||||
{
|
||||
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_ap finished. SSID: %s, Password: %s, Channel: %d",
|
||||
(char*)wifi_config.ap.ssid, "********", AP_CHANNEL);
|
||||
ESP_LOGI(TAG, "wifi_init_ap finished. SSID: %s, Password: %s, Channel: %d", (char*)wifi_config.ap.ssid, "********",
|
||||
AP_CHANNEL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user