Updated SSID/Password mechanism
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -109,4 +109,5 @@ wifi_credentials.h
|
||||
credentials.h
|
||||
|
||||
# Project-specific ignores
|
||||
# Add any project-specific files to ignore here
|
||||
# Add any project-specific files to ignore here
|
||||
main/Kconfig.projbuild
|
||||
17
main/main.c
17
main/main.c
@ -9,11 +9,16 @@
|
||||
#include "ota_server.h"
|
||||
#include "led_strip.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char *TAG = "MAIN";
|
||||
|
||||
// WiFi credentials - Change these to your network
|
||||
#define WIFI_SSID "YOUR_SSID"
|
||||
#define WIFI_PASSWORD "YOUR_PASSWORD"
|
||||
// #define WIFI_SSID "YOUR_SSID"
|
||||
// #define WIFI_PASSWORD "YOUR_PASSWORD"
|
||||
|
||||
const char *ssid = CONFIG_WIFI_SSID;
|
||||
const char *password = CONFIG_WIFI_PASSWORD;
|
||||
|
||||
// Application version
|
||||
#define APP_VERSION "1.0.0"
|
||||
@ -113,16 +118,16 @@ void app_main(void)
|
||||
char stored_pass[65] = {0};
|
||||
|
||||
// Force update with new credentials (remove this after first successful connection)
|
||||
ESP_LOGI(TAG, "Updating WiFi credentials - SSID: '%s'", WIFI_SSID);
|
||||
wifi_manager_set_credentials(WIFI_SSID, WIFI_PASSWORD);
|
||||
ESP_LOGI(TAG, "Updating WiFi credentials - SSID: '%s'", ssid);
|
||||
wifi_manager_set_credentials(ssid, password);
|
||||
|
||||
/*
|
||||
// Normal flow - only update if no credentials stored
|
||||
if (wifi_manager_get_credentials(stored_ssid, sizeof(stored_ssid),
|
||||
stored_pass, sizeof(stored_pass)) != ESP_OK) {
|
||||
ESP_LOGI(TAG, "No stored WiFi credentials, saving default ones");
|
||||
ESP_LOGI(TAG, "Setting SSID: '%s'", WIFI_SSID);
|
||||
wifi_manager_set_credentials(WIFI_SSID, WIFI_PASSWORD);
|
||||
ESP_LOGI(TAG, "Setting SSID: '%s'", ssid);
|
||||
wifi_manager_set_credentials(ssid, password);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Found stored credentials - SSID: '%s'", stored_ssid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user