Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions wled00/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (n >= multiWiFi.size()) multiWiFi.emplace_back(); // expand vector by one
char oldSSID[33]; strcpy(oldSSID, multiWiFi[n].clientSSID);
char oldPass[65]; strcpy(oldPass, multiWiFi[n].clientPass);
uint8_t oldBSSID[6]; memcpy(oldBSSID, multiWiFi[n].bssid, 6); // save old BSSID

strlcpy(multiWiFi[n].clientSSID, request->arg(cs).c_str(), 33);
if (strlen(oldSSID) == 0 || strncmp(multiWiFi[n].clientSSID, oldSSID, 32) != 0) {
Expand All @@ -46,6 +47,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
forceReconnect = true;
}
fillStr2MAC(multiWiFi[n].bssid, request->arg(bs).c_str());
if (memcmp(oldBSSID, multiWiFi[n].bssid, 6) != 0) { // check if BSSID changed
forceReconnect = true;
}
for (size_t i = 0; i < 4; i++) {
ip[3] = 48+i;
gw[3] = 48+i;
Expand Down
24 changes: 22 additions & 2 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ void WLED::setup()

if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0 && !configBackupExists())
showWelcomePage = true;

#ifndef ESP8266
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
#endif
WiFi.persistent(false);
WiFi.onEvent(WiFiEvent);
WiFi.mode(WIFI_STA); // enable scanning
Expand Down Expand Up @@ -727,7 +731,15 @@ void WLED::initConnection()
wifi_station_clear_enterprise_username();
wifi_station_clear_enterprise_password();
#endif
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass);
uint8_t *bssid = nullptr;
// check if user BSSID is non zero for current WiFi config
for (int i = 0; i < sizeof(multiWiFi[selectedWiFi].bssid); i++) {
if (multiWiFi[selectedWiFi].bssid[i] != 0) {
bssid = multiWiFi[selectedWiFi].bssid; // BSSID set, assign pointer and continue
break;
}
}
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass, 0, bssid); // no harm if called multiple times
} else { // WIFI_ENCRYPTION_TYPE_ENTERPRISE
DEBUG_PRINTF_P(PSTR("Using WPA2_AUTH_PEAP (Anon: %s, Ident: %s)\n"), multiWiFi[selectedWiFi].enterpriseAnonIdentity, multiWiFi[selectedWiFi].enterpriseIdentity);
#ifdef ESP8266
Expand All @@ -746,7 +758,15 @@ void WLED::initConnection()
#endif
}
#else // WLED_ENABLE_WPA_ENTERPRISE
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass); // no harm if called multiple times
uint8_t *bssid = nullptr;
// check if user BSSID is non zero for current WiFi config
for (int i = 0; i < sizeof(multiWiFi[selectedWiFi].bssid); i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment

if (multiWiFi[selectedWiFi].bssid[i] != 0) {
bssid = multiWiFi[selectedWiFi].bssid; // BSSID set, assign pointer and continue
break;
}
}
WiFi.begin(multiWiFi[selectedWiFi].clientSSID, multiWiFi[selectedWiFi].clientPass, 0, bssid); // no harm if called multiple times
#endif // WLED_ENABLE_WPA_ENTERPRISE

#ifdef ARDUINO_ARCH_ESP32
Expand Down