The alexa device and the node mcu are on the same wifi network.
Below is my code but I am having a compilation error,
Compilation error: no matching function for call to 'Espalexa::addDevice(String&, void (&)())'
please help me fixing it
Code: Untitled.cpp Select all
#include <Espalexa.h>
const char* ssid = "ssid";
const char* password = "password";
String requestBody = "Switch";
ESP8266WebServer server(80);
Espalexa espalexa;
void SwitchChanged();
void handleRequest() {
requestBody = server.arg("plain"); // Get the POST data
Serial.println(requestBody);
server.send(200, "text/plain", "Data received");
}
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Add a virtual device to be discovered by Alexa
espalexa.addDevice(requestBody, handleRequest); // Specify the callback function without parentheses
espalexa.begin();
server.on("/", HTTP_POST, handleRequest); // Specify the callback function without parentheses
server.begin();
}
void loop() {
server.handleClient();
espalexa.loop(); // Include this to handle Espalexa tasks
}