[GH-ISSUE #372] How to open a web page when connect successs? #314

Closed
opened 2026-02-28 01:24:41 +03:00 by kerem · 3 comments
Owner

Originally created by @tarzan115 on GitHub (Jun 2, 2017).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/372

hi @tzapu
thank you for your library.

when I connect success to a wifi I want to open the web with notification "Success" after window auto close. or "Faile" when connecting unsuccess. how to do that?

thank you so much

Originally created by @tarzan115 on GitHub (Jun 2, 2017). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/372 hi @tzapu thank you for your library. when I connect success to a wifi I want to open the web with notification "Success" after window auto close. or "Faile" when connecting unsuccess. how to do that? thank you so much
kerem closed this issue 2026-02-28 01:24:41 +03:00
Author
Owner

@tzapu commented on GitHub (Jun 2, 2017):

hi,

Thanks for the appreciation.

Unfortunately you can’t really do that, as by that point you will have most likely been disconnected from the module.

cheers

On 2 Jun 2017, at 11:53, Doanh Văn Lương notifications@github.com wrote:

hi @tzapu https://github.com/tzapu
thank you for your library.

when I connect success to a wifi I want to open the web with notification "Success" after window auto close. or "Faile" when connecting unsuccess. how to do that?

thank you so much


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/tzapu/WiFiManager/issues/372, or mute the thread https://github.com/notifications/unsubscribe-auth/AC2FkHyD-B8bMq1g-oj-8kICulAN5uhqks5r_82JgaJpZM4NuASr.

<!-- gh-comment-id:305743044 --> @tzapu commented on GitHub (Jun 2, 2017): hi, Thanks for the appreciation. Unfortunately you can’t really do that, as by that point you will have most likely been disconnected from the module. cheers > On 2 Jun 2017, at 11:53, Doanh Văn Lương <notifications@github.com> wrote: > > hi @tzapu <https://github.com/tzapu> > thank you for your library. > > when I connect success to a wifi I want to open the web with notification "Success" after window auto close. or "Faile" when connecting unsuccess. how to do that? > > thank you so much > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub <https://github.com/tzapu/WiFiManager/issues/372>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AC2FkHyD-B8bMq1g-oj-8kICulAN5uhqks5r_82JgaJpZM4NuASr>. >
Author
Owner

@tarzan115 commented on GitHub (Jun 2, 2017):

Hi,
I tried to modified function handleWifiSave by connecting wifi inside with connect_status after that check connection before sending web page to the server. when connecting success it showed "Success" on the web page before the auto close window. but when connecting failed, it can't show "Failed" in the web page. maybe you can figure out that situation.

void WiFiManager::handleWifiSave() {
  DEBUG_WM(F("WiFi save"));

  //SAVE/connect here
  _ssid = server->arg("s").c_str();
  _pass = server->arg("p").c_str();

  int connect_status = connectWifi(_ssid, _pass);
  //parameters
  for (int i = 0; i < _paramsCount; i++) {
    if (_params[i] == NULL) {
      break;
    }
    //read parameter
    String value = server->arg(_params[i]->getID()).c_str();
    //store it in array
    value.toCharArray(_params[i]->_value, _params[i]->_length);
    DEBUG_WM(F("Parameter"));
    DEBUG_WM(_params[i]->getID());
    DEBUG_WM(value);
  }

  String page = FPSTR(HTTP_HEAD);
  page.replace("{v}", "Credentials Saved");
  page += FPSTR(HTTP_SCRIPT);
  page += FPSTR(HTTP_STYLE);
  page += _customHeadElement;
  page += FPSTR(HTTP_HEAD_END);
  // page += FPSTR(HTTP_SAVED);
  page += "<h1>";
  if(connect_status == WL_CONNECTED)
  {
      page += "Success";
  }
  else
  {
      page += "Failed";
  }
  page += "</h1>"
  page += FPSTR(HTTP_END);

  server->sendHeader("Content-Length", String(page.length()));
  server->send(200, "text/html", page);

  DEBUG_WM(F("Sent wifi save page"));

  connect = true; //signal ready to connect/reset
}
<!-- gh-comment-id:305746710 --> @tarzan115 commented on GitHub (Jun 2, 2017): Hi, I tried to modified function `handleWifiSave` by connecting wifi inside with `connect_status` after that check connection before sending web page to the server. when connecting success it showed "Success" on the web page before the auto close window. but when connecting failed, it can't show "Failed" in the web page. maybe you can figure out that situation. ```c void WiFiManager::handleWifiSave() { DEBUG_WM(F("WiFi save")); //SAVE/connect here _ssid = server->arg("s").c_str(); _pass = server->arg("p").c_str(); int connect_status = connectWifi(_ssid, _pass); //parameters for (int i = 0; i < _paramsCount; i++) { if (_params[i] == NULL) { break; } //read parameter String value = server->arg(_params[i]->getID()).c_str(); //store it in array value.toCharArray(_params[i]->_value, _params[i]->_length); DEBUG_WM(F("Parameter")); DEBUG_WM(_params[i]->getID()); DEBUG_WM(value); } String page = FPSTR(HTTP_HEAD); page.replace("{v}", "Credentials Saved"); page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += _customHeadElement; page += FPSTR(HTTP_HEAD_END); // page += FPSTR(HTTP_SAVED); page += "<h1>"; if(connect_status == WL_CONNECTED) { page += "Success"; } else { page += "Failed"; } page += "</h1>" page += FPSTR(HTTP_END); server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); DEBUG_WM(F("Sent wifi save page")); connect = true; //signal ready to connect/reset } ```
Author
Owner

@tablatronix commented on GitHub (Aug 27, 2017):

This is hard to handle but it can be done, the problem is you have to disconnect ap to negotiate sta, and if sta fails then sta+ap is not even possible. So you have to disconnect sta and restart the ap all while having the page refresh properly.

It is definetly on list

<!-- gh-comment-id:325168906 --> @tablatronix commented on GitHub (Aug 27, 2017): This is hard to handle but it can be done, the problem is you have to disconnect ap to negotiate sta, and if sta fails then sta+ap is not even possible. So you have to disconnect sta and restart the ap all while having the page refresh properly. It is definetly on list
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#314
No description provided.