From a16dcbe9d0256f7681f233ab09d36f4b8dbfd9b5 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 30 Dec 2021 14:24:44 -0800 Subject: [PATCH 1/3] Don't let S&F send payloads if channel utilization is > 50% --- src/plugins/esp32/StoreForwardPlugin.cpp | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index 10dedda41..4b8152a08 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -3,6 +3,7 @@ #include "NodeDB.h" #include "RTC.h" #include "Router.h" +#include "airtime.h" #include "configuration.h" #include "mesh-pb-constants.h" #include "mesh/generated/storeforward.pb.h" @@ -22,20 +23,29 @@ int32_t StoreForwardPlugin::runOnce() if (radioConfig.preferences.is_router) { + // Send out the message queue. if (this->busy) { - // Send out the message queue. + - // DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index); - storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index); + // Only send packets if the channel is less than 50% utilized. + if (airTime->channelUtilizationPercent() < 50) { - if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) { - strcpy(this->routerMessage, "** S&F - Done"); - storeForwardPlugin->sendMessage(this->busyTo, this->routerMessage); - // DEBUG_MSG("--- --- --- In busy loop - Done \n"); - this->packetHistoryTXQueue_index = 0; - this->busy = false; + // DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index); + storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index); + + if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) { + strcpy(this->routerMessage, "** S&F - Done"); + storeForwardPlugin->sendMessage(this->busyTo, this->routerMessage); + + // DEBUG_MSG("--- --- --- In busy loop - Done \n"); + this->packetHistoryTXQueue_index = 0; + this->busy = false; + } else { + this->packetHistoryTXQueue_index++; + } + } else { - this->packetHistoryTXQueue_index++; + DEBUG_MSG("Channel utilization is too high. Skipping this oppurtunity to send and will retry later.\n"); } } DEBUG_MSG("SF myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate); From 8bbdfe45387246b20e2de0b815d2c0bc2368dd69 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 30 Dec 2021 15:01:19 -0800 Subject: [PATCH 2/3] Fix typo --- src/plugins/esp32/StoreForwardPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index 4b8152a08..f8194563e 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -45,7 +45,7 @@ int32_t StoreForwardPlugin::runOnce() } } else { - DEBUG_MSG("Channel utilization is too high. Skipping this oppurtunity to send and will retry later.\n"); + DEBUG_MSG("Channel utilization is too high. Skipping this opportunity to send and will retry later.\n"); } } DEBUG_MSG("SF myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate); From 924069f9ad285e4b09b3406fe5059654ad4e3113 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 1 Jan 2022 19:54:49 -0800 Subject: [PATCH 3/3] S&F - Only TX if utilization is below 25% --- src/plugins/esp32/StoreForwardPlugin.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/plugins/esp32/StoreForwardPlugin.cpp index f8194563e..f613fc7c0 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/plugins/esp32/StoreForwardPlugin.cpp @@ -27,8 +27,8 @@ int32_t StoreForwardPlugin::runOnce() if (this->busy) { - // Only send packets if the channel is less than 50% utilized. - if (airTime->channelUtilizationPercent() < 50) { + // Only send packets if the channel is less than 25% utilized. + if (airTime->channelUtilizationPercent() < 25) { // DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index); storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index); @@ -424,9 +424,6 @@ StoreForwardPlugin::StoreForwardPlugin() // Popupate PSRAM with our data structures. this->populatePSRAM(); - // this->packetTimeMax = 2000; - // DEBUG_MSG("SF Time to Transmit maxPacketSize (%d bytes) %d ms\n", maxPacketSize, this->packetTimeMax); - } else { DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n"); DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");