Espalexa, ElegantOTA and webserver causing esp to crash
Posted: Mon Nov 15, 2021 11:07 am
I am running the latest Arduino IDE with all board and libraries fully updated. I am programming an esp12E board.
Is it possible to run a webserver, espalexa and elegantOTA all at the same time? I am attempting to do so, but the esp crashes and restarts when I try to access the OTA update page. The standard webserver works fine. So does alexa control. To complicate matters, I also am running a softAP so the user can set up the initial wifi credentials. Here are snipets of my code.
in globals
in void setup()
In void loop()
I believe the problem is that I am trying to start the espalexa.begin and ElegantOTA.begin with (&server). But I am really not sure. The OTA is supposed to have a server.begin() after the elegantOTA.begin(&server), but espalexa says to eliminate that and replace it with espalexa.begin(&server). Is there a way to combine the espalexa and elegantOTA begin commands with the webserver begin? Thank you.
Is it possible to run a webserver, espalexa and elegantOTA all at the same time? I am attempting to do so, but the esp crashes and restarts when I try to access the OTA update page. The standard webserver works fine. So does alexa control. To complicate matters, I also am running a softAP so the user can set up the initial wifi credentials. Here are snipets of my code.
in globals
Code: Select all
//lots of other stuff. The relevant pieces are listed here
#include <Espalexa.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
#include <DNSServer.h>
#include <ElegantOTA.h> //https://github.com/ayushsharma82/ElegantOTA
//callback functions for alexa
void deviceOneChanged(uint8_t brightness);
void deviceTwoChanged(uint8_t brightness);
Espalexa espalexa;
//pointers for alexa devices
EspalexaDevice* d1;
EspalexaDevice* d2;
ESP8266WiFiMulti wifiMulti;
ESP8266WebServer server(80);
DNSServer dnsServer;
in void setup()
Code: Select all
//lots of other stuff going on, but here is the relevant pieces.
//setup softAP
WiFi.softAP(ap_SSID, ap_Password);
dnsServer.start(53, "Settings.com", WiFi.softAPIP());
//setup wifi
WiFi.disconnect(true);
wifiMulti.addAP(SSID1, PW1);
wifiMulti.addAP(SSID2, PW2);
//Setup Alexa
d1 = new EspalexaDevice(A_Click_Device, deviceOneChanged);
d2 = new EspalexaDevice(B_Click_Device, deviceTwoChanged);
espalexa.addDevice(d1);
espalexa.addDevice(d2);
server.on("/", handleRoot);
server.onNotFound([]() {
if (!espalexa.handleAlexaApiCall(server.uri(), server.arg(0))) {
server.send(404, "text/plain", "Not found");
}
});
//start servers
ElegantOTA.begin(&server);
espalexa.begin(&server);
In void loop()
Code: Select all
//again. lots of other code, but here are the relevant snipets.
dnsServer.processNextRequest();
server.handleClient();
espalexa.loop();
I believe the problem is that I am trying to start the espalexa.begin and ElegantOTA.begin with (&server). But I am really not sure. The OTA is supposed to have a server.begin() after the elegantOTA.begin(&server), but espalexa says to eliminate that and replace it with espalexa.begin(&server). Is there a way to combine the espalexa and elegantOTA begin commands with the webserver begin? Thank you.