Multiple SSID support

Hi,
fist of all, I love WLED and recently build 4 LED columns / bar / tube / pipe or whatever it is called :slight_smile:
These LED columns need to work in our home from the local network but also from another router whenever I take them for a party. So I would like the support of multiple SSIDs so that I don’t need to reconfigure the columns each time.
Since this feature is not supported, I made my own simple implementation. It is far from perfect, but it works for me. it supports two SSIDs and passwords but could easily be extended. If one SSID is configured, there is no difference with the current way of working. For multiple SSIDs, there is a penalty of 10 seconds between attempts to connect to connect multiple SSIDs. With no connection, the fallback to AP mode still works.
The SSID names are separated by a ‘,’ in the configuration, the same holds for passwords. E.g “ssid1,ssid2” and “passw1,passw2”. Make sure they are in the same order. The maximum number of characters specified for the SSID array and password array can be increased if you like. There is no check that the input will fit the array, so be carefull.

The code that needs to be adapted is in wled.cpp:
The original call to WiFi.begin needs to be replaced by:

std::string ssid_str(clientSSID);
std::string passw_str(clientPass);
std::string delim = “,”;

auto start1 = 0U;
auto end1 = ssid_str.find(delim);
auto start2 = 0U;
auto end2 = passw_str.find(delim);

if (end1 == std::string::npos) // Only one SSID specified
{
WiFi.begin(clientSSID, clientPass);
} else
{
//Serial.println(ssid_str.substr(start1, end1).c_str());
WiFi.begin(ssid_str.substr(start1, end1).c_str(), passw_str.substr(start2, end2).c_str());
delay(10000);
if( WiFi.status() != WL_CONNECTED)
{
start1 = end1 + delim.length();
end1 = ssid_str.find(delim, start1);
start2 = end2 + delim.length();
end2 = passw_str.find(delim, start2);
//Serial.println(ssid_str.substr(start1, end1).c_str());
WiFi.begin(ssid_str.substr(start1, end1).c_str(), passw_str.substr(start2, end2).c_str());
delay(10000);
}
}
Give it try if you have the same issue as I have.

WLED rules!

1 Like

If you want to implement this feature to a WLED project make a pull request on GitHub.

Please fork WLED repo, make changes and open a PR.

Hi, this is by far not a good solution to the problem, it is merely a hack to at least solve my problem in the simplest way. I am merely sharing this piece of code to help people with the same issue so it might help them in a simple way.
I have no intend of making this a PR. Maybe when the snow is gone, I will sit down in the sun and try to find a better solution :slight_smile:

I thought you are the one who made this PR

It turned out to be rather simple to implement this. The only real work was to make UI as comfortable as possible, while providing all options.
Here’s my attempt.

1 Like