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

ESP32 AP mode problem #4595

Closed
naakhtar opened this issue Dec 1, 2020 · 9 comments
Closed

ESP32 AP mode problem #4595

naakhtar opened this issue Dec 1, 2020 · 9 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@naakhtar
Copy link

naakhtar commented Dec 1, 2020

Hardware:

Board: FireBeetle-ESP32 (ARDUINO IDE BOARD SELECTION)
Core Installation version: V1.0.4
IDE name: ARDUINO IDE V1.8.13
Flash Frequency: 80Mhz
PSRAM enabled: NOT SPECIFIED IN ARDUINO IDE
Upload Speed: 921600
Computer OS: Windows 10

Description:

Describe your problem here
We are trying make WEBSERVER using ESP32, on which we are accessing our designed webpages.
these webpages are written in HTML and CSS.

  • AP MODE used for the ESP32 WEBSERVER.
  • Webpages are not accessible in a web browser after successful connection with Access point of ESP32.

Sketch: (leave the backquotes for code formatting)

//Change the code below by your sketch
#include <WiFiClient.h>
#include <ESP32WebServer.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include "webpage.h"

String defaultAP = "apmode";
String defaultPASS = "11111111";

ESP32WebServer server(80);



void handleRoot() {
//  server.send(200, "text/plain", "hello from ESP32!");
server.send(200, "text/html", userlogin());
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}

void setup(void){
  Serial.begin(9600);
  Serial.println(" ");
  Serial.println("Configuring access point...");
  Deafault_AP_MODE();

  delay(100);


  server.on("/", handleRoot);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  delay(100);
  server.handleClient();
}

void Deafault_AP_MODE()
{
  WiFi.mode(WIFI_AP);delay(500);    
//  WiFi.softAPConfig( IPAddress(defIP0, defIP1, defIP2, defIP3),  IPAddress(192, 168, 2, 2), IPAddress(255, 255, 255, 0) );delay(500); 
  WiFi.softAP( defaultAP.c_str(), defaultPASS.c_str());delay(500); 
  WiFi.persistent(false);
//  defAPFlg=1;
//  Wmode = 0; 
  Serial.print("Default AP Mode Started at ");  Serial.println(WiFi.softAPIP());
}

String userlogin()
{

  String ptr = HTML_headernew("Login", "KVARTech", 20); //Read HTML contents
  ptr += login_setting_array;

  return ptr;
}

String HTML_headernew(String title, String companyname, int page_no)
{
  String ptr = "<!DOCTYPE html>";
  ptr += "<html>";
  ptr += "<head>";
   ptr += "<title>" + title + "</title>";
  ptr += cssforpage;
  ptr += "</head>";
  ptr +="<body>";
  ptr +="<div class=\"header\">";

//  ptr += KVARlogo;
  ptr +="<h1>" + companyname + "</h1>";
  ptr +="<h2>" + title + "</h2>";

  

  ptr +="</div>";

if(page_no > 10){
    return ptr;
}else{
    ptr +="<ul>";
//    if(CID_login.access_level == 0){
  if(page_no == 1) ptr +="<li style=\"float:left\"><a class=\"active\" href=\"/Home\">Home</a></li>"; else ptr +="<li style=\"float:left\"><a href=\"/Home\">Home</a></li>";
  if(page_no == 2) ptr +="<li style=\"float:left\"><a class=\"active\"href=\"/settings\">Log settings</a></li>"; else ptr +="<li style=\"float:left\"><a href=\"/settings\">Log settings</a></li>";
  if(page_no == 3) ptr +="<li style=\"float:left\"><a class=\"active\"href=\"/wifi_settings\">WiFi settings</a></li>"; else ptr +="<li style=\"float:left\"><a href=\"/wifi_settings\">WiFi settings</a></li>";
  if(page_no == 4) ptr +="<li style=\"float:left\"><a class=\"active\"href=\"/download_data\">Download data</a></li>"; else ptr +="<li style=\"float:left\"><a href=\"/download_data\">Download data</a></li>";
  if(page_no == 5) ptr +="<li style=\"float:left\"><a class=\"active\"href=\"/mail_settings\">Mail Settings</a></li>"; else ptr +="<li style=\"float:left\"><a href=\"/mail_settings\">Mail Settings</a></li>";  
//    }
    
  ptr +="<li><a href=\"/logout\">Logout</a></li>";
  ptr +="</ul>";
}
  return ptr;
}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here
14:27:22.844 -> dhcps: send_offer>>udp_sendto result 0 
@lbernstone
Copy link
Contributor

Use board "ESP32 Dev Module". Set Core Debug Level to verbose. This will give you more logging information.
protip: If you want help with your code, it should directly compile.

@mkfrey
Copy link
Contributor

mkfrey commented Dec 1, 2020

I think this is a duplicate of #2025, which has not been fixed.

Edit: Does not seem to be a duplicate. I mistakingly ignored the fact that your device doesn't crash.

@solartech77
Copy link

Hello world

@naakhtar
Copy link
Author

naakhtar commented Dec 3, 2020

Verbose Error Log 2
Verbose Error Log 1

@lbernstone
Copy link
Contributor

So, your issue is only with your Windows 10 PC connecting to the device? Your android phone is able to browse the web page? Disconnect your pc from any other networks (even wired), and try again.

@naakhtar
Copy link
Author

naakhtar commented Dec 4, 2020

As advised tried by disconnecting pc from any other network but still getting same result.

@EricMc1289
Copy link
Contributor

From your screenshot your are still connected to a wired network. The most os‘s route traffic to the network port that is online even if you use a ip as adress.
F.e. on ios i got problems getting the website of the esp because the iphone tries to connect to 192.168.4.1 over the mobile data. Try to give your pc only the esp wifi and no other network connection

@stale
Copy link

stale bot commented Jun 23, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jun 23, 2021
@stale
Copy link

stale bot commented Jul 8, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

5 participants