Merge pull request #4891 from meshtastic/store-n-forward

First stab at enabling store and forward for Native
This commit is contained in:
Thomas Göttgens 2024-09-28 12:09:53 +02:00 committed by GitHub
commit 5a2c58197b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 23 additions and 10 deletions

View File

@ -58,10 +58,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
#include "esp_task_wdt.h" #include "esp_task_wdt.h"
#include "modules/esp32/StoreForwardModule.h" #include "modules/StoreForwardModule.h"
#endif #endif
#if ARCH_PORTDUINO #if ARCH_PORTDUINO
#include "modules/StoreForwardModule.h"
#include "platform/portduino/PortduinoGlue.h" #include "platform/portduino/PortduinoGlue.h"
#endif #endif

View File

@ -57,6 +57,8 @@ uint32_t MemGet::getFreePsram()
{ {
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
return ESP.getFreePsram(); return ESP.getFreePsram();
#elif defined(ARCH_PORTDUINO)
return 4194252;
#else #else
return 0; return 0;
#endif #endif
@ -71,6 +73,8 @@ uint32_t MemGet::getPsramSize()
{ {
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
return ESP.getPsramSize(); return ESP.getPsramSize();
#elif defined(ARCH_PORTDUINO)
return 4194252;
#else #else
return 0; return 0;
#endif #endif

View File

@ -13,9 +13,9 @@
#if defined(ARCH_PORTDUINO) && !HAS_RADIO #if defined(ARCH_PORTDUINO) && !HAS_RADIO
#include "../platform/portduino/SimRadio.h" #include "../platform/portduino/SimRadio.h"
#endif #endif
#ifdef ARCH_ESP32 #if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
#if !MESHTASTIC_EXCLUDE_STOREFORWARD #if !MESHTASTIC_EXCLUDE_STOREFORWARD
#include "modules/esp32/StoreForwardModule.h" #include "modules/StoreForwardModule.h"
#endif #endif
#endif #endif

View File

@ -32,12 +32,13 @@
#if HAS_WIFI #if HAS_WIFI
#include "mesh/wifi/WiFiAPClient.h" #include "mesh/wifi/WiFiAPClient.h"
#endif #endif
#include "modules/esp32/StoreForwardModule.h" #include "modules/StoreForwardModule.h"
#include <Preferences.h> #include <Preferences.h>
#include <nvs_flash.h> #include <nvs_flash.h>
#endif #endif
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
#include "modules/StoreForwardModule.h"
#include "platform/portduino/PortduinoGlue.h" #include "platform/portduino/PortduinoGlue.h"
#endif #endif

View File

@ -47,6 +47,9 @@
#endif #endif
#if ARCH_PORTDUINO #if ARCH_PORTDUINO
#include "input/LinuxInputImpl.h" #include "input/LinuxInputImpl.h"
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
#include "modules/StoreForwardModule.h"
#endif
#endif #endif
#if HAS_TELEMETRY #if HAS_TELEMETRY
#include "modules/Telemetry/DeviceTelemetry.h" #include "modules/Telemetry/DeviceTelemetry.h"
@ -67,7 +70,7 @@
#include "modules/esp32/PaxcounterModule.h" #include "modules/esp32/PaxcounterModule.h"
#endif #endif
#if !MESHTASTIC_EXCLUDE_STOREFORWARD #if !MESHTASTIC_EXCLUDE_STOREFORWARD
#include "modules/esp32/StoreForwardModule.h" #include "modules/StoreForwardModule.h"
#endif #endif
#endif #endif
#if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) #if defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040)

View File

@ -35,7 +35,7 @@ uint32_t heartbeatInterval = 60; // Default to 60 seconds, adjust as needed
int32_t StoreForwardModule::runOnce() int32_t StoreForwardModule::runOnce()
{ {
#ifdef ARCH_ESP32 #if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
if (moduleConfig.store_forward.enabled && is_server) { if (moduleConfig.store_forward.enabled && is_server) {
// Send out the message queue. // Send out the message queue.
if (this->busy) { if (this->busy) {
@ -82,8 +82,12 @@ void StoreForwardModule::populatePSRAM()
uint32_t numberOfPackets = uint32_t numberOfPackets =
(this->records ? this->records : (((memGet.getFreePsram() / 3) * 2) / sizeof(PacketHistoryStruct))); (this->records ? this->records : (((memGet.getFreePsram() / 3) * 2) / sizeof(PacketHistoryStruct)));
this->records = numberOfPackets; this->records = numberOfPackets;
#if defined(ARCH_ESP32)
this->packetHistory = static_cast<PacketHistoryStruct *>(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct))); this->packetHistory = static_cast<PacketHistoryStruct *>(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct)));
#elif defined(ARCH_PORTDUINO)
this->packetHistory = static_cast<PacketHistoryStruct *>(calloc(numberOfPackets, sizeof(PacketHistoryStruct)));
#endif
LOG_DEBUG("*** After PSRAM initialization: heap %d/%d PSRAM %d/%d\n", memGet.getFreeHeap(), memGet.getHeapSize(), LOG_DEBUG("*** After PSRAM initialization: heap %d/%d PSRAM %d/%d\n", memGet.getFreeHeap(), memGet.getHeapSize(),
memGet.getFreePsram(), memGet.getPsramSize()); memGet.getFreePsram(), memGet.getPsramSize());
@ -376,7 +380,7 @@ void StoreForwardModule::statsSend(uint32_t to)
*/ */
ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &mp) ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &mp)
{ {
#ifdef ARCH_ESP32 #if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
if (moduleConfig.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
if ((mp.decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) && is_server) { if ((mp.decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) && is_server) {
@ -559,7 +563,7 @@ StoreForwardModule::StoreForwardModule()
ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg) ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg)
{ {
#ifdef ARCH_ESP32 #if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
isPromiscuous = true; // Brown chicken brown cow isPromiscuous = true; // Brown chicken brown cow