Pass in string of SSID

This commit is contained in:
2025-12-09 19:30:35 +11:00
parent fc84cfa66a
commit 4cc1de9c46
2 changed files with 15 additions and 5 deletions

View File

@@ -28,6 +28,8 @@ build_flags =
-DCORE_DEBUG_LEVEL=3
-DCONFIG_BT_ENABLED=1
-DCONFIG_BLUEDROID_ENABLED=1
-DSTA_SSID="${sysenv.STA_SSID}"
-DSTA_PASSWORD="${sysenv.STA_PASSWORD}"
; Libraries
lib_deps =

View File

@@ -31,9 +31,17 @@
// WiFi Mode: Set to true to connect to existing network, false for AP mode
#define WIFI_STATION_MODE true
#define ST(A) #A
#define STR(A) ST(A)
// WiFi Station mode settings (connect to existing network)
const char* STA_SSID = "MeridenRainbow5G"; // Your WiFi network name
const char* STA_PASSWORD = "4z8bcw5vfrs3n7dm"; // Your WiFi password
#ifndef STA_SSID
#define STA_SSID "ExampleSSID"
#endif
#ifndef STA_PASSWORD
#define STA_PASSWORD "ThePassword"
#endif
// WiFi Access Point fallback settings (if station fails or AP mode selected)
const char* AP_SSID = "ESP32-DebugDongle";
@@ -244,10 +252,10 @@ void setupWebServer() {
// ============================================================================
bool connectToWiFi() {
Serial.printf("[WiFi] Connecting to %s", STA_SSID);
Serial.printf("[WiFi] Connecting to %s", STR(STA_SSID));
WiFi.mode(WIFI_STA);
WiFi.begin(STA_SSID, STA_PASSWORD);
WiFi.begin(STR(STA_SSID), STR(STA_PASSWORD));
unsigned long startTime = millis();
while (WiFi.status() != WL_CONNECTED) {
@@ -260,7 +268,7 @@ bool connectToWiFi() {
}
Serial.println(" OK");
Serial.printf("[WiFi] Connected to: %s\n", STA_SSID);
Serial.printf("[WiFi] Connected to: %s\n", STR(STA_SSID));
Serial.printf("[WiFi] IP Address: %s\n", WiFi.localIP().toString().c_str());
Serial.printf("[WiFi] Signal strength: %d dBm\n", WiFi.RSSI());
return true;