mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 06:42:34 +00:00
This is a non-breaking change that increases the internal representation of node counts from uint8_t (max 255) to uint16_t (max 65535) to support larger mesh networks, particularly on ESP32-S3 devices with PSRAM. Changes: - NodeStatus: numOnline, numTotal, lastNumTotal (uint8_t -> uint16_t) - ProtobufModule: numOnlineNodes (uint8_t -> uint16_t) - MapApplet: loop counters changed to size_t for consistency with getNumMeshNodes() - NodeStatus: Fixed log format to use %u for unsigned integers Note: Default class methods keep uint32_t for numOnlineNodes parameter to match the public API and allow flexibility, even though internal node counts use uint16_t (max 65535 nodes). This change does NOT affect protobuf definitions, maintaining wire compatibility with existing clients and devices.
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#pragma once
|
|
#include "Status.h"
|
|
#include "configuration.h"
|
|
#include <Arduino.h>
|
|
|
|
namespace meshtastic
|
|
{
|
|
|
|
/// Describes the state of the NodeDB system.
|
|
class NodeStatus : public Status
|
|
{
|
|
|
|
private:
|
|
CallbackObserver<NodeStatus, const NodeStatus *> statusObserver =
|
|
CallbackObserver<NodeStatus, const NodeStatus *>(this, &NodeStatus::updateStatus);
|
|
|
|
uint16_t numOnline = 0;
|
|
uint16_t numTotal = 0;
|
|
|
|
uint16_t lastNumTotal = 0;
|
|
|
|
public:
|
|
bool forceUpdate = false;
|
|
|
|
NodeStatus() { statusType = STATUS_TYPE_NODE; }
|
|
NodeStatus(uint16_t numOnline, uint16_t numTotal, bool forceUpdate = false) : Status()
|
|
{
|
|
this->forceUpdate = forceUpdate;
|
|
this->numOnline = numOnline;
|
|
this->numTotal = numTotal;
|
|
}
|
|
NodeStatus(const NodeStatus &);
|
|
NodeStatus &operator=(const NodeStatus &);
|
|
|
|
void observe(Observable<const NodeStatus *> *source) { statusObserver.observe(source); }
|
|
|
|
uint16_t getNumOnline() const { return numOnline; }
|
|
|
|
uint16_t getNumTotal() const { return numTotal; }
|
|
|
|
uint16_t getLastNumTotal() const { return lastNumTotal; }
|
|
|
|
bool matches(const NodeStatus *newStatus) const
|
|
{
|
|
return (newStatus->getNumOnline() != numOnline || newStatus->getNumTotal() != numTotal);
|
|
}
|
|
int updateStatus(const NodeStatus *newStatus)
|
|
{
|
|
// Only update the status if values have actually changed
|
|
lastNumTotal = numTotal;
|
|
bool isDirty;
|
|
{
|
|
isDirty = matches(newStatus);
|
|
initialized = true;
|
|
numOnline = newStatus->getNumOnline();
|
|
numTotal = newStatus->getNumTotal();
|
|
}
|
|
if (isDirty || newStatus->forceUpdate) {
|
|
LOG_DEBUG("Node status update: %u online, %u total", numOnline, numTotal);
|
|
onNewStatus.notifyObservers(this);
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
} // namespace meshtastic
|
|
|
|
extern meshtastic::NodeStatus *nodeStatus; |