WordClockESP/src/main.cpp

45 lines
1.2 KiB
C++
Raw Normal View History

#include <ESP8266React.h>
#include <LightMqttSettingsService.h>
#include <LightStateService.h>
#include <FS.h>
#define SERIAL_BAUD_RATE 115200
AsyncWebServer server(80);
ESP8266React esp8266React(&server, &SPIFFS);
LightMqttSettingsService lightMqttSettingsService =
LightMqttSettingsService(&server, &SPIFFS, esp8266React.getSecurityManager());
LightStateService lightStateService = LightStateService(&server,
esp8266React.getSecurityManager(),
esp8266React.getMqttClient(),
&lightMqttSettingsService);
void setup() {
2019-08-09 14:53:39 +00:00
// start serial and filesystem
Serial.begin(SERIAL_BAUD_RATE);
// start the file system (must be done before starting the framework)
#ifdef ESP32
SPIFFS.begin(true);
#elif defined(ESP8266)
SPIFFS.begin();
#endif
// start the framework and demo project
esp8266React.begin();
// load the initial light settings
lightStateService.begin();
// start the light service
lightMqttSettingsService.begin();
2019-08-09 14:53:39 +00:00
// start the server
server.begin();
}
void loop() {
2019-08-09 14:53:39 +00:00
// run the framework's loop function
esp8266React.loop();
}