- Restructure include/ and src/ directories with logical grouping - Move core components to spore/core/ (NodeContext, NetworkManager, TaskManager, ClusterManager, ApiServer) - Move services to spore/services/ (NodeService, NetworkService, ClusterService, TaskService) - Move types to spore/types/ (NodeInfo, ApiTypes, Config) - Move internal components to spore/internal/ (Globals) - Update all #include statements to use new namespace paths - Update platformio.ini build filters for all environments - Update all example files to use new include paths - Maintain backward compatibility for public API - Improve code organization, maintainability, and scalability This reorganization follows modern C++ project structure patterns and provides clear separation between public API, internal implementation, and utilities. All examples compile successfully with the new structure.
37 lines
862 B
C++
37 lines
862 B
C++
#include <Arduino.h>
|
|
#include "spore/Spore.h"
|
|
#include "RelayService.h"
|
|
|
|
// Choose a default relay pin. For ESP-01 this is GPIO0. Adjust as needed for your board.
|
|
#ifndef RELAY_PIN
|
|
#define RELAY_PIN 0
|
|
#endif
|
|
|
|
// Create Spore instance with custom labels
|
|
Spore spore({
|
|
{"app", "relay"},
|
|
{"device", "actuator"},
|
|
{"pin", String(RELAY_PIN)}
|
|
});
|
|
|
|
// Create custom service
|
|
RelayService* relayService = nullptr;
|
|
|
|
void setup() {
|
|
// Initialize the Spore framework
|
|
spore.setup();
|
|
|
|
// Create and add custom service
|
|
relayService = new RelayService(spore.getTaskManager(), RELAY_PIN);
|
|
spore.addService(relayService);
|
|
|
|
// Start the API server and complete initialization
|
|
spore.begin();
|
|
|
|
Serial.println("[Main] Relay service registered and ready!");
|
|
}
|
|
|
|
void loop() {
|
|
// Run the Spore framework loop
|
|
spore.loop();
|
|
} |