feat: implement Spore framework class as main orchestration layer #3
@@ -1,5 +1,5 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Spore.h"
|
#include "spore/Spore.h"
|
||||||
|
|
||||||
// Create Spore instance with custom labels
|
// Create Spore instance with custom labels
|
||||||
Spore spore({
|
Spore spore({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "NeoPatternService.h"
|
#include "NeoPatternService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
NeoPatternService::NeoPatternService(TaskManager& taskMgr, uint16_t numPixels, uint8_t pin, uint8_t type)
|
NeoPatternService::NeoPatternService(TaskManager& taskMgr, uint16_t numPixels, uint8_t pin, uint8_t type)
|
||||||
: taskManager(taskMgr),
|
: taskManager(taskMgr),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include "NeoPattern.cpp"
|
#include "NeoPattern.cpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Spore.h"
|
#include "spore/Spore.h"
|
||||||
#include "NeoPatternService.h"
|
#include "NeoPatternService.h"
|
||||||
|
|
||||||
#ifndef LED_STRIP_PIN
|
#ifndef LED_STRIP_PIN
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "NeoPixelService.h"
|
#include "NeoPixelService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
// Wheel helper: map 0-255 to RGB rainbow
|
// Wheel helper: map 0-255 to RGB rainbow
|
||||||
static uint32_t colorWheel(Adafruit_NeoPixel& strip, uint8_t pos) {
|
static uint32_t colorWheel(Adafruit_NeoPixel& strip, uint8_t pos) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Spore.h"
|
#include "spore/Spore.h"
|
||||||
#include "NeoPixelService.h"
|
#include "NeoPixelService.h"
|
||||||
|
|
||||||
#ifndef NEOPIXEL_PIN
|
#ifndef NEOPIXEL_PIN
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "RelayService.h"
|
#include "RelayService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
RelayService::RelayService(TaskManager& taskMgr, int pin)
|
RelayService::RelayService(TaskManager& taskMgr, int pin)
|
||||||
: taskManager(taskMgr), relayPin(pin), relayOn(false) {
|
: taskManager(taskMgr), relayPin(pin), relayOn(false) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
class RelayService : public Service {
|
class RelayService : public Service {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "Spore.h"
|
#include "spore/Spore.h"
|
||||||
#include "RelayService.h"
|
#include "RelayService.h"
|
||||||
|
|
||||||
// Choose a default relay pin. For ESP-01 this is GPIO0. Adjust as needed for your board.
|
// Choose a default relay pin. For ESP-01 this is GPIO0. Adjust as needed for your board.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
class Service {
|
class Service {
|
||||||
public:
|
public:
|
||||||
@@ -4,12 +4,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "NodeContext.h"
|
#include "core/NodeContext.h"
|
||||||
#include "NetworkManager.h"
|
#include "core/NetworkManager.h"
|
||||||
#include "ClusterManager.h"
|
#include "core/ClusterManager.h"
|
||||||
#include "ApiServer.h"
|
#include "core/ApiServer.h"
|
||||||
#include "TaskManager.h"
|
#include "core/TaskManager.h"
|
||||||
#include "services/Service.h"
|
#include "Service.h"
|
||||||
|
|
||||||
class Spore {
|
class Spore {
|
||||||
public:
|
public:
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include "NodeInfo.h"
|
#include "spore/types/NodeInfo.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include "ApiTypes.h"
|
#include "spore/types/ApiTypes.h"
|
||||||
|
|
||||||
class Service; // Forward declaration
|
class Service; // Forward declaration
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include "NodeInfo.h"
|
#include "spore/types/NodeInfo.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "NodeInfo.h"
|
#include "spore/types/NodeInfo.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include "Config.h"
|
#include "spore/types/Config.h"
|
||||||
#include "ApiTypes.h"
|
#include "spore/types/ApiTypes.h"
|
||||||
|
|
||||||
class NodeContext {
|
class NodeContext {
|
||||||
public:
|
public:
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
// Define our own callback type to avoid conflict with TaskScheduler
|
// Define our own callback type to avoid conflict with TaskScheduler
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
class ClusterService : public Service {
|
class ClusterService : public Service {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "NetworkManager.h"
|
#include "spore/core/NetworkManager.h"
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
|
|
||||||
class NetworkService : public Service {
|
class NetworkService : public Service {
|
||||||
public:
|
public:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <Updater.h>
|
#include <Updater.h>
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
class TaskService : public Service {
|
class TaskService : public Service {
|
||||||
@@ -30,9 +30,11 @@ board_build.flash_size = 1M
|
|||||||
lib_deps = ${common.lib_deps}
|
lib_deps = ${common.lib_deps}
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<examples/base/*.cpp>
|
+<examples/base/*.cpp>
|
||||||
+<src/*.c>
|
+<src/spore/*.cpp>
|
||||||
+<src/*.cpp>
|
+<src/spore/core/*.cpp>
|
||||||
+<src/services/*.cpp>
|
+<src/spore/services/*.cpp>
|
||||||
|
+<src/spore/types/*.cpp>
|
||||||
|
+<src/internal/*.cpp>
|
||||||
|
|
||||||
[env:d1_mini]
|
[env:d1_mini]
|
||||||
platform = platformio/espressif8266@^4.2.1
|
platform = platformio/espressif8266@^4.2.1
|
||||||
@@ -45,9 +47,11 @@ board_build.flash_size = 4M
|
|||||||
lib_deps = ${common.lib_deps}
|
lib_deps = ${common.lib_deps}
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<examples/base/*.cpp>
|
+<examples/base/*.cpp>
|
||||||
+<src/*.c>
|
+<src/spore/*.cpp>
|
||||||
+<src/*.cpp>
|
+<src/spore/core/*.cpp>
|
||||||
+<src/services/*.cpp>
|
+<src/spore/services/*.cpp>
|
||||||
|
+<src/spore/types/*.cpp>
|
||||||
|
+<src/internal/*.cpp>
|
||||||
|
|
||||||
[env:esp01_1m_relay]
|
[env:esp01_1m_relay]
|
||||||
platform = platformio/espressif8266@^4.2.1
|
platform = platformio/espressif8266@^4.2.1
|
||||||
@@ -61,9 +65,11 @@ board_build.flash_size = 1M
|
|||||||
lib_deps = ${common.lib_deps}
|
lib_deps = ${common.lib_deps}
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<examples/relay/*.cpp>
|
+<examples/relay/*.cpp>
|
||||||
+<src/*.c>
|
+<src/spore/*.cpp>
|
||||||
+<src/*.cpp>
|
+<src/spore/core/*.cpp>
|
||||||
+<src/services/*.cpp>
|
+<src/spore/services/*.cpp>
|
||||||
|
+<src/spore/types/*.cpp>
|
||||||
|
+<src/internal/*.cpp>
|
||||||
|
|
||||||
[env:esp01_1m_neopixel]
|
[env:esp01_1m_neopixel]
|
||||||
platform = platformio/espressif8266@^4.2.1
|
platform = platformio/espressif8266@^4.2.1
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Spore.h"
|
#include "spore/Spore.h"
|
||||||
#include "services/NodeService.h"
|
#include "spore/services/NodeService.h"
|
||||||
#include "services/NetworkService.h"
|
#include "spore/services/NetworkService.h"
|
||||||
#include "services/ClusterService.h"
|
#include "spore/services/ClusterService.h"
|
||||||
#include "services/TaskService.h"
|
#include "spore/services/TaskService.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
Spore::Spore() : ctx(), network(ctx), taskManager(ctx), cluster(ctx, taskManager),
|
Spore::Spore() : ctx(), network(ctx), taskManager(ctx), cluster(ctx, taskManager),
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
#include "services/Service.h"
|
#include "spore/Service.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
const char* ApiServer::methodToStr(int method) {
|
const char* ApiServer::methodToStr(int method) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "ClusterManager.h"
|
#include "spore/core/ClusterManager.h"
|
||||||
#include "Globals.h"
|
#include "spore/internal/Globals.h"
|
||||||
|
|
||||||
ClusterManager::ClusterManager(NodeContext& ctx, TaskManager& taskMgr) : ctx(ctx), taskManager(taskMgr) {
|
ClusterManager::ClusterManager(NodeContext& ctx, TaskManager& taskMgr) : ctx(ctx), taskManager(taskMgr) {
|
||||||
// Register callback for node_discovered event
|
// Register callback for node_discovered event
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "NetworkManager.h"
|
#include "spore/core/NetworkManager.h"
|
||||||
|
|
||||||
// SSID and password are now configured via Config class
|
// SSID and password are now configured via Config class
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "NodeContext.h"
|
#include "spore/core/NodeContext.h"
|
||||||
|
|
||||||
NodeContext::NodeContext() {
|
NodeContext::NodeContext() {
|
||||||
udp = new WiFiUDP();
|
udp = new WiFiUDP();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "TaskManager.h"
|
#include "spore/core/TaskManager.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
TaskManager::TaskManager(NodeContext& ctx) : ctx(ctx) {}
|
TaskManager::TaskManager(NodeContext& ctx) : ctx(ctx) {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "services/ClusterService.h"
|
#include "spore/services/ClusterService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
ClusterService::ClusterService(NodeContext& ctx) : ctx(ctx) {}
|
ClusterService::ClusterService(NodeContext& ctx) : ctx(ctx) {}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "services/NetworkService.h"
|
#include "spore/services/NetworkService.h"
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
NetworkService::NetworkService(NetworkManager& networkManager)
|
NetworkService::NetworkService(NetworkManager& networkManager)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "services/NodeService.h"
|
#include "spore/services/NodeService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
|
|
||||||
NodeService::NodeService(NodeContext& ctx, ApiServer& apiServer) : ctx(ctx), apiServer(apiServer) {}
|
NodeService::NodeService(NodeContext& ctx, ApiServer& apiServer) : ctx(ctx), apiServer(apiServer) {}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "services/TaskService.h"
|
#include "spore/services/TaskService.h"
|
||||||
#include "ApiServer.h"
|
#include "spore/core/ApiServer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
TaskService::TaskService(TaskManager& taskManager) : taskManager(taskManager) {}
|
TaskService::TaskService(TaskManager& taskManager) : taskManager(taskManager) {}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "Config.h"
|
#include "spore/types/Config.h"
|
||||||
|
|
||||||
Config::Config() {
|
Config::Config() {
|
||||||
// WiFi Configuration
|
// WiFi Configuration
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "NodeInfo.h"
|
#include "spore/types/NodeInfo.h"
|
||||||
#include "Globals.h"
|
#include "spore/internal/Globals.h"
|
||||||
|
|
||||||
const char* statusToStr(NodeInfo::Status status) {
|
const char* statusToStr(NodeInfo::Status status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
Reference in New Issue
Block a user