Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
545 stars 137 forks source link

A Guide on using Espalexa & WiFi Manager Together. And making them Compatible with each other. #99

Closed SiddhantShah2001 closed 4 years ago

SiddhantShah2001 commented 4 years ago

PROCEDURE: (Tested with Espalexa Version 2.6.0 & WiFi Manager Version 2.0.3-alpha)

STEP 1: Go to: My PC > Documents > Arduino > libraries > Espalexa > src < and Open up all three Files in the Folder named as: "Espalexa.h" "EspalexaDevice.h" "EspalexaDevice.cpp" in a Simple Text Editor or a Code Editor (I used Sublime Text).

STEP 2: In File: "Espalexa.h": Add Function:

void close()
{
  server->close();
}

before the line:


~Espalexa(){}

In File: "EspalexaDevice.h": Add Line:


void close();

at the End, after the Line:


void doCallback();

In File: "EspalexaDevice.cpp": Add Function:


void EspalexaDevice::close()
{
}

Just after the Function:


void EspalexaDevice::doCallback()
{
  if (_callback != nullptr) {_callback(_val); return;}
  if (_callbackDev != nullptr) {_callbackDev(this); return;}
  if (_callbackCol != nullptr) _callbackCol(_val, getRGB());
}

STEP 3: Last Step! Add Line:


espalexa.close();

just before you call the Config Portal. Also Remember to add a reset function at the end or atleast the begin function for Espalexa. i.e.:

  espalexa.close();
  WiFiManager wifiManager;
  wifiManager.startConfigPortal();
  ESP.reset(); // I would recommend this one than the one below.

or

  espalexa.close();
  WiFiManager wifiManager;
  wifiManager.startConfigPortal();
  espalexa.begin();

That's It!

GoTVm commented 2 years ago

This guide seems to work so far, it's the only solution but sadly it doesn't pop up if you Google search the issue. Had to scour both GitHub repos and see if anybody else had this issue.

gosth-coder commented 2 years ago

Hello, the last step, I did not understand it well, could you explain to me in which file the lines should be added. Thank you

GoTVm commented 2 years ago

You need to call espalexa.close() before you call the OnDemandConfig portal in your main sketch. Once it's done and it closes, you can espalexa.begin() again.