2019-12-03 23:16:06 +00:00
|
|
|
#include <ESP8266React.h>
|
2020-05-14 23:23:45 +01:00
|
|
|
#include <LightMqttSettingsService.h>
|
|
|
|
#include <LightStateService.h>
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
#define SERIAL_BAUD_RATE 115200
|
|
|
|
|
|
|
|
AsyncWebServer server(80);
|
2020-07-19 19:32:08 +01:00
|
|
|
ESP8266React esp8266React(&server);
|
2020-05-14 23:23:45 +01:00
|
|
|
LightMqttSettingsService lightMqttSettingsService =
|
2020-07-19 19:32:08 +01:00
|
|
|
LightMqttSettingsService(&server, esp8266React.getFS(), esp8266React.getSecurityManager());
|
2020-05-14 23:23:45 +01:00
|
|
|
LightStateService lightStateService = LightStateService(&server,
|
|
|
|
esp8266React.getSecurityManager(),
|
|
|
|
esp8266React.getMqttClient(),
|
|
|
|
&lightMqttSettingsService);
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
void setup() {
|
2019-08-09 15:53:39 +01:00
|
|
|
// start serial and filesystem
|
2019-06-07 20:08:46 +01:00
|
|
|
Serial.begin(SERIAL_BAUD_RATE);
|
2019-09-30 21:28:24 +01:00
|
|
|
|
|
|
|
// start the framework and demo project
|
|
|
|
esp8266React.begin();
|
2019-09-30 21:38:44 +01:00
|
|
|
|
2020-05-14 23:23:45 +01:00
|
|
|
// load the initial light settings
|
|
|
|
lightStateService.begin();
|
|
|
|
|
|
|
|
// start the light service
|
|
|
|
lightMqttSettingsService.begin();
|
2019-09-30 21:28:24 +01:00
|
|
|
|
2019-08-09 15:53:39 +01:00
|
|
|
// start the server
|
2019-06-07 20:08:46 +01:00
|
|
|
server.begin();
|
2018-02-26 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2019-08-09 15:53:39 +01:00
|
|
|
// run the framework's loop function
|
2019-09-30 21:28:24 +01:00
|
|
|
esp8266React.loop();
|
2018-02-26 00:11:31 +00:00
|
|
|
}
|