feat: config class

This commit is contained in:
2025-08-21 21:33:54 +02:00
parent 3124a7f2db
commit fd89c8e7eb
8 changed files with 110 additions and 25 deletions

View File

@@ -9,13 +9,18 @@ const char* statusToStr(NodeInfo::Status status) {
}
}
void updateNodeStatus(NodeInfo &node, unsigned long now) {
void updateNodeStatus(NodeInfo &node, unsigned long now, unsigned long inactive_threshold, unsigned long dead_threshold) {
unsigned long diff = now - node.lastSeen;
if (diff < NODE_INACTIVE_THRESHOLD) {
if (diff < inactive_threshold) {
node.status = NodeInfo::ACTIVE;
} else if (diff < NODE_INACTIVE_THRESHOLD) {
node.status = NodeInfo::INACTIVE;
} else if (diff < dead_threshold) {
node.status = NodeInfo::DEAD;
} else {
node.status = NodeInfo::DEAD;
}
}
void updateNodeStatus(NodeInfo &node, unsigned long now) {
// Legacy implementation using hardcoded values
updateNodeStatus(node, now, NODE_INACTIVE_THRESHOLD, NODE_DEAD_THRESHOLD);
}