- Add Spore class as unified interface for all core framework functionality - Implement setup() and begin() methods for flexible initialization pattern - Add service registration with addService() for both raw and smart pointers - Provide accessor methods for core components (getTaskManager, getContext, etc.) - Automatically include core services (Node, Network, Cluster, Task) - Update all examples to use simplified Spore framework approach - Fix circular dependency issues in include structure - Remove setHostname and setApiPort configuration methods - Add comprehensive documentation and usage examples The Spore class encapsulates all core functionality from the base example and provides a clean, unified API for the entire framework. Examples now use just spore.setup() -> add services -> spore.begin() -> spore.loop().
28 lines
934 B
C++
28 lines
934 B
C++
#pragma once
|
|
#include <IPAddress.h>
|
|
#include <vector>
|
|
#include <tuple>
|
|
#include <map>
|
|
#include "ApiTypes.h"
|
|
|
|
struct NodeInfo {
|
|
String hostname;
|
|
IPAddress ip;
|
|
unsigned long lastSeen;
|
|
enum Status { ACTIVE, INACTIVE, DEAD } status;
|
|
struct Resources {
|
|
uint32_t freeHeap = 0;
|
|
uint32_t chipId = 0;
|
|
String sdkVersion;
|
|
uint32_t cpuFreqMHz = 0;
|
|
uint32_t flashChipSize = 0;
|
|
} resources;
|
|
unsigned long latency = 0; // ms since lastSeen
|
|
std::vector<EndpointInfo> endpoints; // List of registered endpoints
|
|
std::map<String, String> labels; // Arbitrary node labels (key -> value)
|
|
};
|
|
|
|
const char* statusToStr(NodeInfo::Status status);
|
|
void updateNodeStatus(NodeInfo &node, unsigned long now, unsigned long inactive_threshold, unsigned long dead_threshold);
|
|
void updateNodeStatus(NodeInfo &node, unsigned long now = millis()); // Legacy overload for backward compatibility
|