Hi All,
I m Trying to integrate FauxmoESP with ESPAsyncWiFiManager ..
when i use FauxmoESP individually ..Alexa Discovers New Devices.. BUt when i add ESPAsyncWiFiManager to my code. The Code Shows no Error..It Compiles.. But Alexa is Not Discovering the New Devices..Please Help Me to Fix This..
Thanks
#if defined(ESP8266)
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
#else
#include <WiFi.h>
#endif
//needed for library
#include <ESPAsyncWebServer.h>
#include <ESPAsyncWiFiManager.h> //https://github.com/tzapu/WiFiManager
#include "fauxmoESP.h"
fauxmoESP fauxmo;
AsyncWebServer server(80);
DNSServer dns;
#define LED 2
void serverSetup() {
// Custom entry point (not required by the library, here just as an example)
server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", "Hello, world");
});
// These two callbacks are required for gen1 and gen3 compatibility
server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
if (fauxmo.process(request->client(), request->method() == HTTP_GET, request->url(), String((char *)data))) return;
// Handle any other body request here...
});
server.onNotFound([](AsyncWebServerRequest *request) {
String body = (request->hasParam("body", true)) ? request->getParam("body", true)->value() : String();
if (fauxmo.process(request->client(), request->method() == HTTP_GET, request->url(), body)) return;
// Handle not found request here...
});
// Start the server
server.begin();
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
AsyncWiFiManager wifiManager(&server,&dns);
//reset saved settings
//wifiManager.resetSettings();
//set custom ip for portal
//wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
//fetches ssid and pass from eeprom and tries to connect
//if it does not connect it starts an access point with the specified name
//here "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
wifiManager.autoConnect("AutoConnectAP");
//or use this for auto generated name ESP + ChipID
//wifiManager.autoConnect();
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
serverSetup();
fauxmo.createServer(false);
fauxmo.setPort(80); // This is required for gen3 devices
fauxmo.enable(true);
fauxmo.addDevice("kitchen");
fauxmo.addDevice("livingroom");
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
// For the example we are turning the same LED on and off regardless fo the device triggered or the value
digitalWrite(LED, !state); // we are nor-ing the state because our LED has inverse logic.
});
}
void loop() {
// put your main code here, to run repeatedly:
fauxmo.handle();
}