Don't let S&F send payloads if channel utilization is > 50%

This commit is contained in:
Jm Casler 2021-12-30 14:24:44 -08:00
parent cea35acfa0
commit a16dcbe9d0

View File

@ -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,8 +23,12 @@ int32_t StoreForwardPlugin::runOnce()
if (radioConfig.preferences.is_router) {
if (this->busy) {
// Send out the message queue.
if (this->busy) {
// Only send packets if the channel is less than 50% utilized.
if (airTime->channelUtilizationPercent() < 50) {
// DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index);
storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index);
@ -31,12 +36,17 @@ int32_t StoreForwardPlugin::runOnce()
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 {
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);