From 255713d23dad6a2cfd41fe973ca67d1d8ef7a6df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 19:33:20 -0600 Subject: [PATCH 1/5] [create-pull-request] automated change (#5258) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 6664f69b99..91c1f48232 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 11 +build = 12 From 8498b175e74fdb883eaef20e0e8f56c6726cef71 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 5 Nov 2024 20:06:43 -0600 Subject: [PATCH 2/5] Add exception for RTC to not strip time from position (#5262) * Add exception for RTC to not strip time from position * t --- src/modules/PositionModule.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 1baa550c09..b9847c22b0 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -251,6 +251,9 @@ meshtastic_MeshPacket *PositionModule::allocReply() if (getRTCQuality() < RTCQualityNTP) { LOG_INFO("Strip time %u from position send", p.time); p.time = 0; + } else if (rtc_found.address != ScanI2C::ADDRESS_NONE.address) { + LOG_INFO("Using RTC time %u for position send", p.time); + p.time = getValidTime(RTCQualityDevice); } else { p.time = getValidTime(RTCQualityNTP); LOG_INFO("Provide time to mesh %u", p.time); From 982190936dfe47b20a7147d4a6627a3ade7ac3c5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Nov 2024 07:03:25 -0600 Subject: [PATCH 3/5] More log reductions. I'll probably stop now ;-) (#5263) --- src/FSCommon.cpp | 2 +- src/airtime.cpp | 11 +++++------ src/graphics/EInkDynamicDisplay.cpp | 2 +- src/graphics/Screen.cpp | 2 +- src/input/MPR121Keyboard.cpp | 2 +- src/main.cpp | 4 ++-- src/mesh/NodeDB.cpp | 8 ++++---- src/mesh/RF95Interface.cpp | 2 +- src/mesh/SX128xInterface.cpp | 4 ++-- src/mesh/eth/ethClient.cpp | 6 +++--- src/mesh/http/ContentHandler.cpp | 4 ++-- src/mesh/http/WebServer.cpp | 8 ++++---- src/modules/AdminModule.cpp | 2 +- src/modules/DetectionSensorModule.cpp | 2 +- src/modules/NodeInfoModule.cpp | 4 ++-- src/modules/PositionModule.cpp | 4 ++-- src/modules/Telemetry/Sensor/TelemetrySensor.h | 2 +- src/shutdown.h | 2 +- 18 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 5eacead1ff..6cd17dac84 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -329,7 +329,7 @@ void fsInit() { #ifdef FSCom if (!FSBegin()) { - LOG_ERROR("Filesystem mount Failed."); + LOG_ERROR("Filesystem mount failed"); // assert(0); This auto-formats the partition, so no need to fail here. } #if defined(ARCH_ESP32) diff --git a/src/airtime.cpp b/src/airtime.cpp index cbd30a2d0a..a7736d6671 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -13,17 +13,17 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) { if (reportType == TX_LOG) { - LOG_DEBUG("Packet transmitted : %ums", airtime_ms); + LOG_DEBUG("Packet TX: %ums", airtime_ms); this->airtimes.periodTX[0] = this->airtimes.periodTX[0] + airtime_ms; air_period_tx[0] = air_period_tx[0] + airtime_ms; this->utilizationTX[this->getPeriodUtilHour()] = this->utilizationTX[this->getPeriodUtilHour()] + airtime_ms; } else if (reportType == RX_LOG) { - LOG_DEBUG("Packet received : %ums", airtime_ms); + LOG_DEBUG("Packet RX: %ums", airtime_ms); this->airtimes.periodRX[0] = this->airtimes.periodRX[0] + airtime_ms; air_period_rx[0] = air_period_rx[0] + airtime_ms; } else if (reportType == RX_ALL_LOG) { - LOG_DEBUG("Packet received (noise?) : %ums", airtime_ms); + LOG_DEBUG("Packet RX (noise?) : %ums", airtime_ms); this->airtimes.periodRX_ALL[0] = this->airtimes.periodRX_ALL[0] + airtime_ms; } @@ -126,7 +126,7 @@ bool AirTime::isTxAllowedChannelUtil(bool polite) if (channelUtilizationPercent() < percentage) { return true; } else { - LOG_WARN("Channel utilization is >%d percent. Skip opportunity to send.", percentage); + LOG_WARN("Ch. util >%d%%. Skip send", percentage); return false; } } @@ -137,8 +137,7 @@ bool AirTime::isTxAllowedAirUtil() if (utilizationTXPercent() < myRegion->dutyCycle * polite_duty_cycle_percent / 100) { return true; } else { - LOG_WARN("Tx air utilization is >%f percent. Skip opportunity to send.", - myRegion->dutyCycle * polite_duty_cycle_percent / 100); + LOG_WARN("TX air util. >%f%%. Skip send", myRegion->dutyCycle * polite_duty_cycle_percent / 100); return false; } } diff --git a/src/graphics/EInkDynamicDisplay.cpp b/src/graphics/EInkDynamicDisplay.cpp index 9a76a38c2a..6664646b99 100644 --- a/src/graphics/EInkDynamicDisplay.cpp +++ b/src/graphics/EInkDynamicDisplay.cpp @@ -170,7 +170,7 @@ bool EInkDynamicDisplay::determineMode() checkFastRequested(); if (refresh == UNSPECIFIED) - LOG_WARN("There was a flaw in the determineMode() logic."); + LOG_WARN("There was a flaw in the determineMode() logic"); // -- Decision has been reached -- applyRefreshMode(); diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 3e1361f1ec..bd0133740c 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1789,7 +1789,7 @@ int32_t Screen::runOnce() // serialSinceMsec adjusts for additional serial wait time during nRF52 bootup static bool showingBootScreen = true; if (showingBootScreen && (millis() > (logo_timeout + serialSinceMsec))) { - LOG_INFO("Done with boot screen..."); + LOG_INFO("Done with boot screen"); stopBootScreen(); showingBootScreen = false; } diff --git a/src/input/MPR121Keyboard.cpp b/src/input/MPR121Keyboard.cpp index 04a4245437..078d802728 100644 --- a/src/input/MPR121Keyboard.cpp +++ b/src/input/MPR121Keyboard.cpp @@ -116,7 +116,7 @@ void MPR121Keyboard::begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr) void MPR121Keyboard::reset() { - LOG_DEBUG("MPR121 Reset..."); + LOG_DEBUG("MPR121 Reset"); // Trigger a MPR121 Soft Reset if (m_wire) { m_wire->beginTransmission(m_addr); diff --git a/src/main.cpp b/src/main.cpp index 7f16d95b09..9f765eeb29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -435,7 +435,7 @@ void setup() // accessories auto i2cScanner = std::unique_ptr(new ScanI2CTwoWire()); #if HAS_WIRE - LOG_INFO("Scan for i2c devices..."); + LOG_INFO("Scan for i2c devices"); #endif #if defined(I2C_SDA1) && defined(ARCH_RP2040) @@ -460,7 +460,7 @@ void setup() i2cScanner->scanPort(ScanI2C::I2CPort::WIRE); #elif defined(ARCH_PORTDUINO) if (settingsStrings[i2cdev] != "") { - LOG_INFO("Scan for i2c devices..."); + LOG_INFO("Scan for i2c devices"); i2cScanner->scanPort(ScanI2C::I2CPort::WIRE); } #elif HAS_WIRE diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 928b62e06a..bb5a09eaac 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -647,7 +647,7 @@ void NodeDB::removeNodeByNum(NodeNum nodeNum) numMeshNodes -= removed; std::fill(devicestate.node_db_lite.begin() + numMeshNodes, devicestate.node_db_lite.begin() + numMeshNodes + 1, meshtastic_NodeInfoLite()); - LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries. Save changes...", removed); + LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries. Save changes", removed); saveDeviceStateToDisk(); } @@ -976,7 +976,7 @@ bool NodeDB::saveToDisk(int saveWhat) bool success = saveToDiskNoRetry(saveWhat); if (!success) { - LOG_ERROR("Failed to save to disk, retrying..."); + LOG_ERROR("Failed to save to disk, retrying"); #ifdef ARCH_NRF52 // @geeksville is not ready yet to say we should do this on other platforms. See bug #4184 discussion FSCom.format(); @@ -1152,7 +1152,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde // We just changed something about the user, store our DB Throttle::execute( &lastNodeDbSave, ONE_MINUTE_MS, []() { nodeDB->saveToDisk(SEGMENT_DEVICESTATE); }, - []() { LOG_DEBUG("Deferring NodeDB saveToDisk for now"); }); // since we saved less than a minute ago + []() { LOG_DEBUG("Defer NodeDB saveToDisk for now"); }); // since we saved less than a minute ago } return changed; @@ -1282,7 +1282,7 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co // Currently portuino is mostly used for simulation. Make sure the user notices something really bad happened #ifdef ARCH_PORTDUINO - LOG_ERROR("A critical failure occurred, portduino is exiting..."); + LOG_ERROR("A critical failure occurred, portduino is exiting"); exit(2); #endif } \ No newline at end of file diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index db56659bd6..9ef0450997 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -230,7 +230,7 @@ bool RF95Interface::reconfigure() err = lora->setPreambleLength(preambleLength); if (err != RADIOLIB_ERR_NONE) - LOG_ERROR(" RF95 setPreambleLength %s%d", radioLibErr, err); + LOG_ERROR("RF95 setPreambleLength %s%d", radioLibErr, err); assert(err == RADIOLIB_ERR_NONE); err = lora->setFrequency(getFreq()); diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index 9fe1f645f6..013164bca6 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -71,7 +71,7 @@ template bool SX128xInterface::init() LOG_INFO("SX128x init result %d", res); if ((config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) { - LOG_WARN("Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting."); + LOG_WARN("Radio only supports 2.4GHz LoRa. Adjusting Region and rebooting"); config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_LORA_24; nodeDB->saveToDisk(SEGMENT_CONFIG); delay(2000); @@ -80,7 +80,7 @@ template bool SX128xInterface::init() #elif defined(ARCH_NRF52) NVIC_SystemReset(); #else - LOG_ERROR("FIXME implement reboot for this platform. Skip for now."); + LOG_ERROR("FIXME implement reboot for this platform. Skip for now"); #endif } diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index c275d9c067..3b4d716f58 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -141,13 +141,13 @@ bool initEthernet() if (status == 0) { if (Ethernet.hardwareStatus() == EthernetNoHardware) { - LOG_ERROR("Ethernet shield was not found."); + LOG_ERROR("Ethernet shield was not found"); return false; } else if (Ethernet.linkStatus() == LinkOFF) { - LOG_ERROR("Ethernet cable is not connected."); + LOG_ERROR("Ethernet cable is not connected"); return false; } else { - LOG_ERROR("Unknown Ethernet error."); + LOG_ERROR("Unknown Ethernet error"); return false; } } else { diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 0fdfaabb9e..efa8164385 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -441,8 +441,8 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) return; } else { - LOG_ERROR("This should not have happened..."); - res->println("ERROR: This should not have happened..."); + LOG_ERROR("This should not have happened"); + res->println("ERROR: This should not have happened"); } } diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 20a200624e..d9856e157c 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -95,7 +95,7 @@ static void taskCreateCert(void *parameter) LOG_DEBUG("Retrieved Certificate: %d Bytes", cert->getCertLength()); } else { - LOG_INFO("Creating the certificate. This may take a while. Please wait..."); + LOG_INFO("Creating the certificate. This may take a while. Please wait"); yield(); cert = new SSLCert(); yield(); @@ -189,7 +189,7 @@ int32_t WebServerThread::runOnce() void initWebServer() { - LOG_DEBUG("Init Web Server..."); + LOG_DEBUG("Init Web Server"); // We can now use the new certificate to setup our server as usual. secureServer = new HTTPSServer(cert); @@ -198,10 +198,10 @@ void initWebServer() registerHandlers(insecureServer, secureServer); if (secureServer) { - LOG_INFO("Start Secure Web Server..."); + LOG_INFO("Start Secure Web Server"); secureServer->start(); } - LOG_INFO("Start Insecure Web Server..."); + LOG_INFO("Start Insecure Web Server"); insecureServer->start(); if (insecureServer->isRunning()) { LOG_INFO("Web Servers Ready! :-) "); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index fea199225a..5401e1fdb1 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -369,7 +369,7 @@ void AdminModule::handleGetModuleConfigResponse(const meshtastic_MeshPacket &mp, // Skip if it's disabled or no pins are exposed if (!r->get_module_config_response.payload_variant.remote_hardware.enabled || r->get_module_config_response.payload_variant.remote_hardware.available_pins_count == 0) { - LOG_DEBUG("Remote hardware module disabled or no available_pins. Skip..."); + LOG_DEBUG("Remote hardware module disabled or no available_pins. Skip"); return; } for (uint8_t i = 0; i < devicestate.node_remote_hardware_pins_count; i++) { diff --git a/src/modules/DetectionSensorModule.cpp b/src/modules/DetectionSensorModule.cpp index 0b9e74f326..cb27cbd489 100644 --- a/src/modules/DetectionSensorModule.cpp +++ b/src/modules/DetectionSensorModule.cpp @@ -76,7 +76,7 @@ int32_t DetectionSensorModule::runOnce() if (moduleConfig.detection_sensor.monitor_pin > 0) { pinMode(moduleConfig.detection_sensor.monitor_pin, moduleConfig.detection_sensor.use_pullup ? INPUT_PULLUP : INPUT); } else { - LOG_WARN("Detection Sensor Module: Set to enabled but no monitor pin is set. Disable module..."); + LOG_WARN("Detection Sensor Module: Set to enabled but no monitor pin is set. Disable module"); return disable(); } LOG_INFO("Detection Sensor Module: init"); diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 680ef08901..b55d47d5ba 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -70,11 +70,11 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply() } // If we sent our NodeInfo less than 5 min. ago, don't send it again as it may be still underway. if (!shorterTimeout && lastSentToMesh && Throttle::isWithinTimespanMs(lastSentToMesh, 5 * 60 * 1000)) { - LOG_DEBUG("Skip send NodeInfo since we sent it <5 mins ago."); + LOG_DEBUG("Skip send NodeInfo since we sent it <5min ago"); ignoreRequest = true; // Mark it as ignored for MeshModule return NULL; } else if (shorterTimeout && lastSentToMesh && Throttle::isWithinTimespanMs(lastSentToMesh, 60 * 1000)) { - LOG_DEBUG("Skip send requested NodeInfo since we sent it <60s ago."); + LOG_DEBUG("Skip send NodeInfo since we sent it <60s ago"); ignoreRequest = true; // Mark it as ignored for MeshModule return NULL; } else { diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index b9847c22b0..b7def82426 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -249,10 +249,10 @@ meshtastic_MeshPacket *PositionModule::allocReply() // nodes shouldn't trust it anyways) Note: we allow a device with a local GPS or NTP to include the time, so that devices // without can get time. if (getRTCQuality() < RTCQualityNTP) { - LOG_INFO("Strip time %u from position send", p.time); + LOG_INFO("Strip time %u from position", p.time); p.time = 0; } else if (rtc_found.address != ScanI2C::ADDRESS_NONE.address) { - LOG_INFO("Using RTC time %u for position send", p.time); + LOG_INFO("Use RTC time %u for position", p.time); p.time = getValidTime(RTCQualityDevice); } else { p.time = getValidTime(RTCQualityNTP); diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h index 0e38949d3a..08cc1125dd 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.h +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.h @@ -31,7 +31,7 @@ class TelemetrySensor int32_t initI2CSensor() { if (!status) { - LOG_WARN("Could not connect to detected %s sensor. Remove from nodeTelemetrySensorsMap.", sensorName); + LOG_WARN("Can't connect to detected %s sensor. Remove from nodeTelemetrySensorsMap", sensorName); nodeTelemetrySensorsMap[sensorType].first = 0; } else { LOG_INFO("Opened %s sensor on i2c bus", sensorName); diff --git a/src/shutdown.h b/src/shutdown.h index ad44045e5f..9e30e772c8 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -32,7 +32,7 @@ void powerCommandsCheck() reboot(); #else rebootAtMsec = -1; - LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied."); + LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied"); #endif } From 3bd391191320387b418a397f278bb46e0849b2c1 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:00:26 +0100 Subject: [PATCH 4/5] Only PKC encrypt when packet originates from us (#5267) --- src/mesh/Router.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 5eb2a5f501..ca9600cabc 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -489,7 +489,8 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p) meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to); // We may want to retool things so we can send a PKC packet when the client specifies a key and nodenum, even if the node // is not in the local nodedb - if ( + // First, only PKC encrypt packets we are originating + if (isFromUs(p) && // Don't use PKC with Ham mode !owner.is_licensed && // Don't use PKC if it's not explicitly requested and a non-primary channel is requested @@ -671,4 +672,4 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) // cache/learn of the existence of nodes (i.e. FloodRouter) that they should not handleReceived(p); packetPool.release(p); -} +} \ No newline at end of file From 73e2e25eb1d3e953fae438997b75c29e3e8ed07e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Nov 2024 15:00:53 -0600 Subject: [PATCH 5/5] Smarter traffic scaling (#5264) --- src/mesh/Default.cpp | 5 +++++ src/mesh/Default.h | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/mesh/Default.cpp b/src/mesh/Default.cpp index 653528b607..ba1dafe702 100644 --- a/src/mesh/Default.cpp +++ b/src/mesh/Default.cpp @@ -1,5 +1,6 @@ #include "Default.h" #include "../userPrefs.h" +#include "meshUtils.h" uint32_t Default::getConfiguredOrDefaultMs(uint32_t configuredInterval, uint32_t defaultInterval) { @@ -40,6 +41,10 @@ uint32_t Default::getConfiguredOrDefaultMsScaled(uint32_t configured, uint32_t d if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) return getConfiguredOrDefaultMs(configured, defaultValue); + // Additionally if we're a tracker or sensor, we want priority to send position and telemetry + if (IS_ONE_OF(config.device.role, meshtastic_Config_DeviceConfig_Role_SENSOR, meshtastic_Config_DeviceConfig_Role_TRACKER)) + return getConfiguredOrDefaultMs(configured, defaultValue); + return getConfiguredOrDefaultMs(configured, defaultValue) * congestionScalingCoefficient(numOnlineNodes); } diff --git a/src/mesh/Default.h b/src/mesh/Default.h index 2406dafc52..7a7507c84e 100644 --- a/src/mesh/Default.h +++ b/src/mesh/Default.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #define ONE_DAY 24 * 60 * 60 #define ONE_MINUTE_MS 60 * 1000 #define THIRTY_SECONDS_MS 30 * 1000 @@ -41,12 +42,30 @@ class Default private: static float congestionScalingCoefficient(int numOnlineNodes) { - if (numOnlineNodes <= 40) { - return 1.0; // No scaling for 40 or fewer nodes + // Increase frequency of broadcasts for small networks regardless of preset + if (numOnlineNodes <= 10) { + return 0.6; + } else if (numOnlineNodes <= 20) { + return 0.7; + } else if (numOnlineNodes <= 30) { + return 0.8; + } else if (numOnlineNodes <= 40) { + return 1.0; } else { - // Sscaling based on number of nodes over 40 + float throttlingFactor = 0.075; + if (config.lora.use_preset && config.lora.modem_preset == meshtastic_Config_LoRaConfig_ModemPreset_MEDIUM_SLOW) + throttlingFactor = 0.04; + else if (config.lora.use_preset && config.lora.modem_preset == meshtastic_Config_LoRaConfig_ModemPreset_MEDIUM_FAST) + throttlingFactor = 0.02; + else if (config.lora.use_preset && config.lora.modem_preset == meshtastic_Config_LoRaConfig_ModemPreset_SHORT_SLOW) + throttlingFactor = 0.01; + else if (config.lora.use_preset && + IS_ONE_OF(config.lora.modem_preset, meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST, + meshtastic_Config_LoRaConfig_ModemPreset_SHORT_TURBO)) + return 1.0; // Don't bother throttling for highest bandwidth presets + // Scaling up traffic based on number of nodes over 40 int nodesOverForty = (numOnlineNodes - 40); - return 1.0 + (nodesOverForty * 0.075); // Each number of online node scales by 0.075 + return 1.0 + (nodesOverForty * throttlingFactor); // Each number of online node scales by 0.075 (default) } } }; \ No newline at end of file