witnessmenow / esp8266-alexa-wemo-emulator

multiple belkin wemos switch emulator using ESP8266
GNU General Public License v2.0
132 stars 43 forks source link

Using only one webserver #13

Open hundsmiachn opened 6 years ago

hundsmiachn commented 6 years ago

Hi

First of all thanks for your effort to integrate our beloved ESP8266 "into Alexa framework"! I integrated your code into my current project. Unfortunately I ran out of heap using your files. As I dont have an Echo yet I cannot try it for myself but I have a suggestion: My Project already uses a WebServer, so I dont think that It is necessary to start some more for every device. Wouldn't it be easier to respond to the UDP Broadcast (respondToSearch) with a different URL depending on the number of the device: for example:

"LOCATION: http://" + String(s) + ":" + String(localPort) + "/setup1.xml\r\n"
"LOCATION: http://" + String(s) + ":" + String(localPort) + "/setup2.xml\r\n"
...

And for the callback registration:

server->on("/setup1.xml", [&]() {
    handleSetupXml1();
  });
server->on("/setup2.xml", [&]() {
    handleSetupXml2();
  });
...

And for the events:

"<controlURL>/upnp/control/basicevent1</controlURL>"
"<controlURL>/upnp/control/basicevent2</controlURL>"
...

 server->on("/upnp/control/basicevent1", [&]() {
    handleUpnpControl1();
  });
 server->on("/upnp/control/basicevent2", [&]() {
    handleUpnpControl2();
  });

With some little adaptions for handling the number of course, but you get the idea.

Would this work or does the Belkin skill only accept setup.xml, /upnp/control/basicevent1 and nothing else ??

regards Erich

MrDadaGuy commented 5 years ago

I'm using ESPAsyncWebServer, I'm going to give this a try to see if it can run using existing web server instead of spinning up a new one...