mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 10:04:30 +01:00
add mqtt cat
This commit is contained in:
52
src/var/mqcatt/main.cpp
Normal file
52
src/var/mqcatt/main.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "mqcatt_config.h"
|
||||
#include <WiFiNet.h>
|
||||
#include <Sprocket.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WebServerConfig.h>
|
||||
#include <WebServerPlugin.h>
|
||||
#include <WebConfigPlugin.h>
|
||||
#include <WebApiPlugin.h>
|
||||
#include <PixelPlugin.h>
|
||||
#include <MqttPlugin.h>
|
||||
|
||||
WiFiNet *network;
|
||||
Sprocket *sprocket;
|
||||
AsyncWebServer *server;
|
||||
WebServerPlugin *webServerPlugin;
|
||||
WebConfigPlugin *webConfigPlugin;
|
||||
WebApiPlugin *webApiPlugin;
|
||||
PixelPlugin *pixelPlugin;
|
||||
MqttPlugin *mqttPlugin;
|
||||
|
||||
void setup()
|
||||
{
|
||||
sprocket = new Sprocket({STARTUP_DELAY, SERIAL_BAUD_RATE});
|
||||
pixelPlugin = new PixelPlugin({LED_STRIP_PIN, LED_STRIP_LENGTH, LED_STRIP_BRIGHTNESS, LED_STRIP_UPDATE_INTERVAL});
|
||||
mqttPlugin = new MqttPlugin({MQTT_CLIENT_NAME, MQTT_HOST, MQTT_PORT, MQTT_TOPIC_IN, MQTT_TOPIC_OUT});
|
||||
webServerPlugin = new WebServerPlugin({WEB_DOC_ROOT, WEB_CONTEXT_PATH, WEB_DEFAULT_FILE, WEB_PORT});
|
||||
webConfigPlugin = new WebConfigPlugin(webServerPlugin->server);
|
||||
webApiPlugin = new WebApiPlugin(webServerPlugin->server);
|
||||
sprocket->addPlugin(pixelPlugin);
|
||||
sprocket->addPlugin(webServerPlugin);
|
||||
sprocket->addPlugin(webConfigPlugin);
|
||||
sprocket->addPlugin(webApiPlugin);
|
||||
sprocket->addPlugin(mqttPlugin);
|
||||
|
||||
network = new WiFiNet(
|
||||
WIFI_MODE,
|
||||
STATION_SSID,
|
||||
STATION_PASSWORD,
|
||||
AP_SSID,
|
||||
AP_PASSWORD,
|
||||
HOSTNAME,
|
||||
CONNECT_TIMEOUT);
|
||||
network->connect();
|
||||
|
||||
sprocket->activate();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
sprocket->loop();
|
||||
yield();
|
||||
}
|
||||
Reference in New Issue
Block a user