Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. #include <ESP8266React.h>
  2. #include <LightMqttSettingsService.h>
  3. #include <LightStateService.h>
  4. #include <FS.h>
  5. #define SERIAL_BAUD_RATE 115200
  6. AsyncWebServer server(80);
  7. ESP8266React esp8266React(&server, &SPIFFS);
  8. LightMqttSettingsService lightMqttSettingsService =
  9. LightMqttSettingsService(&server, &SPIFFS, esp8266React.getSecurityManager());
  10. LightStateService lightStateService = LightStateService(&server,
  11. esp8266React.getSecurityManager(),
  12. esp8266React.getMqttClient(),
  13. &lightMqttSettingsService);
  14. void setup() {
  15. // start serial and filesystem
  16. Serial.begin(SERIAL_BAUD_RATE);
  17. // start the file system (must be done before starting the framework)
  18. #ifdef ESP32
  19. SPIFFS.begin(true);
  20. #elif defined(ESP8266)
  21. SPIFFS.begin();
  22. #endif
  23. // start the framework and demo project
  24. esp8266React.begin();
  25. // load the initial light settings
  26. lightStateService.begin();
  27. // start the light service
  28. lightMqttSettingsService.begin();
  29. // start the server
  30. server.begin();
  31. }
  32. void loop() {
  33. // run the framework's loop function
  34. esp8266React.loop();
  35. }