Updated SSID/Password mechanism

This commit is contained in:
2025-07-17 17:40:21 -06:00
parent 0283d87aca
commit c163389160
2 changed files with 13 additions and 7 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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);
}