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

Get SSID and PASSWORD for current connect WIFI #103

Open
expertup opened this issue Jan 17, 2022 · 1 comment
Open

Get SSID and PASSWORD for current connect WIFI #103

expertup opened this issue Jan 17, 2022 · 1 comment

Comments

@expertup
Copy link

expertup commented Jan 17, 2022

I make WIFI mesh network. After connect to WIFI I want to get SSID and passord for connect to painlessMesh network.

After enter data in config page, the functions wifiManager.getConfiguredSTASSID() and wifiManager.getConfiguredSTAPassword() working and return entered data, but after restart module these function return nothing.

How to is possible get SSID and password from current connection?

void setup() {
  Serial.begin(115200);
  
  AsyncWiFiManager wifiManager(&server,&dns);

  wifiManager.autoConnect("AutoConnectAP");

  mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION );  // set before init() so that you can see startup messages

  // Channel set to 6. Make sure to use the same channel for your mesh and for you other
  // network (STATION_SSID)
  mesh.init( MESH_PREFIX, MESH_PASSWORD, MESH_PORT, WIFI_AP_STA, 6, 1 );
  mesh.onReceive(&receivedCallback);

  Serial.println("My SSID is " + wifiManager.getConfiguredSTASSID());
  
  mesh.stationManual(wifiManager.getConfiguredSTASSID(), wifiManager.getConfiguredSTAPassword());
  //mesh.setHostname(HOSTNAME);

  mesh.setRoot(false);
  mesh.setContainsRoot(true);

  myAPIP = IPAddress(mesh.getAPIP());
  Serial.println("My AP IP is " + myAPIP.toString());

  //Async webserver
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/html", "<form>Text to Broadcast<br><input type='text' name='BROADCAST'><br><br><input type='submit' value='Submit'></form>");
    if (request->hasArg("BROADCAST")){
      String msg = request->arg("BROADCAST");
      mesh.sendBroadcast(msg);
    }
  });
  server.begin();

}
@expertup
Copy link
Author

https://arduino.stackexchange.com/a/85493/27856

Put these lines in setup() after wifiManager.autoConnect:

Serial.print("SSID: ");
Serial.println(WiFi.SSID());
Serial.print("psk: ");
Serial.println(WiFi.psk());

I will try this resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant