From c1633891608861e05b2be16e18a19a6d5b8ab630 Mon Sep 17 00:00:00 2001 From: Stephen Minakian Date: Thu, 17 Jul 2025 17:40:21 -0600 Subject: [PATCH] Updated SSID/Password mechanism --- .gitignore | 3 ++- main/main.c | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6238fe7..900db30 100644 --- a/.gitignore +++ b/.gitignore @@ -109,4 +109,5 @@ wifi_credentials.h credentials.h # Project-specific ignores -# Add any project-specific files to ignore here \ No newline at end of file +# Add any project-specific files to ignore here +main/Kconfig.projbuild \ No newline at end of file diff --git a/main/main.c b/main/main.c index 8dc2a18..ee9537a 100644 --- a/main/main.c +++ b/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); }