[GH-ISSUE #1150] Set html page for startConfigPortal #987

Open
opened 2026-02-28 01:27:59 +03:00 by kerem · 5 comments
Owner

Originally created by @Abedi98 on GitHub (Nov 21, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1150

This is the code I wrote for the dedicated page for startConfigPortal.
But when I connect to the Device-AP, the information of the default portal page is displayed.

void handleRoot()
{
  wm.startWebPortal();
}

void handlePage() {
  server.send(200, "text/html", INDEX_HTML); //"text/plain"
}

void setup() {
.
.
.

if(WiFi.SSID() == ""){
    wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0));
    configtone();
    digitalWrite(D2, HIGH);
    digitalWrite(D3, HIGH);
    wm.autoConnect("ESP8266","1234567890xa");
    server.on("/", handleRoot);
    
  }else{ 
     
    Serial.println("after wireless availability : "+WiFi.SSID());
    wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0));
    wm.setConfigPortalBlocking(false);
    wm.startConfigPortal("Device-AP","password");
    server.on("/", handlePage);
  }

  server.begin();
}

hanndlePage() not displayed in 172,217,1,22

Originally created by @Abedi98 on GitHub (Nov 21, 2020). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1150 This is the code I wrote for the dedicated page for startConfigPortal. But when I connect to the Device-AP, the information of the default portal page is displayed. ``` void handleRoot() { wm.startWebPortal(); } void handlePage() { server.send(200, "text/html", INDEX_HTML); //"text/plain" } void setup() { . . . if(WiFi.SSID() == ""){ wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0)); configtone(); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); wm.autoConnect("ESP8266","1234567890xa"); server.on("/", handleRoot); }else{ Serial.println("after wireless availability : "+WiFi.SSID()); wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0)); wm.setConfigPortalBlocking(false); wm.startConfigPortal("Device-AP","password"); server.on("/", handlePage); } server.begin(); } ``` hanndlePage() not displayed in 172,217,1,22
Author
Owner

@tablatronix commented on GitHub (Nov 21, 2020):

You might have to use the web start callback, see the dev example

<!-- gh-comment-id:731504730 --> @tablatronix commented on GitHub (Nov 21, 2020): You might have to use the web start callback, see the dev example
Author
Owner

@Abedi98 commented on GitHub (Nov 21, 2020):

You might have to use the web start callback, see the dev example

Hello
I do not understand what you mean, please explain more

Thanks

<!-- gh-comment-id:731552136 --> @Abedi98 commented on GitHub (Nov 21, 2020): > You might have to use the web start callback, see the dev example Hello I do not understand what you mean, please explain more Thanks
Author
Owner

@Abedi98 commented on GitHub (Nov 21, 2020):

web start callback,


void handleRoot()
{
  wm.startWebPortal();
}

void handlePage() {
  server.send(200, "text/html", INDEX_HTML); //"text/plain"
}

void bindServerCallback()
{
  wm.server->on("/",handleRoot);
}

void bindServerCallback2()
{
  wm.server->on("/custom",handlePage);
}

void setup()
{
  Serial.println("SSID : "+WiFi.SSID());
  delay(1000);
  Serial.begin(115200);
 
  pinMode(D2, OUTPUT); //Green LED
  pinMode(D3, OUTPUT); //Red LED
  
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D8, LOW);

  if(WiFi.SSID() == ""){
    wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0));
    wm.setWebServerCallback(bindServerCallback);
    configtone();
    digitalWrite(D2, HIGH);
    digitalWrite(D3, HIGH);
    wm.autoConnect("ESP8266","1234567890xa");    
  }else{ 
     
    Serial.println("after wireless availability : "+WiFi.SSID());
    wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0));
    wm.setWebServerCallback(bindServerCallback2);
    wireless_availability();
    wm.setConfigPortalBlocking(false);
    wm.startConfigPortal("Device-AP","password");
  }

  server.begin();
}

not working ...

<!-- gh-comment-id:731558289 --> @Abedi98 commented on GitHub (Nov 21, 2020): > web start callback, ``` void handleRoot() { wm.startWebPortal(); } void handlePage() { server.send(200, "text/html", INDEX_HTML); //"text/plain" } void bindServerCallback() { wm.server->on("/",handleRoot); } void bindServerCallback2() { wm.server->on("/custom",handlePage); } void setup() { Serial.println("SSID : "+WiFi.SSID()); delay(1000); Serial.begin(115200); pinMode(D2, OUTPUT); //Green LED pinMode(D3, OUTPUT); //Red LED digitalWrite(D2, LOW); digitalWrite(D3, LOW); digitalWrite(D8, LOW); if(WiFi.SSID() == ""){ wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0)); wm.setWebServerCallback(bindServerCallback); configtone(); digitalWrite(D2, HIGH); digitalWrite(D3, HIGH); wm.autoConnect("ESP8266","1234567890xa"); }else{ Serial.println("after wireless availability : "+WiFi.SSID()); wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0)); wm.setWebServerCallback(bindServerCallback2); wireless_availability(); wm.setConfigPortalBlocking(false); wm.startConfigPortal("Device-AP","password"); } server.begin(); } ``` not working ...
Author
Owner

@Abedi98 commented on GitHub (Nov 21, 2020):

web start callback,


void handleRoot()
{
  wm.startWebPortal();
}

void handlePage() {
  server.send(200, "text/html", INDEX_HTML); //"text/plain"
}

void bindServerCallback()
{
  wm.server->on("/",handleRoot);
}

void bindServerCallback2()
{
  wm.server->on("/custom",handlePage);
}

void setup()
{
  Serial.println("SSID : "+WiFi.SSID());
  delay(1000);
  Serial.begin(115200);
 
  pinMode(D2, OUTPUT); //Green LED
  pinMode(D3, OUTPUT); //Red LED
  
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D8, LOW);

  if(WiFi.SSID() == ""){
    wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0));
    wm.setWebServerCallback(bindServerCallback);
    configtone();
    digitalWrite(D2, HIGH);
    digitalWrite(D3, HIGH);
    wm.autoConnect("ESP8266","1234567890xa");    
  }else{ 
     
    Serial.println("after wireless availability : "+WiFi.SSID());
    wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0));
    wm.setWebServerCallback(bindServerCallback2);
    wireless_availability();
    wm.setConfigPortalBlocking(false);
    wm.startConfigPortal("Device-AP","password");
  }

  server.begin();
}

not working ...

http://connectivitycheck.gstatic.com/generate_204

<!-- gh-comment-id:731561039 --> @Abedi98 commented on GitHub (Nov 21, 2020): > > web start callback, > > ``` > > void handleRoot() > { > wm.startWebPortal(); > } > > void handlePage() { > server.send(200, "text/html", INDEX_HTML); //"text/plain" > } > > void bindServerCallback() > { > wm.server->on("/",handleRoot); > } > > void bindServerCallback2() > { > wm.server->on("/custom",handlePage); > } > > void setup() > { > Serial.println("SSID : "+WiFi.SSID()); > delay(1000); > Serial.begin(115200); > > pinMode(D2, OUTPUT); //Green LED > pinMode(D3, OUTPUT); //Red LED > > digitalWrite(D2, LOW); > digitalWrite(D3, LOW); > digitalWrite(D8, LOW); > > if(WiFi.SSID() == ""){ > wm.setAPStaticIPConfig(IPAddress(172,217,1,28), IPAddress(172,217,1,28), IPAddress(255,255,255,0)); > wm.setWebServerCallback(bindServerCallback); > configtone(); > digitalWrite(D2, HIGH); > digitalWrite(D3, HIGH); > wm.autoConnect("ESP8266","1234567890xa"); > }else{ > > Serial.println("after wireless availability : "+WiFi.SSID()); > wm.setAPStaticIPConfig(IPAddress(172,217,1,22), IPAddress(172,217,1,22), IPAddress(255,255,255,0)); > wm.setWebServerCallback(bindServerCallback2); > wireless_availability(); > wm.setConfigPortalBlocking(false); > wm.startConfigPortal("Device-AP","password"); > } > > server.begin(); > } > ``` > > not working ... http://connectivitycheck.gstatic.com/generate_204
Author
Owner

@tablatronix commented on GitHub (Nov 21, 2020):

hmm, this is wrong

void handleRoot()
{
wm.startWebPortal();
}

why are you doing this?

also this ?
server.begin();

<!-- gh-comment-id:731608091 --> @tablatronix commented on GitHub (Nov 21, 2020): hmm, this is wrong void handleRoot() { wm.startWebPortal(); } why are you doing this? also this ? server.begin();
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#987
No description provided.