mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 01:42:15 +00:00
Disable automatic NodeInfo request when NodeDB is full (#5255)
This commit is contained in:
parent
50dac38a1b
commit
f3b698905d
@ -86,9 +86,9 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
|
|||||||
LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo"); // because this potentially a Repeater which will
|
LOG_DEBUG("Received telemetry response. Skip sending our NodeInfo"); // because this potentially a Repeater which will
|
||||||
// ignore our request for its NodeInfo
|
// ignore our request for its NodeInfo
|
||||||
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
||||||
nodeInfoModule && !isPreferredRebroadcaster) {
|
nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) {
|
||||||
if (airTime->isTxAllowedChannelUtil(true)) {
|
if (airTime->isTxAllowedChannelUtil(true)) {
|
||||||
LOG_INFO("Heard new node on ch. %d, sending NodeInfo and asking for a response", mp->channel);
|
LOG_INFO("Heard new node on ch. %d, send NodeInfo and ask for response", mp->channel);
|
||||||
nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel);
|
nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Skip sending NodeInfo > 25%% ch. util");
|
LOG_DEBUG("Skip sending NodeInfo > 25%% ch. util");
|
||||||
@ -421,4 +421,4 @@ uint32_t MeshService::GetTimeSinceMeshPacket(const meshtastic_MeshPacket *mp)
|
|||||||
delta = 0;
|
delta = 0;
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
@ -1206,13 +1206,19 @@ meshtastic_NodeInfoLite *NodeDB::getMeshNode(NodeNum n)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if the maximum number of nodes is reached or we are running low on memory
|
||||||
|
bool NodeDB::isFull()
|
||||||
|
{
|
||||||
|
return (numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < MINIMUM_SAFE_FREE_HEAP);
|
||||||
|
}
|
||||||
|
|
||||||
/// Find a node in our DB, create an empty NodeInfo if missing
|
/// Find a node in our DB, create an empty NodeInfo if missing
|
||||||
meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
||||||
{
|
{
|
||||||
meshtastic_NodeInfoLite *lite = getMeshNode(n);
|
meshtastic_NodeInfoLite *lite = getMeshNode(n);
|
||||||
|
|
||||||
if (!lite) {
|
if (!lite) {
|
||||||
if ((numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < MINIMUM_SAFE_FREE_HEAP)) {
|
if (isFull()) {
|
||||||
if (screen)
|
if (screen)
|
||||||
screen->print("Warn: node database full!\nErasing oldest entry\n");
|
screen->print("Warn: node database full!\nErasing oldest entry\n");
|
||||||
LOG_WARN("Node database full with %i nodes and %i bytes free! Erasing oldest entry", numMeshNodes,
|
LOG_WARN("Node database full with %i nodes and %i bytes free! Erasing oldest entry", numMeshNodes,
|
||||||
@ -1279,4 +1285,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
|
|||||||
LOG_ERROR("A critical failure occurred, portduino is exiting...");
|
LOG_ERROR("A critical failure occurred, portduino is exiting...");
|
||||||
exit(2);
|
exit(2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -147,6 +147,9 @@ class NodeDB
|
|||||||
meshtastic_NodeInfoLite *getMeshNode(NodeNum n);
|
meshtastic_NodeInfoLite *getMeshNode(NodeNum n);
|
||||||
size_t getNumMeshNodes() { return numMeshNodes; }
|
size_t getNumMeshNodes() { return numMeshNodes; }
|
||||||
|
|
||||||
|
// returns true if the maximum number of nodes is reached or we are running low on memory
|
||||||
|
bool isFull();
|
||||||
|
|
||||||
void clearLocalPosition();
|
void clearLocalPosition();
|
||||||
|
|
||||||
void setLocalPosition(meshtastic_Position position, bool timeOnly = false)
|
void setLocalPosition(meshtastic_Position position, bool timeOnly = false)
|
||||||
|
Loading…
Reference in New Issue
Block a user