Files
spore/include/NodeInfo.h

29 lines
955 B
C++

#pragma once
#include "Globals.h"
#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