Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gestion of Multiple SSID #35

Open
BugsBunny1403 opened this issue May 30, 2024 · 1 comment
Open

Add Gestion of Multiple SSID #35

BugsBunny1403 opened this issue May 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@BugsBunny1403
Copy link

BugsBunny1403 commented May 30, 2024

Hello,
if it possible to add an option for specify multiple SSID.
It's an example i use with the old version of your work before join prusa team.

WiFiMulti wifiMulti;

void setup() {

  // Add list of wifi networks
  wifiMulti.addAP("SSID1", "password1");
  wifiMulti.addAP("SSID2", "SSID2");
  
  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("Scan done");
  if (n == 0) {
      Serial.println("No networks found");
  } 
  else {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
      delay(10);
    }
  }
  
  // Connect to Wi-Fi using wifiMulti (connects to the SSID with strongest connection)
  Serial.println("Connecting Wifi...");
  if(wifiMulti.run() == WL_CONNECTED) {
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
  }

  Serial.println("");
  Serial.print("Signal Strength (RSSI): ");
  Serial.print(WiFi.RSSI());
  Serial.println(" dBm");
}

void loop() {
  Serial.println("----------------------------------------------------------------");
  /* check wifi reconnecting */
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Reconnecting to WiFi...");
  //if the connection to the stongest hotstop is lost, it will connect to the next network on the list
    if (wifiMulti.run(connectTimeoutMs) == WL_CONNECTED) {}

  } else if (WiFi.status() == WL_CONNECTED) {
    char cstr[150];
    sprintf(cstr, "Wifi connected. SSID: %s, RSSI: %d dBm, IP: %s \n", WiFi.SSID().c_str(), WiFi.RSSI(), WiFi.localIP().toString().c_str());
    Serial.printf(cstr);
  }
  
}
@johnyHV
Copy link
Collaborator

johnyHV commented May 30, 2024

Hello. I will look at the implementation and configuration of this option

@johnyHV johnyHV added the enhancement New feature or request label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants