Skip to content

ESP32 OTAWebUpdater using softAP doesn't work #3076

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

Closed
amiltoromagno opened this issue Aug 8, 2019 · 10 comments
Closed

ESP32 OTAWebUpdater using softAP doesn't work #3076

amiltoromagno opened this issue Aug 8, 2019 · 10 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@amiltoromagno
Copy link

Board: ESP-WROOM32
Core Installation/update date: Latest
IDE: Arduino IDE
Flash Frequency: 80Mhz/40Mhz
Upload Speed: 115200
Computer OS: Windows 10

So, I'm creating a OTA update server using the OTAWebUpdater example. When I connect it to my WiFi router, it works perfectly. The problem is, if I create a softAP instead of connecting it to my WiFi, it doesn't work anymore. The browser window returns the following:

"Not found: /serverIndex".

In the code, the only changes I made were WiFi.softAP(ssid, pass) instead of WiFi.begin(ssid, pass), and I removed the "wait for connection" loop.

What should I do?

@lbernstone
Copy link
Contributor

Did you remark out the wait for connection part?

@amiltoromagno
Copy link
Author

Did you remark out the wait for connection part?

Yes, as soon as I noticed that it didn't work I tried without removing it and it still didn't work.

@lbernstone
Copy link
Contributor

The example works for me. Please turn on verbose logging under the tools menu, flash the program again, and post the log from serial monitor. Check that you can ping the device at 192.168.4.1 from your PC after you connect to the SoftAP.

@stale
Copy link

stale bot commented Oct 7, 2019

[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 Oct 7, 2019
@stale
Copy link

stale bot commented Oct 21, 2019

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

@stale stale bot closed this as completed Oct 21, 2019
@musalmz
Copy link

musalmz commented Feb 25, 2022

I am having the same problem. Can you help me pls?

@italocjs
Copy link

I think its related to the inclusion of a external code
"<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>"
since there is no internet available, this fails and it responds that the serverindex handler was not found. I'm not familiar with websites programming and have no idea on how to fix this.

@italocjs
Copy link

italocjs commented Mar 10, 2022

I managed to fix the issue thanks to a old post from "Machiel" (link: https://esp32.com/viewtopic.php?t=11744) in which he converted the jquery script and embedded it into the firmware (not using spiffs).

Here is the full, working code. (edit: embedded code was messed up, so i'm uploading it).

main.zip

@musalmz
Copy link

musalmz commented Mar 23, 2022

Thank you very much, the code works fine.

@R0binBl00d
Copy link

nice one, really love it. Was struggling with the "serverindex cannot be found" for quite some time ...

this even helped me with my SoftAP-approach.
But I didn't use the custom style or Strings instead of const char* ...

the only update required was the "PROGMEM", "script src=", "void onJavaScript" and the "server.on("/jquery.min.js", [...]);"

works perfectly without an external Wifi-Router :-)
Thanks again

#define jquery_min_js_v3_2_1_gz_len 30178
PROGMEM const char jquery_min_js_v3_2_1_gz[] = {
[...]
};

const char* serverIndex =
"<script src='/jquery.min.js'></script>"
[...]
"</script>";

void onJavaScript(void) {
Serial.println("onJavaScript(void)");
server.setContentLength(jquery_min_js_v3_2_1_gz_len);
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send_P(200, "text/javascript", jquery_min_js_v3_2_1_gz, jquery_min_js_v3_2_1_gz_len);
}

/* setup function */
void setup(void) {
Serial.begin(115200);

// Connect to WiFi network
WiFi.softAP(ssid, password);
Serial.println("");

Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());

/*use mdns for host name resolution*/
if (!MDNS.begin(host)) {
Serial.println("Error setting up MDNS responder!");
while (1) {
delay(1000);
}
}
Serial.println("mDNS responder started");
/*return javascript jquery */
server.on("/jquery.min.js", HTTP_GET, onJavaScript);
[...]
}

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