Browse Source

Use built-in fauxmoESP HTTP handler when WEB_SUPPORT=0

sensors
Max Prokhorov 5 years ago
parent
commit
3f946692c4
1 changed files with 12 additions and 10 deletions
  1. +12
    -10
      code/espurna/alexa.ino

+ 12
- 10
code/espurna/alexa.ino View File

@ -36,14 +36,16 @@ void _alexaConfigure() {
alexa.enable(wifiConnected() && alexaEnabled());
}
bool _alexaBodyCallback(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
return alexa.process(request->client(), request->method() == HTTP_GET, request->url(), String((char *)data));
}
#if WEB_SUPPORT
bool _alexaBodyCallback(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
return alexa.process(request->client(), request->method() == HTTP_GET, request->url(), String((char *)data));
}
bool _alexaRequestCallback(AsyncWebServerRequest *request) {
String body = (request->hasParam("body", true)) ? request->getParam("body", true)->value() : String();
return alexa.process(request->client(), request->method() == HTTP_GET, request->url(), body);
}
bool _alexaRequestCallback(AsyncWebServerRequest *request) {
String body = (request->hasParam("body", true)) ? request->getParam("body", true)->value() : String();
return alexa.process(request->client(), request->method() == HTTP_GET, request->url(), body);
}
#endif
#if BROKER_SUPPORT
void _alexaBrokerCallback(const unsigned char type, const char * topic, unsigned char id, const char * payload) {
@ -79,7 +81,7 @@ void alexaSetup() {
moveSetting("fauxmoEnabled", "alexaEnabled");
// Basic fauxmoESP configuration
alexa.createServer(false);
alexa.createServer(!WEB_SUPPORT);
alexa.setPort(80);
// Uses hostname as base name for all devices
@ -116,6 +118,8 @@ void alexaSetup() {
// Websockets
#if WEB_SUPPORT
webBodyRegister(_alexaBodyCallback);
webRequestRegister(_alexaRequestCallback);
wsOnSendRegister(_alexaWebSocketOnSend);
wsOnReceiveRegister(_alexaWebSocketOnReceive);
#endif
@ -137,8 +141,6 @@ void alexaSetup() {
});
// Register main callbacks
webBodyRegister(_alexaBodyCallback);
webRequestRegister(_alexaRequestCallback);
#if BROKER_SUPPORT
brokerRegister(_alexaBrokerCallback);
#endif


Loading…
Cancel
Save