Skip to content

Commit

Permalink
Merge branch 'master' into userPrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
gjelsoe authored Nov 14, 2024
2 parents 692b47d + 295278b commit a1ddca4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ void NodeDB::loadFromDisk()
// disk we will still factoryReset to restore things.

// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
auto state = loadProto(prefFileName, sizeof(meshtastic_DeviceState) + MAX_NUM_NODES * sizeof(meshtastic_NodeInfo),
auto state = loadProto(prefFileName, sizeof(meshtastic_DeviceState) + MAX_NUM_NODES_FS * sizeof(meshtastic_NodeInfo),
sizeof(meshtastic_DeviceState), &meshtastic_DeviceState_msg, &devicestate);

// See https://github.com/meshtastic/firmware/issues/4184#issuecomment-2269390786
Expand All @@ -843,6 +843,10 @@ void NodeDB::loadFromDisk()
meshNodes = &devicestate.node_db_lite;
numMeshNodes = devicestate.node_db_lite.size();
}
if (numMeshNodes > MAX_NUM_NODES) {
LOG_WARN("Node count %d exceeds MAX_NUM_NODES %d, truncating", numMeshNodes, MAX_NUM_NODES);
numMeshNodes = MAX_NUM_NODES;
}
meshNodes->resize(MAX_NUM_NODES);

state = loadProto(configFileName, meshtastic_LocalConfig_size, sizeof(meshtastic_LocalConfig), &meshtastic_LocalConfig_msg,
Expand Down
7 changes: 7 additions & 0 deletions src/mesh/mesh-pb-constants.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <vector>

#include "architecture.h"
#include "mesh/generated/meshtastic/admin.pb.h"
#include "mesh/generated/meshtastic/deviceonly.pb.h"
#include "mesh/generated/meshtastic/localonly.pb.h"
Expand All @@ -20,8 +21,14 @@

/// max number of nodes allowed in the mesh
#ifndef MAX_NUM_NODES
#ifdef ARCH_NRF52
#define MAX_NUM_NODES 80
#else
#define MAX_NUM_NODES 100
#endif
#endif

#define MAX_NUM_NODES_FS 100

/// Max number of channels allowed
#define MAX_NUM_CHANNELS (member_size(meshtastic_ChannelFile, channels) / member_size(meshtastic_ChannelFile, channels[0]))
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[VERSION]
major = 2
minor = 5
build = 14
build = 13

0 comments on commit a1ddca4

Please sign in to comment.