-->
Page 1 of 1

Espalexa, ElegantOTA and webserver causing esp to crash

PostPosted: Mon Nov 15, 2021 11:07 am
by mrlightsman
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
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.

Re: Espalexa, ElegantOTA and webserver causing esp to crash

PostPosted: Mon Nov 15, 2021 7:28 pm
by mrlightsman
I ran the exception decoder. Here is what it shared. It means nothing to me. Maybe someone can help me understand it? Thanks.

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x40216773
EXCVADDR: 0x00000084

Decoding stack results
0x40212d81: String::invalidate() at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 295
0x402061fb: esp8266webserver::ESP8266WebServerTemplate::on(Uri const&, HTTPMethod, std::function) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 231
0x40100873: umm_free_core(umm_heap_context_t*, void*) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 549
0x40216e10: std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}>::_M_manager(std::_Any_data&, std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}> const&, std::_Manager_operation) at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 268
0x402103c4: std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h line 103
0x4020faa3: esp8266httpupdateserver::ESP8266HTTPUpdateServerTemplate::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&) at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 303
0x40216e10: std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}>::_M_manager(std::_Any_data&, std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}> const&, std::_Manager_operation) at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 268
0x402103c4: std::_Function_handler::setup(esp8266webserver::ESP8266WebServerTemplate*, String const&, String const&, String const&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h line 103
0x40212f3c: String::copy(char const*, unsigned int) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 225
0x40210186: std::_Function_handler >::_M_invoke(const std::_Any_data &) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 79
0x402054f8: Uri::canHandle(String const&, std::vector >&) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 146
0x401000e9: std::function::operator()() const at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 617
0x402062d9: esp8266webserver::FunctionRequestHandler::handle(esp8266webserver::ESP8266WebServerTemplate&, HTTPMethod, String const&) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/detail/RequestHandlersImpl.h line 42
0x40208028: esp8266webserver::ESP8266WebServerTemplate::_handleRequest() at c:\users\myuser\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h line 498
0x401001a8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181
0x4020aa22: esp8266webserver::ESP8266WebServerTemplate::handleClient() at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h line 274
0x401002bd: millis() at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193
0x4020abef: Espalexa::loop() at C:\Users\myuser\Documents\Arduino\libraries\Espalexa\src/Espalexa.h line 363
0x40213698: String::equals(String const&) const at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 492
0x4020ad83: loop() at C:\Users\myuser\Desktop\Rescue_Light\Emegency_Light_ESPAlexa_v0.3/Emegency_Light_ESPAlexa_v0.3.ino line 201
0x401001a8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181
0x4021438c: loop_wrapper() at C:\Users\myuser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 201