Skip to content

Commit

Permalink
Add MaxNodes to Native
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Mar 16, 2024
1 parent 611f291 commit e83a7fe
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bin/config-dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ Logging:
Webserver:
# Port: 443 # Port for Webserver & Webservices
# RootPath: /usr/share/doc/meshtasticd/web # Root Dir of WebServer

General:
MaxNodes: 200
8 changes: 7 additions & 1 deletion src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace graphics
// #define SHOW_REDRAWS

// A text message frame + debug frame + all the node infos
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
FrameCallback *normalFrames;
static uint32_t targetFramerate = IDLE_FRAMERATE;
static char btPIN[16] = "888888";

Expand Down Expand Up @@ -893,6 +893,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_OledType screenType, OLEDDISPLAY_GEOMETRY geometry)
: concurrency::OSThread("Screen"), address_found(address), model(screenType), geometry(geometry), cmdQueue(32)
{
graphics::normalFrames = new FrameCallback[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
#if defined(USE_SH1106) || defined(USE_SH1107) || defined(USE_SH1107_128_64)
dispdev = new SH1106Wire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
Expand Down Expand Up @@ -931,6 +932,11 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
cmdQueue.setReader(this);
}

Screen::~Screen()
{
delete[] graphics::normalFrames;
}

/**
* Prepare the display for the unit going to the lowest power mode possible. Most screens will just
* poweroff, but eink screens will show a "I'm sleeping" graphic, possibly with a QR code
Expand Down
2 changes: 2 additions & 0 deletions src/graphics/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class Screen : public concurrency::OSThread
public:
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);

~Screen();

Screen(const Screen &) = delete;
Screen &operator=(const Screen &) = delete;

Expand Down
4 changes: 4 additions & 0 deletions src/mesh/PacketHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include "configuration.h"
#include "mesh-pb-constants.h"

#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif

PacketHistory::PacketHistory()
{
recentPackets.reserve(MAX_NUM_NODES); // Prealloc the worst case # of records - to prevent heap fragmentation
Expand Down
4 changes: 4 additions & 0 deletions src/mesh/mesh-pb-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#define MAX_RX_TOPHONE 32

/// max number of nodes allowed in the mesh
#if ARCH_PORTDUINO
#define MAX_NUM_NODES settingsMap[maxnodes]
#else
#define MAX_NUM_NODES (member_size(meshtastic_DeviceState, node_db_lite) / member_size(meshtastic_DeviceState, node_db_lite[0]))
#endif

/// Max number of channels allowed
#define MAX_NUM_CHANNELS (member_size(meshtastic_ChannelFile, channels) / member_size(meshtastic_ChannelFile, channels[0]))
Expand Down
3 changes: 3 additions & 0 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ void portduinoSetup()
settingsMap[webserverport] = (yamlConfig["Webserver"]["Port"]).as<int>(-1);
settingsStrings[webserverrootpath] = (yamlConfig["Webserver"]["RootPath"]).as<std::string>("");
}
if (yamlConfig["General"]) {
settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as<int>(MAX_NUM_NODES);
}

} catch (YAML::Exception e) {
std::cout << "*** Exception " << e.what() << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion src/platform/portduino/PortduinoGlue.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ enum configNames {
logoutputlevel,
webserver,
webserverport,
webserverrootpath
webserverrootpath,
maxnodes
};
enum { no_screen, st7789, st7735, st7735s, ili9341 };
enum { no_touchscreen, xpt2046, stmpe610 };
Expand Down
2 changes: 2 additions & 0 deletions src/shutdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void powerCommandsCheck()
SPI.end();
Wire.end();
Serial1.end();
if (screen)
delete screen;
reboot();
#else
rebootAtMsec = -1;
Expand Down

0 comments on commit e83a7fe

Please sign in to comment.